diff options
| author | huntc <[email protected]> | 2022-02-04 16:39:14 +1100 |
|---|---|---|
| committer | huntc <[email protected]> | 2022-02-04 16:39:14 +1100 |
| commit | e9e4d058d1fbb1eefa0b2d58b0a76075e0a32487 (patch) | |
| tree | f60a4e54e37327c959e8dd2c4a015834d8cb094c /examples/nrf/src | |
| parent | 81f98c32aaec61171678ba6cbdd9c82860a1802f (diff) | |
Revert the use of forever
Diffstat (limited to 'examples/nrf/src')
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence_ws2812b.rs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index 7706f91da..310842d8d 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs | |||
| @@ -7,12 +7,11 @@ mod example_common; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy::util::Forever; | ||
| 11 | use embassy_nrf::gpio::NoPin; | 10 | use embassy_nrf::gpio::NoPin; |
| 12 | use embassy_nrf::pwm::{ | 11 | use embassy_nrf::pwm::{ |
| 13 | Config, Prescaler, Sequence, SequenceConfig, SequenceLoad, SequenceMode, SequencePwm, Sequences, | 12 | Config, Prescaler, Sequence, SequenceConfig, SequenceLoad, SequenceMode, SequencePwm, Sequences, |
| 14 | }; | 13 | }; |
| 15 | use embassy_nrf::{peripherals, Peripherals}; | 14 | use embassy_nrf::Peripherals; |
| 16 | 15 | ||
| 17 | // WS2812B LED light demonstration. Drives just one light. | 16 | // WS2812B LED light demonstration. Drives just one light. |
| 18 | // The following reference on WS2812B may be of use: | 17 | // The following reference on WS2812B may be of use: |
| @@ -27,8 +26,6 @@ const T1H: u16 = 0x8000 | 13; // Duty = 13/20 ticks (0.8us/1.25us) for a 1 | |||
| 27 | const T0H: u16 = 0x8000 | 7; // Duty 7/20 ticks (0.4us/1.25us) for a 0 | 26 | const T0H: u16 = 0x8000 | 7; // Duty 7/20 ticks (0.4us/1.25us) for a 0 |
| 28 | const RES: u16 = 0x8000; | 27 | const RES: u16 = 0x8000; |
| 29 | 28 | ||
| 30 | static PWM: Forever<SequencePwm<peripherals::PWM0>> = Forever::new(); | ||
| 31 | |||
| 32 | // Provides data to a WS2812b (Neopixel) LED and makes it go blue. The data | 29 | // Provides data to a WS2812b (Neopixel) LED and makes it go blue. The data |
| 33 | // line is assumed to be P1_05. | 30 | // line is assumed to be P1_05. |
| 34 | #[embassy::main] | 31 | #[embassy::main] |
| @@ -37,12 +34,10 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 37 | config.sequence_load = SequenceLoad::Common; | 34 | config.sequence_load = SequenceLoad::Common; |
| 38 | config.prescaler = Prescaler::Div1; | 35 | config.prescaler = Prescaler::Div1; |
| 39 | config.max_duty = 20; // 1.25us (1s / 16Mhz * 20) | 36 | config.max_duty = 20; // 1.25us (1s / 16Mhz * 20) |
| 40 | let pwm = unwrap!(SequencePwm::new( | 37 | let mut pwm = unwrap!(SequencePwm::new( |
| 41 | p.PWM0, p.P1_05, NoPin, NoPin, NoPin, config, | 38 | p.PWM0, p.P1_05, NoPin, NoPin, NoPin, config, |
| 42 | )); | 39 | )); |
| 43 | 40 | ||
| 44 | let mut pwm = PWM.put(pwm); | ||
| 45 | |||
| 46 | // Declare the bits of 24 bits in a buffer we'll be | 41 | // Declare the bits of 24 bits in a buffer we'll be |
| 47 | // mutating later. | 42 | // mutating later. |
| 48 | let mut seq_words = [ | 43 | let mut seq_words = [ |
