diff -r 07cc86900473 -r 49eb753a958b thermferm/panel.c --- a/thermferm/panel.c Sat Mar 23 09:31:01 2024 +0100 +++ b/thermferm/panel.c Sat Mar 23 12:18:14 2024 +0100 @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2014 + * Copyright (C) 2014-2024 * * Michiel Broek * @@ -51,6 +51,7 @@ extern uint16_t keys; extern uint16_t leds; extern int slcdHandle; +extern pthread_mutex_t mutexes[5]; int Key_Enter = FALSE; int Key_Enter_Long = FALSE; @@ -186,13 +187,9 @@ /* * Any key is pressed. */ -#ifdef HAVE_WIRINGPI_H - piLock(LOCK_LCD); -#endif + pthread_mutex_lock(&mutexes[LOCK_LCD]); setBacklight(1); -#ifdef HAVE_WIRINGPI_H - piUnlock(LOCK_LCD); -#endif + pthread_mutex_unlock(&mutexes[LOCK_LCD]); Backlight = LCD_SLEEP; menutimer = 0; } else { @@ -208,21 +205,15 @@ if (AnyKey == FALSE) { if (Backlight == 1) { -#ifdef HAVE_WIRINGPI_H - piLock(LOCK_LCD); -#endif + pthread_mutex_lock(&mutexes[LOCK_LCD]); setBacklight(0); -#ifdef HAVE_WIRINGPI_H - piUnlock(LOCK_LCD); -#endif + pthread_mutex_unlock(&mutexes[LOCK_LCD]); } if (Backlight > 0) { Backlight--; } -#ifdef HAVE_WIRINGPI_H - piLock(LOCK_MENU); -#endif + pthread_mutex_lock(&mutexes[LOCK_MENU]); if (setupmenu != MENU_NONE) { if (menutimer < MENU_TIMEOUT) menutimer++; @@ -230,9 +221,7 @@ setupmenu = MENU_NONE; } } -#ifdef HAVE_WIRINGPI_H - piUnlock(LOCK_MENU); -#endif + pthread_mutex_unlock(&mutexes[LOCK_MENU]); } }