adds arming sequence for the AfroESC
This commit is contained in:
parent
07e6e6ec4b
commit
266f09c4b1
1 changed files with 11 additions and 2 deletions
|
|
@ -6,11 +6,12 @@ use esp_hal::mcpwm::operator::PwmPin;
|
|||
use esp_hal::mcpwm::operator::Operator;
|
||||
use esp_hal::mcpwm::McPwm;
|
||||
use esp_hal::peripherals::MCPWM0;
|
||||
|
||||
use esp_hal::delay::Delay;
|
||||
pub struct AfroEsc<'a>{
|
||||
pub pwm_pin: &'a mut PwmPin<'a, esp_hal::peripherals::MCPWM0<'a>, 0,true>
|
||||
|
||||
}
|
||||
const ARMING_SEQUENCE:u16 = 1055;
|
||||
const MIN_THROTTLE:u16 = 1121;
|
||||
const MAX_THROTTLE:u16 = 1421;
|
||||
const GAP:u16 = (MAX_THROTTLE - MIN_THROTTLE)/100;
|
||||
|
|
@ -18,7 +19,11 @@ const GAP:u16 = (MAX_THROTTLE - MIN_THROTTLE)/100;
|
|||
impl AfroEsc<'_>{
|
||||
//this is a little hacky tbh
|
||||
pub fn new<'a>(pwm_pin:&'a mut PwmPin<'a, esp_hal::peripherals::MCPWM0<'a>, 0,true>)-> AfroEsc<'a> {
|
||||
AfroEsc{pwm_pin:pwm_pin}
|
||||
let mut esc = AfroEsc{pwm_pin:pwm_pin};
|
||||
let delay = Delay::new();
|
||||
esc.set_arming_sequence();
|
||||
delay.delay_millis(3000);
|
||||
esc
|
||||
}
|
||||
pub fn set_timestamp(&mut self,value:u16){
|
||||
&self.pwm_pin.set_timestamp(value);
|
||||
|
|
@ -32,4 +37,8 @@ impl AfroEsc<'_>{
|
|||
let new_timestamp = MIN_THROTTLE+value*GAP;
|
||||
&self.pwm_pin.set_timestamp(new_timestamp);
|
||||
}
|
||||
pub fn set_arming_sequence(&mut self){
|
||||
&self.set_timestamp(1055);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue