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