66 holding buffers for the duration of a data transfer."
77) ]
88
9- extern crate alloc;
10- mod led_driver;
119mod display_task;
10+ mod led_driver;
1211
12+ use crate :: display_task:: DisplayState :: * ;
13+ use crate :: display_task:: { DisplayControlChannel , display_task} ;
1314use crate :: led_driver:: LedDriver ;
1415use bt_hci:: controller:: ExternalController ;
1516use embassy_executor:: Spawner ;
@@ -18,14 +19,13 @@ use embassy_time::{Duration, Timer};
1819use esp_hal:: clock:: CpuClock ;
1920use esp_hal:: timer:: systimer:: SystemTimer ;
2021use esp_hal:: timer:: timg:: TimerGroup ;
22+ use esp_hal:: { interrupt, peripherals} ;
2123use esp_wifi:: ble:: controller:: BleConnector ;
2224use log:: info;
2325#[ cfg( feature = "log-rtt" ) ]
2426use rtt_target:: rtt_init_log;
2527use smart_leds:: RGB8 ;
2628use static_cell:: StaticCell ;
27- use crate :: display_task:: { display_task, DisplayControlChannel } ;
28- use crate :: display_task:: DisplayState :: * ;
2929
3030/// Communicate with the display task using this channel and the DisplayState enum
3131static DISPLAY_CHANNEL : StaticCell < DisplayControlChannel > = StaticCell :: new ( ) ;
@@ -62,34 +62,43 @@ async fn main(spawner: Spawner) {
6262 let timer0 = SystemTimer :: new ( peripherals. SYSTIMER ) ;
6363 esp_hal_embassy:: init ( timer0. alarm0 ) ;
6464
65+ info ! ( "MAIN: Enabling RMT ISR" ) ;
66+ interrupt:: enable ( peripherals:: Interrupt :: RMT , interrupt:: Priority :: Priority1 ) . unwrap ( ) ;
67+
6568 info ! ( "MAIN: Embassy initialized!" ) ;
6669
6770 let rng = esp_hal:: rng:: Rng :: new ( peripherals. RNG ) ;
6871 let timer1 = TimerGroup :: new ( peripherals. TIMG0 ) ;
6972 let wifi_init = esp_wifi:: init ( timer1. timer0 , rng, peripherals. RADIO_CLK )
7073 . expect ( "MAIN: Failed to initialize WIFI/BLE controller" ) ;
71-
74+
7275 // find more examples https://github.com/embassy-rs/trouble/tree/main/examples/esp32
7376 let transport = BleConnector :: new ( & wifi_init, peripherals. BT ) ;
7477 let _ble_controller = ExternalController :: < _ , 20 > :: new ( transport) ;
7578
7679 info ! ( "MAIN: Setting up LED driver controller" ) ;
7780 let display_channel = DISPLAY_CHANNEL . init ( Channel :: new ( ) ) ;
78- let led_driver: & ' static mut LedDriver = LED_DRIVER . init ( LedDriver :: new ( peripherals. RMT , peripherals. GPIO6 ) ) ;
79- spawner. spawn ( display_task ( display_channel, led_driver) ) . expect ( "Failed to spawn display task" ) ;
80-
81+ let led_driver: & ' static mut LedDriver =
82+ LED_DRIVER . init ( LedDriver :: new ( peripherals. RMT , peripherals. GPIO6 ) ) ;
83+
84+ spawner
85+ . spawn ( display_task ( display_channel, led_driver) )
86+ . expect ( "Failed to spawn display task" ) ;
87+ Timer :: after ( Duration :: from_secs ( 1 ) ) . await ;
88+
8189 // Simple example that exercises the display task
8290 loop {
83- display_channel . send ( Off ) . await ;
84- display_channel. send ( Colour ( RGB8 :: new ( 0 , 10 , 10 ) ) ) . await ;
91+ info ! ( "MAIN: Loop cycling" ) ;
92+ display_channel. send ( Colour ( RGB8 :: new ( 0 , 10 , 0 ) ) ) . await ;
8593 display_channel. send ( Start ) . await ;
94+ info ! ( "MAIN: Sent start message" ) ;
8695
8796 Timer :: after ( Duration :: from_secs ( 10 ) ) . await ;
8897 display_channel. send ( Stop ) . await ;
8998
9099 Timer :: after ( Duration :: from_secs ( 1 ) ) . await ;
91100 display_channel. send ( Start ) . await ;
92-
101+
93102 Timer :: after ( Duration :: from_secs ( 1 ) ) . await ;
94103 display_channel. send ( Torch ( 10 ) ) . await ;
95104
@@ -98,6 +107,4 @@ async fn main(spawner: Spawner) {
98107
99108 Timer :: after ( Duration :: from_secs ( 1 ) ) . await ;
100109 }
101-
102- // for inspiration, have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0-beta.1/examples/src/bin
103110}
0 commit comments