*: cargo fmt
This commit is contained in:
parent
9948a76602
commit
fe8942575a
7 changed files with 156 additions and 151 deletions
|
|
@ -41,11 +41,11 @@ impl BitTicks {
|
|||
Self {
|
||||
t0_h,
|
||||
t1_h,
|
||||
t0_l:t1_h,
|
||||
t1_l:t0_h,
|
||||
t0_l: t1_h,
|
||||
t1_l: t0_h,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn from_clk(
|
||||
clk_speed: u32,
|
||||
clk_divider: u8,
|
||||
|
|
@ -57,11 +57,10 @@ impl BitTicks {
|
|||
let bit_ticks = (bit_period_us / tick_len).round() as u16;
|
||||
let t1_h = (speed.bit_times().t1_h / tick_len).round() as u16;
|
||||
let t0_h = (speed.bit_times().t0_h / tick_len).round() as u16;
|
||||
let mut bittick = Self::new(t1_h, t0_h);
|
||||
bittick.t0_l = bit_ticks -t0_h;
|
||||
let mut bittick = Self::new(t1_h, t0_h);
|
||||
bittick.t0_l = bit_ticks - t0_h;
|
||||
bittick.t1_l = bit_ticks - t1_h;
|
||||
bittick
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +139,14 @@ impl<'a> DShot<'a> {
|
|||
) -> Self {
|
||||
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);
|
||||
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,
|
||||
|
|
@ -171,7 +176,7 @@ impl<'a> DShot<'a> {
|
|||
rprintln!("--------------------");
|
||||
for i in 0..16 {
|
||||
let bit = (frame >> (15 - i)) & 1;
|
||||
|
||||
|
||||
pulses[i] = if bit == 1 {
|
||||
rprint!("1");
|
||||
PulseCode::new(
|
||||
|
|
@ -195,7 +200,7 @@ impl<'a> DShot<'a> {
|
|||
rprintln!("");
|
||||
rprintln!("--------------------");
|
||||
|
||||
pulses[16] =0;
|
||||
pulses[16] = 0;
|
||||
pulses
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue