Skip to content

Commit

Permalink
challenge complete
Browse files Browse the repository at this point in the history
  • Loading branch information
HenoHyj committed Oct 17, 2024
1 parent 05264c5 commit 1ca4a7b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions firmware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use esp_hal::{
clock::Clocks, gpio::{Io, Level, Output}, mcpwm::PeripheralClockConfig, timer::timg::TimerGroup
};
use esp_println::println;
use esp_wifi::current_millis;
use fugit::RateExtU32;
use esp_hal::mcpwm::McPwm;
use esp_hal::mcpwm::timer::PwmWorkingMode;
Expand Down Expand Up @@ -43,13 +44,29 @@ async fn main(_spawner: Spawner) {
PwmPinConfig::UP_ACTIVE_HIGH,
);

motor_hi.set_timestamp(180);
let cur_motor_value = 255;
motor_hi.set_timestamp(cur_motor_value);
motor_lo.set_timestamp(0);

loop {
println!("Hello, World!");
led.toggle();
Timer::after_millis(1_000).await;
// println!("Hello, World!");
// led.toggle();
// Timer::after_millis(1_000).await;

for cur_motor_value in (0..=255).rev() {
motor_hi.set_timestamp(cur_motor_value);
motor_lo.set_timestamp(0);
Timer::after_millis(10).await;
}

Timer::after_millis(100).await;

for cur_motor_value in (0..=255).rev() {
motor_hi.set_timestamp(0);
motor_lo.set_timestamp(cur_motor_value);
Timer::after_millis(10).await;
}

Timer::after_millis(100).await;
}
}

0 comments on commit 1ca4a7b

Please sign in to comment.