diff options
| author | Jacob Rosenthal <[email protected]> | 2021-11-10 12:48:15 -0700 |
|---|---|---|
| committer | Jacob Rosenthal <[email protected]> | 2021-11-10 12:48:15 -0700 |
| commit | 751617c2be10c047ccf6986ace489999b80a01b0 (patch) | |
| tree | 27de1031a841b96f357acb171ef620eb5a1f67fc /examples | |
| parent | 903b8f032fa36fb1bf8cd6f1d1b3c14ce7caa0dd (diff) | |
fix examples for mut self set_duty
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/src/bin/pwm.rs | 2 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_led.rs | 2 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_servo.rs | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index 0cb91cf1e..8679eddd8 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs | |||
| @@ -85,7 +85,7 @@ static DUTY: [u16; 1024] = [ | |||
| 85 | 85 | ||
| 86 | #[embassy::main] | 86 | #[embassy::main] |
| 87 | async fn main(_spawner: Spawner, p: Peripherals) { | 87 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 88 | let pwm = SimplePwm::new(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); | 88 | let mut pwm = SimplePwm::new(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); |
| 89 | pwm.set_prescaler(Prescaler::Div1); | 89 | pwm.set_prescaler(Prescaler::Div1); |
| 90 | pwm.set_max_duty(32767); | 90 | pwm.set_max_duty(32767); |
| 91 | info!("pwm initialized!"); | 91 | info!("pwm initialized!"); |
diff --git a/examples/nrf/src/bin/pwm_led.rs b/examples/nrf/src/bin/pwm_led.rs index ced6a7136..d0b71a5cd 100644 --- a/examples/nrf/src/bin/pwm_led.rs +++ b/examples/nrf/src/bin/pwm_led.rs | |||
| @@ -13,7 +13,7 @@ use embassy_nrf::Peripherals; | |||
| 13 | 13 | ||
| 14 | #[embassy::main] | 14 | #[embassy::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 16 | let pwm = SimplePwm::new(p.PWM0, p.P0_13, NoPin, NoPin, NoPin); | 16 | let mut pwm = SimplePwm::new(p.PWM0, p.P0_13, NoPin, NoPin, NoPin); |
| 17 | // set_period doesnt actually set what you give it, because it only has a | 17 | // set_period doesnt actually set what you give it, because it only has a |
| 18 | // few options from the hardhware so be explicit instead | 18 | // few options from the hardhware so be explicit instead |
| 19 | // Div128 is slowest, 125khz still crazy fast for our eyes | 19 | // Div128 is slowest, 125khz still crazy fast for our eyes |
diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index d681a2015..700b88574 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs | |||
| @@ -13,7 +13,7 @@ use embassy_nrf::Peripherals; | |||
| 13 | 13 | ||
| 14 | #[embassy::main] | 14 | #[embassy::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 16 | let pwm = SimplePwm::new(p.PWM0, p.P0_05, NoPin, NoPin, NoPin); | 16 | let mut pwm = SimplePwm::new(p.PWM0, p.P0_05, NoPin, NoPin, NoPin); |
| 17 | // sg90 microervo requires 50hz or 20ms period | 17 | // sg90 microervo requires 50hz or 20ms period |
| 18 | // set_period can only set down to 125khz so we cant use it directly | 18 | // set_period can only set down to 125khz so we cant use it directly |
| 19 | // Div128 is 125khz or 0.000008s or 0.008ms, 20/0.008 is 2500 is top | 19 | // Div128 is 125khz or 0.000008s or 0.008ms, 20/0.008 is 2500 is top |
