fix battery widget

This commit is contained in:
galister
2024-02-07 19:56:19 +01:00
parent 57f954025e
commit b14e70c2e9
2 changed files with 6 additions and 5 deletions

View File

@@ -164,7 +164,7 @@ where
canvas.fg_color = color_parse(&normal_fg_color).unwrap_or(FALLBACK_COLOR); canvas.fg_color = color_parse(&normal_fg_color).unwrap_or(FALLBACK_COLOR);
for i in 0..num_devices { for i in 0..num_devices {
let label = canvas.label( let label = canvas.label_centered(
button_x + 2., button_x + 2.,
button_y + 2., button_y + 2.,
button_w - 4., button_w - 4.,
@@ -322,7 +322,7 @@ fn battery_update(control: &mut Control<(), ElemState>, _: &mut (), app: &mut Ap
let text = match device { let text = match device {
Some(d) => d Some(d) => d
.soc .soc
.map(|soc| format!("{}{}", tags[d.role as usize], soc as u32)) .map(|soc| format!("{}{}", tags[d.role as usize], (soc * 100.) as u32))
.unwrap_or_else(|| "".into()), .unwrap_or_else(|| "".into()),
None => "".into(), None => "".into(),
}; };

View File

@@ -96,17 +96,18 @@ watch_elements:
text: "Chicago" # change TZ2 label here text: "Chicago" # change TZ2 label here
- type: Batteries - type: Batteries
rect: [0, 20, 400, 40] rect: [0, 0, 400, 40]
font_size: 14 font_size: 14
num_devices: 9 num_devices: 9
low_threshold: 15 low_threshold: 15
normal_fg_color: "#406040" layout: Horizontal
normal_fg_color: "#99BBAA"
# below is not yet implemented
normal_bg_color: "#353535" normal_bg_color: "#353535"
low_fg_color: "#604040" low_fg_color: "#604040"
low_bg_color: "#353535" low_bg_color: "#353535"
charging_fg_color: "#204070" charging_fg_color: "#204070"
charging_bg_color: "#353535" charging_bg_color: "#353535"
layout: Horizontal
# sample # sample
# - type: ExecLabel # - type: ExecLabel