fix: Force a valid min "backlight on" setting on color lcd radios (#1386)

* always have aat least a 5s backlight timeout and some backlight enabled when backlightshould be on on color lcd radios

* for backlight timeout to be at least 5s on color lcd radios under all circumstances

* fix indentation

* the backlight value is inverted on color lcd radios, so the calculation was wrong

* fix typos
This commit is contained in:
Malte Langermann
2022-01-11 22:44:13 +10:00
committed by GitHub
parent 192ca87afb
commit 37ee8a68f8
+14 -1
View File
@@ -568,6 +568,11 @@ void checkBacklight()
}
if (backlightOn) {
currentBacklightBright = requiredBacklightBright;
#if defined(COLORLCD)
// force backlight on for color lcd radios
if(currentBacklightBright > BACKLIGHT_LEVEL_MAX - BACKLIGHT_LEVEL_MIN)
currentBacklightBright = BACKLIGHT_LEVEL_MAX - BACKLIGHT_LEVEL_MIN;
#endif
BACKLIGHT_ENABLE();
}
else {
@@ -579,7 +584,11 @@ void checkBacklight()
void resetBacklightTimeout()
{
lightOffCounter = ((uint16_t)g_eeGeneral.lightAutoOff*250) << 1;
uint16_t autoOff = g_eeGeneral.lightAutoOff;
#if defined(COLORLCD)
autoOff = std::max<uint16_t>(1, autoOff); // prevent the timeout from being 0 seconds on color lcd radios
#endif
lightOffCounter = (autoOff*250) << 1;
}
#if defined(SPLASH)
@@ -1915,6 +1924,10 @@ void opentxInit()
// no backlight mode off on color lcd radios
g_eeGeneral.backlightMode = e_backlight_mode_keys;
}
if (g_eeGeneral.backlightBright > BACKLIGHT_LEVEL_MAX - BACKLIGHT_LEVEL_MIN)
g_eeGeneral.backlightBright = BACKLIGHT_LEVEL_MAX - BACKLIGHT_LEVEL_MIN;
if (g_eeGeneral.lightAutoOff < 1)
g_eeGeneral.lightAutoOff = 1;
#endif
if (g_eeGeneral.backlightMode != e_backlight_mode_off) {