feat: ipd label

This commit is contained in:
galister
2024-03-28 11:51:10 +01:00
parent 1438d3e7eb
commit 810c0cac63
5 changed files with 39 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ pub enum LabelContent {
low_color: Arc<str>,
charging_color: Arc<str>,
},
Ipd,
}
pub enum LabelData {
@@ -62,6 +63,9 @@ pub enum LabelData {
command: Vec<Arc<str>>,
child: Option<process::Child>,
},
Ipd {
last_ipd: f32,
},
}
pub fn modular_label_init(label: &mut ModularControl, content: &LabelContent) {
@@ -106,6 +110,7 @@ pub fn modular_label_init(label: &mut ModularControl, content: &LabelContent) {
label.set_text(text);
None
}
LabelContent::Ipd => Some(LabelData::Ipd { last_ipd: 0. }),
};
if let Some(state) = state {
@@ -238,5 +243,11 @@ pub(super) fn label_update(control: &mut ModularControl, _: &mut (), app: &mut A
};
}
}
LabelData::Ipd { last_ipd } => {
if (app.input_state.ipd - *last_ipd).abs() > 0.05 {
*last_ipd = app.input_state.ipd;
control.set_text(&format!("{:.1}", app.input_state.ipd));
}
}
}
}