thermferm/panel.c

changeset 645
49eb753a958b
parent 427
e8e548922e31
child 646
e3edc783006b
equal deleted inserted replaced
644:07cc86900473 645:49eb753a958b
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2014 2 * Copyright (C) 2014-2024
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of the mbsePi-apps 6 * This file is part of the mbsePi-apps
7 * 7 *
49 extern int debug; 49 extern int debug;
50 extern int setupmenu; 50 extern int setupmenu;
51 extern uint16_t keys; 51 extern uint16_t keys;
52 extern uint16_t leds; 52 extern uint16_t leds;
53 extern int slcdHandle; 53 extern int slcdHandle;
54 extern pthread_mutex_t mutexes[5];
54 55
55 int Key_Enter = FALSE; 56 int Key_Enter = FALSE;
56 int Key_Enter_Long = FALSE; 57 int Key_Enter_Long = FALSE;
57 int Key_Up = FALSE; 58 int Key_Up = FALSE;
58 int Key_Down = FALSE; 59 int Key_Down = FALSE;
184 if (Key_Enter || Key_Up || Key_Down) { 185 if (Key_Enter || Key_Up || Key_Down) {
185 AnyKey = TRUE; 186 AnyKey = TRUE;
186 /* 187 /*
187 * Any key is pressed. 188 * Any key is pressed.
188 */ 189 */
189 #ifdef HAVE_WIRINGPI_H 190 pthread_mutex_lock(&mutexes[LOCK_LCD]);
190 piLock(LOCK_LCD);
191 #endif
192 setBacklight(1); 191 setBacklight(1);
193 #ifdef HAVE_WIRINGPI_H 192 pthread_mutex_unlock(&mutexes[LOCK_LCD]);
194 piUnlock(LOCK_LCD);
195 #endif
196 Backlight = LCD_SLEEP; 193 Backlight = LCD_SLEEP;
197 menutimer = 0; 194 menutimer = 0;
198 } else { 195 } else {
199 /* 196 /*
200 * No key pressed. 197 * No key pressed.
206 if (Now != Last) { 203 if (Now != Last) {
207 Last = Now; 204 Last = Now;
208 205
209 if (AnyKey == FALSE) { 206 if (AnyKey == FALSE) {
210 if (Backlight == 1) { 207 if (Backlight == 1) {
211 #ifdef HAVE_WIRINGPI_H 208 pthread_mutex_lock(&mutexes[LOCK_LCD]);
212 piLock(LOCK_LCD);
213 #endif
214 setBacklight(0); 209 setBacklight(0);
215 #ifdef HAVE_WIRINGPI_H 210 pthread_mutex_unlock(&mutexes[LOCK_LCD]);
216 piUnlock(LOCK_LCD);
217 #endif
218 } 211 }
219 if (Backlight > 0) { 212 if (Backlight > 0) {
220 Backlight--; 213 Backlight--;
221 } 214 }
222 215
223 #ifdef HAVE_WIRINGPI_H 216 pthread_mutex_lock(&mutexes[LOCK_MENU]);
224 piLock(LOCK_MENU);
225 #endif
226 if (setupmenu != MENU_NONE) { 217 if (setupmenu != MENU_NONE) {
227 if (menutimer < MENU_TIMEOUT) 218 if (menutimer < MENU_TIMEOUT)
228 menutimer++; 219 menutimer++;
229 else { 220 else {
230 setupmenu = MENU_NONE; 221 setupmenu = MENU_NONE;
231 } 222 }
232 } 223 }
233 #ifdef HAVE_WIRINGPI_H 224 pthread_mutex_unlock(&mutexes[LOCK_MENU]);
234 piUnlock(LOCK_MENU);
235 #endif
236 } 225 }
237 } 226 }
238 227
239 /* 228 /*
240 * Loop 10 milliseconds 229 * Loop 10 milliseconds

mercurial