1
1
#include "actions.h"
2
2
#include "screens.h"
3
- #include "ui.h"
4
3
#include <stdio.h>
4
+ #include "ui.h"
5
+ #include "vars.h"
5
6
6
7
int handle_gesture_screen_switch (lv_event_t * e , lv_dir_t direction , int screenId ) {
7
8
lv_event_code_t event_code = lv_event_get_code (e );
@@ -17,6 +18,15 @@ int handle_gesture_screen_switch(lv_event_t *e, lv_dir_t direction, int screenId
17
18
return 1 ;
18
19
}
19
20
21
+ void handle_gesture_main_screen_switch (lv_event_t * e , lv_dir_t direction ) {
22
+ const char * main_screen = get_var_main_screen ();
23
+ if (strcmp (main_screen , "home_screen" ) == 0 ) {
24
+ loadScreen (SCREEN_ID_HOME_SCREEN );
25
+ } else if (strcmp (main_screen , "no_network_screen" ) == 0 ) {
26
+ loadScreen (SCREEN_ID_NO_NETWORK_SCREEN );
27
+ }
28
+ }
29
+
20
30
void action_switch_to_menu (lv_event_t * e ) {
21
31
loadScreen (SCREEN_ID_MENU_SCREEN );
22
32
}
@@ -42,7 +52,7 @@ void action_switch_to_reboot(lv_event_t *e) {
42
52
}
43
53
44
54
void action_menu_screen_gesture (lv_event_t * e ) {
45
- handle_gesture_screen_switch (e , LV_DIR_RIGHT , SCREEN_ID_HOME_SCREEN );
55
+ handle_gesture_main_screen_switch (e , LV_DIR_RIGHT );
46
56
}
47
57
48
58
void action_menu_advanced_screen_gesture (lv_event_t * e ) {
@@ -64,6 +74,8 @@ void action_about_screen_gesture(lv_event_t * e) {
64
74
// user_data doesn't seem to be working, so we use a global variable here
65
75
static uint32_t t_reset_config ;
66
76
static uint32_t t_reboot ;
77
+ static bool b_reboot = false;
78
+ static bool b_reset_config = false;
67
79
const int RESET_CONFIG_HOLD_TIME = 10 ;
68
80
const int REBOOT_HOLD_TIME = 5 ;
69
81
@@ -80,7 +92,9 @@ void action_reset_config(lv_event_t * e) {
80
92
lv_obj_add_flag (objects .reset_config_button , LV_OBJ_FLAG_HIDDEN );
81
93
lv_obj_clear_flag (objects .reset_config_spinner , LV_OBJ_FLAG_HIDDEN );
82
94
ui_call_rpc_handler ("resetConfig" , NULL );
95
+ b_reset_config = true;
83
96
} else {
97
+ b_reset_config = false;
84
98
char buf [100 ];
85
99
int remaining_time_seconds = remaining_time / 1000 ;
86
100
if (remaining_time_seconds <= 1 ) {
@@ -89,6 +103,10 @@ void action_reset_config(lv_event_t * e) {
89
103
sprintf (buf , "Press and hold for %d seconds" , remaining_time_seconds );
90
104
lv_label_set_text (objects .reset_config_label , buf );
91
105
}
106
+ } else if (event_code == LV_EVENT_RELEASED ) {
107
+ if (!b_reset_config ) {
108
+ lv_label_set_text (objects .reset_config_label , "Press and hold for 10 seconds" );
109
+ }
92
110
}
93
111
}
94
112
@@ -103,7 +121,9 @@ void action_reboot(lv_event_t * e) {
103
121
int remaining_time = REBOOT_HOLD_TIME * 1000 - lv_tick_elaps (t_reboot );
104
122
if (remaining_time <= 0 ) {
105
123
ui_call_rpc_handler ("reboot" , NULL );
124
+ b_reboot = false;
106
125
} else {
126
+ b_reboot = false;
107
127
char buf [100 ];
108
128
int remaining_time_seconds = remaining_time / 1000 ;
109
129
if (remaining_time_seconds <= 1 ) {
@@ -112,5 +132,9 @@ void action_reboot(lv_event_t * e) {
112
132
sprintf (buf , "Press and hold for %d seconds" , remaining_time_seconds );
113
133
lv_label_set_text (objects .reboot_label , buf );
114
134
}
135
+ } else if (event_code == LV_EVENT_RELEASED ) {
136
+ if (!b_reboot ) {
137
+ lv_label_set_text (objects .reboot_label , "Press and hold for 5 seconds" );
138
+ }
115
139
}
116
140
}
0 commit comments