From d489dedf51bc0cb9467436172cfdd046e3db2f37 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Fri, 5 Apr 2024 05:03:40 +0200 Subject: [PATCH] Improve BackLt (35/63) --- app/action.c | 4 ++-- app/app.c | 2 +- app/menu.c | 2 +- driver/backlight.c | 14 +++++--------- helper/battery.c | 2 +- main.c | 2 +- settings.c | 2 +- ui/menu.c | 30 +++++++++++++++++------------- ui/menu.h | 1 - 9 files changed, 29 insertions(+), 30 deletions(-) diff --git a/app/action.c b/app/action.c index d3ccb61..1f6afcb 100644 --- a/app/action.c +++ b/app/action.c @@ -504,7 +504,7 @@ void ACTION_BackLightOnDemand(void) if(gBackLight == false) { gBacklightTimeOriginal = gEeprom.BACKLIGHT_TIME; - gEeprom.BACKLIGHT_TIME = 7; + gEeprom.BACKLIGHT_TIME = 17; gBackLight = true; } else @@ -515,7 +515,7 @@ void ACTION_BackLightOnDemand(void) } else { - gEeprom.BACKLIGHT_TIME = 7; + gEeprom.BACKLIGHT_TIME = 17; } } diff --git a/app/app.c b/app/app.c index 0f3a564..a23ca02 100644 --- a/app/app.c +++ b/app/app.c @@ -1483,7 +1483,7 @@ void APP_TimeSlice500ms(void) // don't turn off backlight if user is in backlight menu option && !(gScreenToDisplay == DISPLAY_MENU && (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX)) && --gBacklightCountdown_500ms == 0 - && gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1) + && gEeprom.BACKLIGHT_TIME < 17 ) { BACKLIGHT_TurnOff(); } diff --git a/app/menu.c b/app/menu.c index b8d8724..d6471a7 100644 --- a/app/menu.c +++ b/app/menu.c @@ -129,7 +129,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) case MENU_ABR: //*pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1; + *pMax = 17; break; case MENU_ABR_MIN: diff --git a/driver/backlight.c b/driver/backlight.c index 7868900..79a093b 100644 --- a/driver/backlight.c +++ b/driver/backlight.c @@ -110,17 +110,13 @@ void BACKLIGHT_TurnOn(void) switch (gEeprom.BACKLIGHT_TIME) { default: - case 1: // 5 sec - case 2: // 10 sec - case 3: // 20 sec - gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 1)) * 5; + case 1 ... 11: // 5 sec * value + gBacklightCountdown_500ms = 1 + (gEeprom.BACKLIGHT_TIME * 5) * 2; break; - case 4: // 1 min - case 5: // 2 min - case 6: // 4 min - gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 4)) * 60; + case 12 ... 16: // 1 min $ value + gBacklightCountdown_500ms = 1 + ((gEeprom.BACKLIGHT_TIME - 11) * 60) * 2; break; - case 7: // always on + case 17: // always on gBacklightCountdown_500ms = 0; break; } diff --git a/helper/battery.c b/helper/battery.c index 6267c16..f000a4a 100644 --- a/helper/battery.c +++ b/helper/battery.c @@ -219,7 +219,7 @@ void BATTERY_TimeSlice500ms(void) ST7565_HardwareReset(); - if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) { + if (gEeprom.BACKLIGHT_TIME < 17) { BACKLIGHT_TurnOff(); } } diff --git a/main.c b/main.c index 7a831bb..5e71a79 100644 --- a/main.c +++ b/main.c @@ -151,7 +151,7 @@ void Main(void) { FUNCTION_Select(FUNCTION_POWER_SAVE); - if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) // backlight is not set to be always on + if (gEeprom.BACKLIGHT_TIME < 17) // backlight is not set to be always on BACKLIGHT_TurnOff(); // turn the backlight OFF else BACKLIGHT_TurnOn(); // turn the backlight ON diff --git a/settings.c b/settings.c index 06dbdfe..74b6902 100644 --- a/settings.c +++ b/settings.c @@ -67,7 +67,7 @@ void SETTINGS_InitEEPROM(void) gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4; gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; - gEeprom.BACKLIGHT_TIME = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 3; + gEeprom.BACKLIGHT_TIME = (Data[5] < 18) ? Data[5] : 3; gEeprom.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false; gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true; diff --git a/ui/menu.c b/ui/menu.c index 32da365..0b7fcf4 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -312,18 +312,6 @@ const char * const gSubMenu_F_LOCK[] = "UNLOCK\nALL", }; -const char gSubMenu_BACKLIGHT[][7] = -{ - "OFF", - "5 sec", - "10 sec", - "20 sec", - "1 min", - "2 min", - "4 min", - "ON" -}; - const char gSubMenu_RX_TX[][6] = { "OFF", @@ -668,7 +656,23 @@ void UI_DisplayMenu(void) #endif case MENU_ABR: - strcpy(String, gSubMenu_BACKLIGHT[gSubMenuSelection]); + if(gSubMenuSelection == 0) + { + sprintf(String, "%s", "OFF"); + } + else if(gSubMenuSelection < 12) + { + sprintf(String, "%d sec", gSubMenuSelection * 5); + } + else if(gSubMenuSelection < 17) + { + sprintf(String, "%d min", gSubMenuSelection - 11); + } + else + { + sprintf(String, "%s", "ON"); + } + if(BACKLIGHT_GetBrightness() < 4) BACKLIGHT_SetBrightness(4); break; diff --git a/ui/menu.h b/ui/menu.h index 1322200..902c9e4 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -180,7 +180,6 @@ extern const char* const gSubMenu_PTT_ID[5]; extern const char gSubMenu_ROGER[3][6]; extern const char gSubMenu_RESET[2][4]; extern const char* const gSubMenu_F_LOCK[F_LOCK_LEN]; -extern const char gSubMenu_BACKLIGHT[8][7]; extern const char gSubMenu_RX_TX[4][6]; extern const char gSubMenu_BAT_TXT[3][8]; extern const char gSubMenu_BATTYP[2][9];