@@ -25,24 +25,19 @@ pub async fn buttons_task(
2525 ) ;
2626 handler. add_handler (
2727 Button :: Third ,
28- ButtonTrigger :: HoldOnce ( 15000 ) ,
29- submit_reset_wifi ( ) ,
28+ ButtonTrigger :: HoldOnce ( 10000 ) ,
29+ submit_config_menu ( ) ,
3030 ) ;
3131
32- handler. add_handler ( Button :: First , ButtonTrigger :: Down , room_left ( ) ) ;
32+ handler. add_handler ( Button :: First , ButtonTrigger :: Down , sel_left ( ) ) ;
3333 handler. add_handler ( Button :: First , ButtonTrigger :: Down , inspection_start ( ) ) ;
3434 handler. add_handler (
3535 Button :: First ,
3636 ButtonTrigger :: HoldOnce ( 1000 ) ,
3737 inspection_hold_stop ( ) ,
3838 ) ;
39- handler. add_handler (
40- Button :: First ,
41- ButtonTrigger :: HoldOnce ( 15000 ) ,
42- connect_bluetooth_display ( ) ,
43- ) ;
4439
45- handler. add_handler ( Button :: Fourth , ButtonTrigger :: Down , room_right ( ) ) ;
40+ handler. add_handler ( Button :: Fourth , ButtonTrigger :: Down , sel_right ( ) ) ;
4641 handler. add_handler ( Button :: Fourth , ButtonTrigger :: HoldOnce ( 1000 ) , dnf_button ( ) ) ;
4742 handler. add_handler ( Button :: Fourth , ButtonTrigger :: Up , penalty_button ( ) ) ;
4843
@@ -90,12 +85,20 @@ async fn wakeup_button(
9085}
9186
9287#[ macros:: button_handler]
93- async fn room_left (
88+ async fn sel_left (
9489 _triggered : & ButtonTrigger ,
9590 _hold_time : u64 ,
9691 state : & GlobalState ,
9792) -> Result < bool , ( ) > {
9893 let mut state = state. state . lock ( ) . await ;
94+ if let Some ( sel) = state. selected_config_menu . as_mut ( ) {
95+ * sel = sel
96+ . wrapping_sub ( 1 )
97+ . min ( crate :: structs:: CONFIG_MENU_ITEMS . len ( ) - 1 ) ;
98+
99+ return Ok ( true ) ;
100+ }
101+
99102 if state. scene == Scene :: GroupSelect {
100103 state. group_selected_idx = state
101104 . group_selected_idx
@@ -109,12 +112,21 @@ async fn room_left(
109112}
110113
111114#[ macros:: button_handler]
112- async fn room_right (
115+ async fn sel_right (
113116 _triggered : & ButtonTrigger ,
114117 _hold_time : u64 ,
115118 state : & GlobalState ,
116119) -> Result < bool , ( ) > {
117120 let mut state = state. state . lock ( ) . await ;
121+ if let Some ( sel) = state. selected_config_menu . as_mut ( ) {
122+ * sel += 1 ;
123+ if * sel == crate :: structs:: CONFIG_MENU_ITEMS . len ( ) {
124+ * sel = 0 ;
125+ }
126+
127+ return Ok ( true ) ;
128+ }
129+
118130 if state. scene == Scene :: GroupSelect {
119131 state. group_selected_idx += 1 ;
120132 if state. group_selected_idx == state. possible_groups . len ( ) {
@@ -140,7 +152,44 @@ async fn submit_up(
140152 state_val. error_text = None ;
141153 state. state . signal ( ) ;
142154
143- return Ok ( false ) ;
155+ return Ok ( true ) ;
156+ }
157+
158+ if let Some ( sel) = state_val. selected_config_menu {
159+ match sel {
160+ 0 => {
161+ // Reset WiFi
162+ _ = state
163+ . nvs
164+ . invalidate_key ( esp_hal_wifimanager:: WIFI_NVS_KEY )
165+ . await ;
166+ _ = state. nvs . invalidate_key ( b"SIGN_KEY" ) . await ;
167+
168+ Timer :: after_millis ( 250 ) . await ;
169+ esp_hal:: system:: software_reset ( ) ;
170+ }
171+ 1 => {
172+ // BT Display
173+ state_val. error_text = Some ( "Not Implemented" . to_string ( ) ) ;
174+ }
175+ 2 => {
176+ // Sign Cards
177+ state_val. error_text = Some ( "Not Implemented" . to_string ( ) ) ;
178+ }
179+ 3 => {
180+ // Un-Sign Cards
181+ state_val. error_text = Some ( "Not Implemented" . to_string ( ) ) ;
182+ }
183+ 4 => { } // Exit
184+ _ => {
185+ state_val. error_text = Some ( "Not Implemented" . to_string ( ) ) ;
186+ }
187+ }
188+
189+ state_val. selected_config_menu = None ;
190+ state. state . signal ( ) ;
191+
192+ return Ok ( true ) ;
144193 }
145194
146195 // Device add
@@ -161,7 +210,7 @@ async fn submit_up(
161210 } )
162211 . await ;
163212
164- return Ok ( false ) ;
213+ return Ok ( true ) ;
165214 }
166215
167216 if state_val. should_skip_other_actions ( ) {
@@ -249,16 +298,6 @@ async fn inspection_hold_stop(
249298 Ok ( false )
250299}
251300
252- #[ macros:: button_handler]
253- async fn connect_bluetooth_display (
254- _triggered : & ButtonTrigger ,
255- _hold_time : u64 ,
256- state : & GlobalState ,
257- ) -> Result < bool , ( ) > {
258- _ = state;
259- Ok ( false )
260- }
261-
262301#[ macros:: button_handler]
263302async fn dnf_button (
264303 _triggered : & ButtonTrigger ,
@@ -337,24 +376,17 @@ async fn submit_reset_competitor(
337376}
338377
339378#[ macros:: button_handler]
340- async fn submit_reset_wifi (
379+ async fn submit_config_menu (
341380 _triggered : & ButtonTrigger ,
342381 _hold_time : u64 ,
343382 state : & GlobalState ,
344383) -> Result < bool , ( ) > {
345- _ = state
346- . nvs
347- . invalidate_key ( esp_hal_wifimanager:: WIFI_NVS_KEY )
348- . await ;
349- _ = state. nvs . invalidate_key ( b"SIGN_KEY" ) . await ;
350-
351384 {
352385 let mut state = state. state . lock ( ) . await ;
353- state. custom_message = Some ( ( "Resetting WIFI" . to_string ( ) , "Restart in 5s..." . to_string ( ) ) ) ;
386+ state. selected_config_menu = Some ( 0 ) ;
354387 }
355388
356- Timer :: after_millis ( 5000 ) . await ;
357- esp_hal:: system:: software_reset ( ) ;
389+ Ok ( true )
358390}
359391
360392#[ macros:: button_handler]
0 commit comments