@@ -23,9 +23,6 @@ use structs::ConnSettings;
2323use utils:: { logger:: FkmLogger , set_brownout_detection} ;
2424use ws_framer:: { WsUrl , WsUrlOwned } ;
2525
26- #[ cfg( feature = "esp32" ) ]
27- use esp_hal:: time:: RateExtU32 ;
28-
2926mod battery;
3027mod buttons;
3128mod consts;
@@ -62,12 +59,12 @@ async fn main(spawner: Spawner) {
6259
6360 #[ cfg( feature = "esp32" ) ]
6461 {
65- config. cpu_clock = esp_hal:: clock:: CpuClock :: _80MHz;
62+ config = config . with_cpu_clock ( esp_hal:: clock:: CpuClock :: _80MHz) ;
6663 }
6764
6865 #[ cfg( feature = "esp32c3" ) ]
6966 {
70- config. cpu_clock = esp_hal:: clock:: CpuClock :: _80MHz;
67+ config = config . with_cpu_clock ( esp_hal:: clock:: CpuClock :: _80MHz) ;
7168 }
7269
7370 config
@@ -79,7 +76,7 @@ async fn main(spawner: Spawner) {
7976
8077 #[ cfg( not( feature = "esp32" ) ) ]
8178 {
82- esp_alloc:: heap_allocator!( 120 * 1024 ) ;
79+ esp_alloc:: heap_allocator!( size : 120 * 1024 ) ;
8380 }
8481
8582 {
@@ -123,11 +120,23 @@ async fn main(spawner: Spawner) {
123120 #[ cfg( feature = "esp32" ) ]
124121 let stackmat_rx = peripherals. GPIO4 . degrade ( ) ;
125122 #[ cfg( feature = "esp32" ) ]
126- let shifter_data_pin = Output :: new ( peripherals. GPIO16 , esp_hal:: gpio:: Level :: Low ) ;
123+ let shifter_data_pin = Output :: new (
124+ peripherals. GPIO16 ,
125+ esp_hal:: gpio:: Level :: Low ,
126+ Default :: default ( ) ,
127+ ) ;
127128 #[ cfg( feature = "esp32" ) ]
128- let shifter_clk_pin = Output :: new ( peripherals. GPIO12 , esp_hal:: gpio:: Level :: Low ) ;
129+ let shifter_clk_pin = Output :: new (
130+ peripherals. GPIO12 ,
131+ esp_hal:: gpio:: Level :: Low ,
132+ Default :: default ( ) ,
133+ ) ;
129134 #[ cfg( feature = "esp32" ) ]
130- let shifter_latch_pin = Output :: new ( peripherals. GPIO17 , esp_hal:: gpio:: Level :: Low ) ;
135+ let shifter_latch_pin = Output :: new (
136+ peripherals. GPIO17 ,
137+ esp_hal:: gpio:: Level :: Low ,
138+ Default :: default ( ) ,
139+ ) ;
131140
132141 #[ cfg( feature = "esp32c3" ) ]
133142 let sck = peripherals. GPIO4 . degrade ( ) ;
@@ -140,11 +149,23 @@ async fn main(spawner: Spawner) {
140149 #[ cfg( feature = "esp32c3" ) ]
141150 let stackmat_rx = peripherals. GPIO20 . degrade ( ) ;
142151 #[ cfg( feature = "esp32c3" ) ]
143- let shifter_data_pin = Output :: new ( peripherals. GPIO10 , esp_hal:: gpio:: Level :: Low ) ;
152+ let shifter_data_pin = Output :: new (
153+ peripherals. GPIO10 ,
154+ esp_hal:: gpio:: Level :: Low ,
155+ Default :: default ( ) ,
156+ ) ;
144157 #[ cfg( feature = "esp32c3" ) ]
145- let shifter_latch_pin = Output :: new ( peripherals. GPIO1 , esp_hal:: gpio:: Level :: Low ) ;
158+ let shifter_latch_pin = Output :: new (
159+ peripherals. GPIO1 ,
160+ esp_hal:: gpio:: Level :: Low ,
161+ Default :: default ( ) ,
162+ ) ;
146163 #[ cfg( feature = "esp32c3" ) ]
147- let shifter_clk_pin = Output :: new ( peripherals. GPIO21 , esp_hal:: gpio:: Level :: Low ) ;
164+ let shifter_clk_pin = Output :: new (
165+ peripherals. GPIO21 ,
166+ esp_hal:: gpio:: Level :: Low ,
167+ Default :: default ( ) ,
168+ ) ;
148169
149170 let mut adv_shift_reg = adv_shift_registers:: AdvancedShiftRegister :: < 8 , _ > :: new (
150171 shifter_data_pin,
@@ -164,16 +185,31 @@ async fn main(spawner: Spawner) {
164185 . set_data ( & [ !crate :: utils:: stackmat:: DEC_DIGITS [ 8 ] ^ crate :: utils:: stackmat:: DOT_MOD ; 6 ] ) ;
165186
166187 #[ cfg( feature = "esp32" ) ]
167- let button_1 = Input :: new ( peripherals. GPIO27 , esp_hal:: gpio:: Pull :: Up ) ;
188+ let button_1 = Input :: new (
189+ peripherals. GPIO27 ,
190+ esp_hal:: gpio:: InputConfig :: default ( ) . with_pull ( esp_hal:: gpio:: Pull :: Down ) ,
191+ ) ;
168192 #[ cfg( feature = "esp32" ) ]
169- let button_2 = Input :: new ( peripherals. GPIO26 , esp_hal:: gpio:: Pull :: Up ) ;
193+ let button_2 = Input :: new (
194+ peripherals. GPIO26 ,
195+ esp_hal:: gpio:: InputConfig :: default ( ) . with_pull ( esp_hal:: gpio:: Pull :: Down ) ,
196+ ) ;
170197 #[ cfg( feature = "esp32" ) ]
171- let button_3 = Input :: new ( peripherals. GPIO33 , esp_hal:: gpio:: Pull :: Up ) ;
198+ let button_3 = Input :: new (
199+ peripherals. GPIO33 ,
200+ esp_hal:: gpio:: InputConfig :: default ( ) . with_pull ( esp_hal:: gpio:: Pull :: Down ) ,
201+ ) ;
172202 #[ cfg( feature = "esp32" ) ]
173- let button_4 = Input :: new ( peripherals. GPIO32 , esp_hal:: gpio:: Pull :: Up ) ;
203+ let button_4 = Input :: new (
204+ peripherals. GPIO32 ,
205+ esp_hal:: gpio:: InputConfig :: default ( ) . with_pull ( esp_hal:: gpio:: Pull :: Down ) ,
206+ ) ;
174207
175208 #[ cfg( feature = "esp32c3" ) ]
176- let button_input = Input :: new ( peripherals. GPIO3 , esp_hal:: gpio:: Pull :: Down ) ;
209+ let button_input = Input :: new (
210+ peripherals. GPIO3 ,
211+ esp_hal:: gpio:: InputConfig :: default ( ) . with_pull ( esp_hal:: gpio:: Pull :: Down ) ,
212+ ) ;
177213
178214 #[ cfg( feature = "esp32c3" ) ]
179215 let buttons_shifter = adv_shift_reg. get_shifter_mut ( 0 ) ;
@@ -191,7 +227,11 @@ async fn main(spawner: Spawner) {
191227 } ;
192228
193229 #[ cfg( feature = "esp32" ) ]
194- let cs_pin = Output :: new ( peripherals. GPIO5 , esp_hal:: gpio:: Level :: High ) ;
230+ let cs_pin = Output :: new (
231+ peripherals. GPIO5 ,
232+ esp_hal:: gpio:: Level :: High ,
233+ Default :: default ( ) ,
234+ ) ;
195235
196236 let global_state = Rc :: new ( GlobalStateInner :: new ( & nvs) ) ;
197237 let wifi_setup_sig = Rc :: new ( Signal :: new ( ) ) ;
@@ -200,7 +240,7 @@ async fn main(spawner: Spawner) {
200240 let i2c = esp_hal:: i2c:: master:: I2c :: new (
201241 peripherals. I2C0 ,
202242 esp_hal:: i2c:: master:: Config :: default ( )
203- . with_frequency ( 100 . kHz ( ) )
243+ . with_frequency ( esp_hal :: time :: Rate :: from_khz ( 100 ) )
204244 . with_timeout ( esp_hal:: i2c:: master:: BusTimeout :: Maximum ) ,
205245 )
206246 . expect ( "I2C new failed" )
@@ -289,8 +329,7 @@ async fn main(spawner: Spawner) {
289329 let Ok ( mut wifi_res) = wifi_res else {
290330 log:: error!( "WifiManager failed!!! Restarting in 1s!" ) ;
291331 Timer :: after_millis ( 1000 ) . await ;
292- esp_hal:: reset:: software_reset ( ) ;
293- return ;
332+ esp_hal:: system:: software_reset ( ) ;
294333 } ;
295334
296335 let conn_settings: ConnSettings = wifi_res
@@ -324,7 +363,7 @@ async fn main(spawner: Spawner) {
324363 _ = nvs. invalidate_key ( WIFI_NVS_KEY ) . await ;
325364 Timer :: after_millis ( 1000 ) . await ;
326365
327- esp_hal:: reset :: software_reset ( ) ;
366+ esp_hal:: system :: software_reset ( ) ;
328367 }
329368
330369 continue ;
0 commit comments