2
2
#include "scences/main_menu.h"
3
3
4
4
typedef enum {
5
- NfcPlaylistEvent_ShowEmulatingPopup
5
+ NfcPlaylistEvent_ShowEmulatingPopup ,
6
+ NfcPlaylistEvent_ShowSettings
6
7
} NfcPlaylistMainMenuEvent ;
7
8
8
9
typedef enum {
9
- NfcPlaylistSettings_Timeout ,
10
- NfcPlaylistSettings_Delay ,
11
- NfcPlaylistSettings_LedIndicator ,
12
- NfcPlaylistMenuSelection_Start
10
+ NfcPlaylistMenuSelection_Start ,
11
+ NfcPlaylistMenuSelection_Settings
13
12
} NfcPlaylistMenuSelection ;
14
13
15
14
static void nfc_playlist_menu_callback (void * context , uint32_t index ) {
@@ -18,35 +17,8 @@ static void nfc_playlist_menu_callback(void* context, uint32_t index) {
18
17
case NfcPlaylistMenuSelection_Start :
19
18
scene_manager_handle_custom_event (nfc_playlist -> scene_manager , NfcPlaylistEvent_ShowEmulatingPopup );
20
19
break ;
21
- default :
22
- break ;
23
- }
24
- }
25
-
26
- static void nfc_playlist_settings_change_callback (VariableItem * item ) {
27
- NfcPlaylist * nfc_playlist = variable_item_get_context (item );
28
-
29
- uint8_t current_option = variable_item_list_get_selected_item_index (nfc_playlist -> variable_item_list );
30
- uint8_t option_value_index = variable_item_get_current_value_index (item );
31
-
32
- switch (current_option ) {
33
- case NfcPlaylistSettings_Timeout : {
34
- nfc_playlist -> emulate_timeout = option_value_index ;
35
- char emulate_timeout_text [10 ];
36
- snprintf (emulate_timeout_text , 10 , "%ds" , options_emulate_timeout [option_value_index ]);
37
- variable_item_set_current_value_text (item , (char * )emulate_timeout_text );
38
- break ;
39
- }
40
- case NfcPlaylistSettings_Delay : {
41
- nfc_playlist -> emulate_delay = option_value_index ;
42
- char emulate_delay_text [10 ];
43
- snprintf (emulate_delay_text , 10 , "%ds" , options_emulate_delay [option_value_index ]);
44
- variable_item_set_current_value_text (item , (char * )emulate_delay_text );
45
- break ;
46
- }
47
- case NfcPlaylistSettings_LedIndicator :
48
- nfc_playlist -> emulate_led_indicator = option_value_index ;
49
- variable_item_set_current_value_text (item , nfc_playlist -> emulate_led_indicator ? "ON" : "OFF" );
20
+ case NfcPlaylistMenuSelection_Settings :
21
+ scene_manager_handle_custom_event (nfc_playlist -> scene_manager , NfcPlaylistEvent_ShowSettings );
50
22
break ;
51
23
default :
52
24
break ;
@@ -55,42 +27,22 @@ static void nfc_playlist_settings_change_callback(VariableItem* item) {
55
27
56
28
void nfc_playlist_main_menu_scene_on_enter (void * context ) {
57
29
NfcPlaylist * nfc_playlist = context ;
58
- variable_item_list_set_header (nfc_playlist -> variable_item_list , "NFC Playlist" );
59
-
60
- VariableItem * emulation_timeout_settings = variable_item_list_add (
61
- nfc_playlist -> variable_item_list ,
62
- "Emulate time" ,
63
- (sizeof (options_emulate_timeout )/sizeof (options_emulate_timeout [0 ])),
64
- nfc_playlist_settings_change_callback ,
65
- nfc_playlist );
66
- variable_item_set_current_value_index (emulation_timeout_settings , nfc_playlist -> emulate_timeout );
67
- char emulation_timeout_settings_text [10 ];
68
- snprintf (emulation_timeout_settings_text , 10 , "%ds" , options_emulate_timeout [nfc_playlist -> emulate_timeout ]);
69
- variable_item_set_current_value_text (emulation_timeout_settings , (char * )emulation_timeout_settings_text );
30
+ submenu_set_header (nfc_playlist -> submenu , "NFC Playlist" );
70
31
71
- VariableItem * emulation_delay_settings = variable_item_list_add (
72
- nfc_playlist -> variable_item_list ,
73
- "Delay time " ,
74
- ( sizeof ( options_emulate_delay )/ sizeof ( options_emulate_delay [ 0 ])) ,
75
- nfc_playlist_settings_change_callback ,
32
+ submenu_add_item (
33
+ nfc_playlist -> submenu ,
34
+ "Start " ,
35
+ NfcPlaylistMenuSelection_Start ,
36
+ nfc_playlist_menu_callback ,
76
37
nfc_playlist );
77
- variable_item_set_current_value_index (emulation_delay_settings , nfc_playlist -> emulate_delay );
78
- char emulation_delay_settings_text [10 ];
79
- snprintf (emulation_delay_settings_text , 10 , "%ds" , options_emulate_delay [nfc_playlist -> emulate_delay ]);
80
- variable_item_set_current_value_text (emulation_delay_settings , (char * )emulation_delay_settings_text );
81
38
82
- // add bool setting
83
- VariableItem * emulation_led_indicator_settings = variable_item_list_add (
84
- nfc_playlist -> variable_item_list ,
85
- "LED Indicator" ,
86
- 2 ,
87
- nfc_playlist_settings_change_callback ,
39
+ submenu_add_item (
40
+ nfc_playlist -> submenu ,
41
+ "Settings" ,
42
+ NfcPlaylistMenuSelection_Settings ,
43
+ nfc_playlist_menu_callback ,
88
44
nfc_playlist );
89
- variable_item_set_current_value_index (emulation_led_indicator_settings , nfc_playlist -> emulate_led_indicator );
90
- variable_item_set_current_value_text (emulation_led_indicator_settings , nfc_playlist -> emulate_led_indicator ? "ON" : "OFF" );
91
45
92
- variable_item_list_add (nfc_playlist -> variable_item_list , "Start" , 0 , NULL , NULL );
93
- variable_item_list_set_enter_callback (nfc_playlist -> variable_item_list , nfc_playlist_menu_callback , nfc_playlist );
94
46
view_dispatcher_switch_to_view (nfc_playlist -> view_dispatcher , NfcPlaylistView_Menu );
95
47
}
96
48
@@ -104,6 +56,10 @@ bool nfc_playlist_main_menu_scene_on_event(void* context, SceneManagerEvent even
104
56
scene_manager_next_scene (nfc_playlist -> scene_manager , NfcPlaylistScene_EmulatingPopup );
105
57
consumed = true;
106
58
break ;
59
+ case NfcPlaylistEvent_ShowSettings :
60
+ scene_manager_next_scene (nfc_playlist -> scene_manager , NfcPlaylistScene_Settings );
61
+ consumed = true;
62
+ break ;
107
63
default :
108
64
break ;
109
65
}
@@ -117,5 +73,5 @@ bool nfc_playlist_main_menu_scene_on_event(void* context, SceneManagerEvent even
117
73
118
74
void nfc_playlist_main_menu_scene_on_exit (void * context ) {
119
75
NfcPlaylist * nfc_playlist = context ;
120
- variable_item_list_reset (nfc_playlist -> variable_item_list );
76
+ submenu_reset (nfc_playlist -> submenu );
121
77
}
0 commit comments