Skip to content

Commit 329d5cb

Browse files
committed
Update example(crashing)
1 parent d9f14e9 commit 329d5cb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

examples/mcpwm-simple.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,19 @@ fn main() -> anyhow::Result<()> {
7878

7979
println!("Starting duty-cycle loop");
8080

81-
for &x in [0.0, 20.0, 40.0, 60.0, 80.0, 100.0].iter().cycle() {
82-
println!("Duty {}%", x);
83-
operator.set_duty_a(x)?;
84-
operator.set_duty_b(100.0 - x)?;
85-
FreeRtos.delay_ms(2000)?;
86-
}
81+
for x in (0..10000u16).cycle() {
82+
let duty = f32::from(x) * 0.01;
83+
84+
if x % 100 == 0 {
85+
println!("Duty {}%", duty);
86+
}
8787

88-
loop {
89-
FreeRtos.delay_ms(1000)?;
88+
operator.set_duty_a(duty)?;
89+
operator.set_duty_b(100.0 - duty)?;
90+
FreeRtos.delay_ms(10)?;
9091
}
92+
93+
unreachable!()
9194
}
9295

9396
#[cfg(not(any(esp32, esp32s3)))]

0 commit comments

Comments
 (0)