Improve BackLt (35/63)

This commit is contained in:
Armel FAUVEAU
2024-04-05 05:03:40 +02:00
parent a562ff8479
commit d489dedf51
9 changed files with 29 additions and 30 deletions

View File

@@ -504,7 +504,7 @@ void ACTION_BackLightOnDemand(void)
if(gBackLight == false) if(gBackLight == false)
{ {
gBacklightTimeOriginal = gEeprom.BACKLIGHT_TIME; gBacklightTimeOriginal = gEeprom.BACKLIGHT_TIME;
gEeprom.BACKLIGHT_TIME = 7; gEeprom.BACKLIGHT_TIME = 17;
gBackLight = true; gBackLight = true;
} }
else else
@@ -515,7 +515,7 @@ void ACTION_BackLightOnDemand(void)
} }
else else
{ {
gEeprom.BACKLIGHT_TIME = 7; gEeprom.BACKLIGHT_TIME = 17;
} }
} }

View File

@@ -1483,7 +1483,7 @@ void APP_TimeSlice500ms(void)
// don't turn off backlight if user is in backlight menu option // 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)) && !(gScreenToDisplay == DISPLAY_MENU && (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX))
&& --gBacklightCountdown_500ms == 0 && --gBacklightCountdown_500ms == 0
&& gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1) && gEeprom.BACKLIGHT_TIME < 17
) { ) {
BACKLIGHT_TurnOff(); BACKLIGHT_TurnOff();
} }

View File

@@ -129,7 +129,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_ABR: case MENU_ABR:
//*pMin = 0; //*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1; *pMax = 17;
break; break;
case MENU_ABR_MIN: case MENU_ABR_MIN:

View File

@@ -110,17 +110,13 @@ void BACKLIGHT_TurnOn(void)
switch (gEeprom.BACKLIGHT_TIME) { switch (gEeprom.BACKLIGHT_TIME) {
default: default:
case 1: // 5 sec case 1 ... 11: // 5 sec * value
case 2: // 10 sec gBacklightCountdown_500ms = 1 + (gEeprom.BACKLIGHT_TIME * 5) * 2;
case 3: // 20 sec
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 1)) * 5;
break; break;
case 4: // 1 min case 12 ... 16: // 1 min $ value
case 5: // 2 min gBacklightCountdown_500ms = 1 + ((gEeprom.BACKLIGHT_TIME - 11) * 60) * 2;
case 6: // 4 min
gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 4)) * 60;
break; break;
case 7: // always on case 17: // always on
gBacklightCountdown_500ms = 0; gBacklightCountdown_500ms = 0;
break; break;
} }

View File

@@ -219,7 +219,7 @@ void BATTERY_TimeSlice500ms(void)
ST7565_HardwareReset(); ST7565_HardwareReset();
if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) { if (gEeprom.BACKLIGHT_TIME < 17) {
BACKLIGHT_TurnOff(); BACKLIGHT_TurnOff();
} }
} }

2
main.c
View File

@@ -151,7 +151,7 @@ void Main(void)
{ {
FUNCTION_Select(FUNCTION_POWER_SAVE); 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 BACKLIGHT_TurnOff(); // turn the backlight OFF
else else
BACKLIGHT_TurnOn(); // turn the backlight ON BACKLIGHT_TurnOn(); // turn the backlight ON

View File

@@ -67,7 +67,7 @@ void SETTINGS_InitEEPROM(void)
gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4; gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4;
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; 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.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false;
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true; gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true;

View File

@@ -312,18 +312,6 @@ const char * const gSubMenu_F_LOCK[] =
"UNLOCK\nALL", "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] = const char gSubMenu_RX_TX[][6] =
{ {
"OFF", "OFF",
@@ -668,7 +656,23 @@ void UI_DisplayMenu(void)
#endif #endif
case MENU_ABR: 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) if(BACKLIGHT_GetBrightness() < 4)
BACKLIGHT_SetBrightness(4); BACKLIGHT_SetBrightness(4);
break; break;

View File

@@ -180,7 +180,6 @@ extern const char* const gSubMenu_PTT_ID[5];
extern const char gSubMenu_ROGER[3][6]; extern const char gSubMenu_ROGER[3][6];
extern const char gSubMenu_RESET[2][4]; extern const char gSubMenu_RESET[2][4];
extern const char* const gSubMenu_F_LOCK[F_LOCK_LEN]; 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_RX_TX[4][6];
extern const char gSubMenu_BAT_TXT[3][8]; extern const char gSubMenu_BAT_TXT[3][8];
extern const char gSubMenu_BATTYP[2][9]; extern const char gSubMenu_BATTYP[2][9];