22
33////////////////////////// ByteInput Scene ////////////////////////
44void SetValue (void * context ) {
5- App * app = context ;
6- scene_manager_handle_back_event (app -> sceneManager );
5+ App * app = context ;
6+ scene_manager_handle_back_event (app -> sceneManager );
77}
88void app_scene_byte_input_on_enter (void * context ) {
9- App * app = context ;
10- uint8_t * buf = app -> msgBuf ;
11- uint8_t offset =
12- scene_manager_get_scene_state (app -> sceneManager , app_scene_byte_input );
13- switch (scene_manager_get_scene_state (app -> sceneManager , app_scene_byte_input )) {
9+ App * app = context ;
10+ uint8_t * buf = app -> msgBuf ;
11+ uint8_t offset = scene_manager_get_scene_state (app -> sceneManager , app_scene_byte_input );
12+ switch (scene_manager_get_scene_state (app -> sceneManager , app_scene_byte_input )) {
1413 case 0 :
15- byte_input_set_header_text (app -> byteInput , "Set Slave" );
16- byte_input_set_result_callback (app -> byteInput , SetValue , NULL , app ,
17- & SLAVE , 1 );
18- view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
19- break ;
14+ byte_input_set_header_text (app -> byteInput , "Set Slave" );
15+ byte_input_set_result_callback (app -> byteInput , SetValue , NULL , app , & SLAVE , 1 );
16+ view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
17+ break ;
2018 case 1 :
21- byte_input_set_header_text (app -> byteInput , "Set Function" );
22- byte_input_set_result_callback (app -> byteInput , SetValue , NULL , app ,
23- & FUNCTION , 1 );
24- view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
25- break ;
19+ byte_input_set_header_text (app -> byteInput , "Set Function" );
20+ byte_input_set_result_callback (app -> byteInput , SetValue , NULL , app , & FUNCTION , 1 );
21+ view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
22+ break ;
2623 case 2 :
27- byte_input_set_header_text (app -> byteInput , "Set Address" );
28- byte_input_set_result_callback (app -> byteInput , SetValue , NULL , app ,
29- & buf [2 ], 2 );
30- view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
31- break ;
24+ byte_input_set_header_text (app -> byteInput , "Set Address" );
25+ byte_input_set_result_callback (app -> byteInput , SetValue , NULL , app , & buf [2 ], 2 );
26+ view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
27+ break ;
3228 case 3 :
33- byte_input_set_header_text (app -> byteInput , "Set value or quantity" );
34- byte_input_set_result_callback (app -> byteInput , SetValue , NULL , app ,
35- & buf [4 ], 2 );
36- view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
37- break ;
29+ byte_input_set_header_text (app -> byteInput , "Set value or quantity" );
30+ byte_input_set_result_callback (app -> byteInput , SetValue , NULL , app , & buf [4 ], 2 );
31+ view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
32+ break ;
3833 default :
39- if (FUNCTION == 0x0F )
40- offset += 2 ;
41- else
42- offset += offset - 3 ;
43- byte_input_set_header_text (app -> byteInput , "Set x value" );
44- byte_input_set_result_callback ( app -> byteInput , SetValue , NULL , app ,
45- & buf [offset ], FUNCTION == 0x0F ? 1 : 2 );
46- view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
47- break ;
48- }
34+ if (FUNCTION == 0x0F )
35+ offset += 2 ;
36+ else
37+ offset += offset - 3 ;
38+ byte_input_set_header_text (app -> byteInput , "Set x value" );
39+ byte_input_set_result_callback (
40+ app -> byteInput , SetValue , NULL , app , & buf [offset ], FUNCTION == 0x0F ? 1 : 2 );
41+ view_dispatcher_switch_to_view (app -> viewDispatcher , ByteInput_View );
42+ break ;
43+ }
4944}
5045bool app_scene_byte_input_on_event (void * context , SceneManagerEvent event ) {
51- UNUSED (context );
52- UNUSED (event );
53- return false;
46+ UNUSED (context );
47+ UNUSED (event );
48+ return false;
5449}
5550void app_scene_byte_input_on_exit (void * context ) {
56- App * app = context ;
57- UNUSED (app );
58- }
51+ App * app = context ;
52+ UNUSED (app );
53+ }
0 commit comments