Add parameters to end screen
This commit is contained in:
parent
adf731dd29
commit
ab775e32de
@ -88,21 +88,50 @@ pub fn draw_driving(screen: &mut Screen, font: &Font) {
|
||||
}
|
||||
|
||||
#[allow(clippy::similar_names)]
|
||||
pub fn draw_finished(screen: &mut Screen, time: Duration, font: &Font) {
|
||||
pub fn draw_finished(
|
||||
screen: &mut Screen,
|
||||
time: Duration,
|
||||
(k_p, k_i, k_d): (f32, f32, f32),
|
||||
v: i32,
|
||||
font: &Font,
|
||||
) {
|
||||
clear(screen);
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
let text_scale = Scale::uniform(screen.yres() as f32 / 2.0 - 8.0);
|
||||
let text_scale = Scale::uniform(screen.yres() as f32 / 4.0 - 8.0);
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
let time_scale = Scale::uniform(screen.yres() as f32 / 2.0 - 8.0);
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
let value_scale = Scale {
|
||||
x: screen.xres() as f32 / 10.0,
|
||||
y: screen.yres() as f32 / 4.0 - 8.0,
|
||||
};
|
||||
let xres = i32::try_from(screen.xres()).expect("range checked");
|
||||
let yres = i32::try_from(screen.yres()).expect("range checked");
|
||||
draw_centered_text(screen, xres / 2, 4, text_scale, font, "Zeit:");
|
||||
draw_centered_text(
|
||||
screen,
|
||||
xres / 2,
|
||||
yres / 2 + 4,
|
||||
text_scale,
|
||||
yres / 4 + 4,
|
||||
time_scale,
|
||||
font,
|
||||
format!("{:.2}s", time.as_secs_f32()).as_str(),
|
||||
);
|
||||
macro_rules! draw_param {
|
||||
($param: ident, $index: literal) => {
|
||||
draw_centered_text(
|
||||
screen,
|
||||
xres * (1 + 2 * $index) / 8,
|
||||
yres * 3 / 4 + 4,
|
||||
value_scale,
|
||||
font,
|
||||
format!("{:.2}", $param).as_str(),
|
||||
);
|
||||
};
|
||||
}
|
||||
draw_param!(k_p, 0);
|
||||
draw_param!(k_i, 1);
|
||||
draw_param!(k_d, 2);
|
||||
draw_param!(v, 3);
|
||||
screen.update();
|
||||
}
|
||||
|
||||
@ -115,7 +144,7 @@ fn draw_setting(
|
||||
screen: &mut Screen,
|
||||
value: impl Display,
|
||||
selected: bool,
|
||||
index: u8,
|
||||
index: i32,
|
||||
name: &str,
|
||||
font: &Font,
|
||||
) {
|
||||
@ -128,7 +157,7 @@ fn draw_setting(
|
||||
};
|
||||
let xres = i32::try_from(screen.xres()).expect("range checked");
|
||||
let yres = i32::try_from(screen.yres()).expect("range checked");
|
||||
let x = xres / 8 + xres * i32::from(index) / 4;
|
||||
let x = xres * (1 + 2 * index) / 8;
|
||||
draw_centered_text(screen, x, yres / 4 + 4, text_scale, font, name);
|
||||
draw_centered_text(
|
||||
screen,
|
||||
|
@ -52,7 +52,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
e => e?,
|
||||
};
|
||||
|
||||
draw_finished(&mut screen, time, &font);
|
||||
draw_finished(&mut screen, time, (k_p, k_i, k_d), v, &font);
|
||||
buttons.process();
|
||||
while !buttons.is_enter_pressed() {
|
||||
buttons.process();
|
||||
|
Loading…
Reference in New Issue
Block a user