204:9a14d6b2de7f | 205:ca18ff45deba |
---|---|
28 #ifdef HAVE_WIRINGPI_H | 28 #ifdef HAVE_WIRINGPI_H |
29 | 29 |
30 | 30 |
31 extern int my_shutdown; | 31 extern int my_shutdown; |
32 extern int debug; | 32 extern int debug; |
33 extern int setupmenu; | |
33 | 34 |
34 int Key_Enter = FALSE; | 35 int Key_Enter = FALSE; |
35 int Key_Enter_Long = FALSE; | 36 int Key_Enter_Long = FALSE; |
36 int Key_Up = FALSE; | 37 int Key_Up = FALSE; |
37 int Key_Down = FALSE; | 38 int Key_Down = FALSE; |
38 | 39 |
39 int previous_key = KEY_NONE; | 40 int previous_key = KEY_NONE; |
41 int menutimer = 0; | |
42 | |
43 int Led_Off = 0; | |
44 int Led_On = 100; | |
45 | |
46 | |
47 /* | |
48 * LED flash patterns, on, off. Times in 10 mSecs. | |
49 */ | |
50 const int LED_OFF[2] = { 0, 100 }; | |
51 const int LED_ON[2] = { 100, 0 }; | |
52 const int LED_WARN[2] = { 5, 95 }; | |
53 const int LED_ALARM[2] = { 50, 50 }; | |
40 | 54 |
41 | 55 |
42 | 56 |
43 /* | 57 /* |
44 * Check for a key. Return last pressed key or none. | 58 * Check for a key. Return last pressed key or none. |
61 int keypressed(void) | 75 int keypressed(void) |
62 { | 76 { |
63 if (Key_Enter && Key_Up && Key_Down) | 77 if (Key_Enter && Key_Up && Key_Down) |
64 return KEY_ALL; | 78 return KEY_ALL; |
65 if (Key_Up && Key_Down) | 79 if (Key_Up && Key_Down) |
66 return KEY_UPDOWN; | 80 return KEY_ESCAPE; |
67 if (Key_Up) | 81 if (Key_Up) |
68 return KEY_UP; | 82 return KEY_UP; |
69 if (Key_Down) | 83 if (Key_Down) |
70 return KEY_DOWN; | 84 return KEY_DOWN; |
71 if (Key_Enter_Long) | 85 if (Key_Enter_Long) |
135 * Any key is pressed. | 149 * Any key is pressed. |
136 */ | 150 */ |
137 if (Backlight == 0) | 151 if (Backlight == 0) |
138 setBacklight(1); | 152 setBacklight(1); |
139 Backlight = LCD_SLEEP; | 153 Backlight = LCD_SLEEP; |
154 menutimer = 0; | |
140 } else { | 155 } else { |
141 /* | 156 /* |
142 * No key pressed. | 157 * No key pressed. |
143 */ | 158 */ |
144 AnyKey = FALSE; | 159 AnyKey = FALSE; |
158 if (Backlight == 1) | 173 if (Backlight == 1) |
159 setBacklight(0); | 174 setBacklight(0); |
160 if (Backlight > 0) { | 175 if (Backlight > 0) { |
161 Backlight--; | 176 Backlight--; |
162 } | 177 } |
178 | |
179 if (setupmenu != MENU_NONE) { | |
180 if (menutimer < MENU_TIMEOUT) | |
181 menutimer++; | |
182 else | |
183 setupmenu = MENU_NONE; | |
184 } | |
163 } | 185 } |
164 | |
165 } | 186 } |
166 | 187 |
167 /* | 188 /* |
168 * Loop 10 milliseconds | 189 * Loop 10 milliseconds |
169 */ | 190 */ |