Start pedal history
This commit is contained in:
parent
e6ae0e7bee
commit
364b1e5686
2 changed files with 21 additions and 18 deletions
|
@ -14,8 +14,10 @@ pub struct Pedals {
|
||||||
|
|
||||||
brake: Arc<ProgressBar>,
|
brake: Arc<ProgressBar>,
|
||||||
throttle: Arc<ProgressBar>,
|
throttle: Arc<ProgressBar>,
|
||||||
fuel: Arc<Label>,
|
history: Arc<Icon>,
|
||||||
gear: Arc<Label>,
|
|
||||||
|
throttle_samples: Vec<f32>,
|
||||||
|
brake_samples: Vec<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pedals {
|
impl Pedals {
|
||||||
|
@ -26,15 +28,17 @@ impl Pedals {
|
||||||
|
|
||||||
let brake = gui.element("brake")?;
|
let brake = gui.element("brake")?;
|
||||||
let throttle = gui.element("throttle")?;
|
let throttle = gui.element("throttle")?;
|
||||||
let fuel = gui.element("fuel")?;
|
let history = gui.element("history")?;
|
||||||
let gear = gui.element("gear")?;
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
gui,
|
gui,
|
||||||
|
|
||||||
brake,
|
brake,
|
||||||
throttle,
|
throttle,
|
||||||
fuel,
|
history,
|
||||||
gear,
|
|
||||||
|
throttle_samples: Vec::new(),
|
||||||
|
brake_samples: Vec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,13 +64,14 @@ impl DataReceiver for Pedals {
|
||||||
self.gui.enable()?;
|
self.gui.enable()?;
|
||||||
|
|
||||||
if let Some(telemetry) = telemetries.iter().find(|telemetry| telemetry.id == id) {
|
if let Some(telemetry) = telemetries.iter().find(|telemetry| telemetry.id == id) {
|
||||||
self.brake
|
let brake = 1.0 - telemetry.unfiltered_brake as f32;
|
||||||
.set_progress(1.0 - telemetry.unfiltered_brake as f32)?;
|
let throttle = 1.0 - telemetry.unfiltered_throttle as f32;
|
||||||
self.throttle
|
|
||||||
.set_progress(1.0 - telemetry.unfiltered_throttle as f32)?;
|
self.throttle.set_progress(throttle)?;
|
||||||
self.gear.set_text(telemetry.gear)?;
|
self.brake.set_progress(brake)?;
|
||||||
let fuel = telemetry.fuel;
|
|
||||||
self.fuel.set_text(format!("{:.2}", fuel))?;
|
self.throttle_samples.push(throttle);
|
||||||
|
self.brake_samples.push(brake);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -7,10 +7,8 @@
|
||||||
<progressbar id="throttle"
|
<progressbar id="throttle"
|
||||||
x_slot="1" y_slot="0" y_size="2" background="#494949" direction="bottom_to_top"
|
x_slot="1" y_slot="0" y_size="2" background="#494949" direction="bottom_to_top"
|
||||||
foreground="#00b900"></progressbar>
|
foreground="#00b900"></progressbar>
|
||||||
<label id="fuel" x_slot="2"
|
|
||||||
x_size="5" y_slot="0"
|
<icon id="history" x_slot="2" x_size="5" y_slot="0"
|
||||||
text_color="black"></label>
|
y_size="2"></icon>
|
||||||
<label id="gear" x_slot="2" x_size="5" y_slot="1"
|
|
||||||
text_color="black"></label>
|
|
||||||
</grid>
|
</grid>
|
||||||
</root>
|
</root>
|
Loading…
Reference in a new issue