This commit is contained in:
Max Känner 2023-01-29 15:04:46 +01:00
parent 63534c7e05
commit a5dc6f15af

View File

@ -37,32 +37,31 @@ fn main() -> Result<(), Box<dyn Error>> {
let white = calibrate_gray(&mut screen, &sensor, &mut buttons, "Weiß", &font)?; let white = calibrate_gray(&mut screen, &sensor, &mut buttons, "Weiß", &font)?;
let setpoint = (black + white) / 2.0; let setpoint = (black + white) / 2.0;
loop {
let (k_p, k_i, k_d, v) = select_values(&mut screen, &mut buttons, &font); let (k_p, k_i, k_d, v) = select_values(&mut screen, &mut buttons, &font);
draw_driving(&mut screen, &font); draw_driving(&mut screen, &font);
let result = follow_line( let result = follow_line(
(&left_motor, &right_motor), (&left_motor, &right_motor),
&sensor, &sensor,
&mut buttons, &mut buttons,
setpoint, setpoint,
(k_p / 10.0, k_i, k_d), (k_p / 10.0, k_i / 100.0, k_d / 100.0),
v, v,
); );
left_motor.stop().and(right_motor.stop())?; left_motor.stop().and(right_motor.stop())?;
let time = match result { let time = match result {
Ok(time) => time, Ok(time) => time,
Err(ProgramError::UserAbort) => return Ok(()), Err(ProgramError::UserAbort) => continue,
e => e?, e => e?,
}; };
buttons.process();
draw_finished(&mut screen, time, &font); draw_finished(&mut screen, time, &font);
buttons.process();
while !buttons.is_enter_pressed() { while !buttons.is_enter_pressed() {
buttons.process(); buttons.process();
} }
}
Ok(())
} }
fn select_values( fn select_values(