Skip to content

Commit

Permalink
added some test actions
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkamprath committed Sep 30, 2024
1 parent cedc10a commit fc1c26f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
30 changes: 29 additions & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ impl<
// - button one will select the current function and execute it
// - if no button is pressed for the idle wait time, return to idle state

const FUNCTIONS: [&str; 4] = [
const FUNCTIONS: [&str; 6] = [
"Select Path",
"Calibrate Gyro",
"Heading Display",
"Drive Straight",
"Turn Left",
"Turn Right",
];
let mut function_idx: usize = 0;
let mut last_interaction_millis = millis();
Expand Down Expand Up @@ -278,9 +280,35 @@ impl<
self.robot.set_display_to_idle();
}
3 => {
write!(
self.robot.clear_lcd().set_lcd_cursor(0, 0),
"Driving straight",
)
.ok();
self.delay.delay_ms(500);
self.robot.straight(1500, true);
self.robot.start_display_reset_timer();
}
4 => {
write!(
self.robot.clear_lcd().set_lcd_cursor(0, 0),
"Turning left \x7F",
)
.ok();
self.delay.delay_ms(500);
self.robot.turn(90);
self.robot.start_display_reset_timer();
}
5 => {
write!(
self.robot.clear_lcd().set_lcd_cursor(0, 0),
"Turning right \x7E",
)
.ok();
self.delay.delay_ms(500);
self.robot.turn(-90);
self.robot.start_display_reset_timer();
}
_ => {
warn!("handle_functions_menu: invalid function index");
}
Expand Down
16 changes: 0 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,6 @@ fn main() -> ! {

// set up SPI
#[allow(clippy::type_complexity)]
// let spi: rp_pico::hal::Spi<
// rp_pico::hal::spi::Disabled,
// SPI0,
// (
// rp_pico::hal::gpio::Pin<Gpio3, FunctionSpi, PullDown>,
// rp_pico::hal::gpio::Pin<Gpio0, FunctionSpi, PullDown>,
// rp_pico::hal::gpio::Pin<Gpio2, FunctionSpi, PullDown>,
// ),
// > = bsp::hal::Spi::new(
// pac.SPI0,
// (
// pins.gpio3.into_function::<gpio::FunctionSpi>(),
// pins.gpio0.into_function::<gpio::FunctionSpi>(),
// pins.gpio2.into_function::<gpio::FunctionSpi>(),
// ),
// );
let spi_mosi = pins.gpio3.into_function::<bsp::hal::gpio::FunctionSpi>();
let spi_miso = pins.gpio0.into_function::<bsp::hal::gpio::FunctionSpi>();
let spi_sclk = pins.gpio2.into_function::<bsp::hal::gpio::FunctionSpi>();
Expand Down
1 change: 1 addition & 0 deletions src/robot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ where
1.0
}

/// Turns the robot by a specified angle in degrees. Positive angle is a left turn, negative angle is a right turn
pub fn turn(&mut self, angle_degrees: i32) -> &mut Self {
const TURN_MIN_POWER: f32 = 0.50;
if angle_degrees.abs() < self.min_turn_angle() as i32 {
Expand Down

0 comments on commit fc1c26f

Please sign in to comment.