dshot debugging
This commit is contained in:
parent
3e5a905544
commit
9948a76602
3 changed files with 26 additions and 16 deletions
|
|
@ -5,6 +5,7 @@ use esp_hal::{
|
|||
rmt::{Channel, PulseCode, Rx, Tx, TxChannelCreator},
|
||||
};
|
||||
use num_traits::float::FloatCore;
|
||||
use rtt_target::{rprint, rprintln};
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[allow(non_camel_case_types)]
|
||||
|
|
@ -140,6 +141,7 @@ impl<'a> DShot<'a> {
|
|||
let clk_speed = clk_speed.unwrap_or(80_000_000);
|
||||
let clk_divider = clk_divider.unwrap_or(1);
|
||||
let bit_ticks = BitTicks::from_clk(clk_speed, clk_divider, speed.bit_times(),speed);
|
||||
rprint!("bit_ticks.t1_h:{},t1_l:{},t0_h:{},t0_l{}",bit_ticks.t1_h,bit_ticks.t1_l,bit_ticks.t0_h,bit_ticks.t0_l);
|
||||
Self {
|
||||
rx_channel: rx_channel,
|
||||
tx_channel: tx_channel,
|
||||
|
|
@ -165,10 +167,13 @@ impl<'a> DShot<'a> {
|
|||
pub fn create_pulses(&mut self, throttle_value: u16, telemetry: bool) -> [u32; 17] {
|
||||
let frame = Self::create_frame(throttle_value, telemetry);
|
||||
let mut pulses = [0; 17];
|
||||
rprintln!("CREATING NEW FRAME!");
|
||||
rprintln!("--------------------");
|
||||
for i in 0..16 {
|
||||
let bit = (frame >> (15 - i)) & 1;
|
||||
|
||||
|
||||
pulses[i] = if bit == 1 {
|
||||
rprint!("1");
|
||||
PulseCode::new(
|
||||
Level::High,
|
||||
self.bit_ticks.t1_h,
|
||||
|
|
@ -177,6 +182,7 @@ impl<'a> DShot<'a> {
|
|||
)
|
||||
.into()
|
||||
} else {
|
||||
rprint!("0");
|
||||
PulseCode::new(
|
||||
Level::High,
|
||||
self.bit_ticks.t0_h,
|
||||
|
|
@ -186,14 +192,10 @@ impl<'a> DShot<'a> {
|
|||
.into()
|
||||
};
|
||||
}
|
||||
rprintln!("");
|
||||
rprintln!("--------------------");
|
||||
|
||||
pulses[16] = PulseCode::new(
|
||||
Level::Low,
|
||||
self.bit_ticks.t1_h * 2,
|
||||
Level::Low,
|
||||
0,
|
||||
)
|
||||
.into();
|
||||
pulses[16] =0;
|
||||
pulses
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue