This commit is contained in:
rafael 2024-10-20 23:31:53 +02:00
parent 7fc09f89e8
commit 8baf88f8f4

View File

@ -5,19 +5,19 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use assign_resources::assign_resources;
use defmt::*; use defmt::*;
use embassy_executor::Spawner; use embassy_executor::Spawner;
use embassy_rp::block::ImageDef; use embassy_rp::block::ImageDef;
use embassy_rp::config::Config; use embassy_rp::config::Config;
use embassy_rp::gpio;
use embassy_rp::gpio::Output; use embassy_rp::gpio::Output;
use embassy_rp::peripherals; use embassy_rp::peripherals;
use embassy_rp::gpio;
use embassy_rp::pwm; use embassy_rp::pwm;
use embassy_time::Duration; use embassy_time::Duration;
use embassy_time::Timer; use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
use tb6612fng::{DriveCommand, Motor, Tb6612fng}; use tb6612fng::{DriveCommand, Motor, Tb6612fng};
use assign_resources::assign_resources; use {defmt_rtt as _, panic_probe as _};
/// Maximum PWM value (fully on) /// Maximum PWM value (fully on)
const PWM_MAX: u16 = 50000; const PWM_MAX: u16 = 50000;
@ -100,15 +100,14 @@ async fn main(_spawner: Spawner) {
Timer::after(Duration::from_secs(1)).await; Timer::after(Duration::from_secs(1)).await;
// slowly turn for 3s // slowly turn for 3s
info!( "turn"); info!("turn");
control.motor_a.drive(DriveCommand::Backward(10)).unwrap(); control.motor_a.drive(DriveCommand::Backward(10)).unwrap();
control.motor_b.drive(DriveCommand::Forward(10)).unwrap(); control.motor_b.drive(DriveCommand::Forward(10)).unwrap();
Timer::after(Duration::from_secs(3)).await; Timer::after(Duration::from_secs(3)).await;
// and put the driver in standby mode and wait for 5s // and put the driver in standby mode and wait for 5s
info!( "standby"); info!("standby");
control.enable_standby().unwrap(); control.enable_standby().unwrap();
Timer::after(Duration::from_secs(5)).await; Timer::after(Duration::from_secs(5)).await;
} }
} }