diff --git a/spinnyboy_rust/src/bin/main.rs b/spinnyboy_rust/src/bin/main.rs index 834c2da..8219eef 100644 --- a/spinnyboy_rust/src/bin/main.rs +++ b/spinnyboy_rust/src/bin/main.rs @@ -43,12 +43,16 @@ use crate::dc_driver::dshot; use crate::peripherals::ErrCommand; use esp_hal::rmt::RxChannelConfig; use esp_hal::rmt::RxChannelCreator; + +use esp_hal::timer::timg::TimerGroup; +use esp_hal::timer::OneShotTimer; +use esp_hal::timer::Timer; #[panic_handler] fn panic(panic: &core::panic::PanicInfo) -> ! { rprintln!("{}",panic.message()); let trace = Backtrace::capture(); loop { - // rprintln!("{}",panic.location().unwrap()) + rprintln!("{}",panic.location().unwrap()) } } use alloc::format; @@ -138,8 +142,13 @@ fn main() -> ! { dshot_esc.arm(); let mut rpm = 0; let mut control: f32 = 200.0; - // let timestamp = Instant::now(); - loop { + let mut timg0 = TimerGroup::new(peripherals.TIMG0); + let timer0 = timg0.timer0; + // let now =timer.now(); + //we need the explicit type here! + timer0.load_value(esp_hal::time::Duration::from_secs(10)); + timer0.start(); + while !timer0.is_interrupt_set() { dshot_esc.process(); //let control_val = dc_driver:: //this bad boy needs floats, this will be fun :) @@ -150,7 +159,7 @@ fn main() -> ! { x } None => { - rprintln!("NO RPM!"); + // rprintln!("NO RPM!"); rpm } }; @@ -160,9 +169,10 @@ fn main() -> ! { let timestamp = esp_hal::time::Instant::now().duration_since_epoch().as_millis(); (control, ctx) = controller.compute(ctx, rpm as _, set_point as _, Millis(timestamp), None); let dumped_context = ctx.last_time().expect("LAST TIME!"); - rprintln!("control:{},rpm:{}", control,rpm); + // rprintln!("control:{},rpm:{}", control,rpm); } - + rprintln!("Coating done!"); + dshot_esc.set_throttle(0); // rprintln!("RMT SENT!"); // let mut esc = AfroEsc::new(&mut pwm_pin);; // esc.set_timestamp(1000);