Battery: Only redraw when needed, not after each tick
This commit is contained in:
parent
5c474f4256
commit
8df91bd475
1 changed files with 17 additions and 17 deletions
|
@ -81,8 +81,19 @@ void update_battery_tick(void *arg)
|
||||||
tint_exec(ac_disconnected_cmd);
|
tint_exec(ac_disconnected_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (battery_state.percentage < battery_low_status && battery_state.state == BATTERY_DISCHARGING &&
|
||||||
|
!battery_low_cmd_sent) {
|
||||||
|
tint_exec(battery_low_cmd);
|
||||||
|
battery_low_cmd_sent = TRUE;
|
||||||
|
}
|
||||||
|
if (battery_state.percentage > battery_low_status && battery_state.state == BATTERY_CHARGING &&
|
||||||
|
battery_low_cmd_sent) {
|
||||||
|
battery_low_cmd_sent = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < num_panels; i++) {
|
for (i = 0; i < num_panels; i++) {
|
||||||
|
// Show/hide if needed
|
||||||
if (!battery_found) {
|
if (!battery_found) {
|
||||||
if (panels[i].battery.area.on_screen) {
|
if (panels[i].battery.area.on_screen) {
|
||||||
hide(&panels[i].battery.area);
|
hide(&panels[i].battery.area);
|
||||||
|
@ -101,25 +112,14 @@ void update_battery_tick(void *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Redraw if needed
|
||||||
if (panels[i].battery.area.on_screen) {
|
if (panels[i].battery.area.on_screen) {
|
||||||
panels[i].battery.area.resize_needed = 1;
|
if (old_found != battery_found || old_percentage != battery_state.percentage ||
|
||||||
|
old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) {
|
||||||
|
panels[i].battery.area.resize_needed = TRUE;
|
||||||
panel_refresh = TRUE;
|
panel_refresh = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_found == battery_found && old_percentage == battery_state.percentage &&
|
|
||||||
old_hours == battery_state.time.hours && old_minutes == battery_state.time.minutes) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (battery_state.percentage < battery_low_status && battery_state.state == BATTERY_DISCHARGING &&
|
|
||||||
!battery_low_cmd_sent) {
|
|
||||||
tint_exec(battery_low_cmd);
|
|
||||||
battery_low_cmd_sent = 1;
|
|
||||||
}
|
|
||||||
if (battery_state.percentage > battery_low_status && battery_state.state == BATTERY_CHARGING &&
|
|
||||||
battery_low_cmd_sent) {
|
|
||||||
battery_low_cmd_sent = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue