From 5200915c13976e0a87291a917cb44758c00ad1a4 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Tue, 12 Mar 2024 04:46:26 +0100 Subject: [PATCH] Revert BackLight Action and add 2 new buttons shortcuts --- app/action.c | 27 +++++++++++++++++++++++---- app/action.h | 1 + app/main.c | 11 +++++++++++ app/menu.c | 13 ++++++++++++- misc.c | 1 + misc.h | 1 + ui/menu.c | 1 - 7 files changed, 49 insertions(+), 6 deletions(-) diff --git a/app/action.c b/app/action.c index 6c3a7f4..d3ccb61 100644 --- a/app/action.c +++ b/app/action.c @@ -491,15 +491,34 @@ void ACTION_Wn(void) void ACTION_BackLight(void) { - gBackLight = true; - if(gBacklightBrightnessOld == gEeprom.BACKLIGHT_MAX) + if(gBackLight) { - gEeprom.BACKLIGHT_TIME = 0; + gEeprom.BACKLIGHT_TIME = gBacklightTimeOriginal; + } + gBackLight = false; + BACKLIGHT_TurnOn(); +} + +void ACTION_BackLightOnDemand(void) +{ + if(gBackLight == false) + { + gBacklightTimeOriginal = gEeprom.BACKLIGHT_TIME; + gEeprom.BACKLIGHT_TIME = 7; + gBackLight = true; } else { - gEeprom.BACKLIGHT_TIME = 7; + if(gBacklightBrightnessOld == gEeprom.BACKLIGHT_MAX) + { + gEeprom.BACKLIGHT_TIME = 0; + } + else + { + gEeprom.BACKLIGHT_TIME = 7; + } } + BACKLIGHT_TurnOn(); } #endif \ No newline at end of file diff --git a/app/action.h b/app/action.h index 8aec306..1d37084 100644 --- a/app/action.h +++ b/app/action.h @@ -39,6 +39,7 @@ void ACTION_SwitchDemodul(void); void ACTION_RxMode(void); void ACTION_Ptt(void); void ACTION_Wn(void); + void ACTION_BackLightOnDemand(void); void ACTION_BackLight(void); #endif diff --git a/app/main.c b/app/main.c index 7d44ed7..5dfe287 100644 --- a/app/main.c +++ b/app/main.c @@ -456,6 +456,17 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gWasFKeyPressed = false; gUpdateStatus = true; + if(Key == 8) + { + ACTION_BackLightOnDemand(); + return; + } + else if(Key == 9) + { + ACTION_BackLight(); + return; + } + processFKeyFunction(Key, true); } diff --git a/app/menu.c b/app/menu.c index 78ca0b3..2af07ec 100644 --- a/app/menu.c +++ b/app/menu.c @@ -1010,7 +1010,18 @@ void MENU_ShowCurrentSetting(void) #endif case MENU_ABR: - gSubMenuSelection = gEeprom.BACKLIGHT_TIME; + #ifdef ENABLE_FEAT_F4HWN + if(gBackLight) + { + gSubMenuSelection = gBacklightTimeOriginal; + } + else + { + gSubMenuSelection = gEeprom.BACKLIGHT_TIME; + } + #else + gSubMenuSelection = gEeprom.BACKLIGHT_TIME; + #endif break; case MENU_ABR_MIN: diff --git a/misc.c b/misc.c index 2d84bd0..dffb91b 100644 --- a/misc.c +++ b/misc.c @@ -277,6 +277,7 @@ uint8_t gIsLocked = 0xFF; #ifdef ENABLE_FEAT_F4HWN bool gBackLight = false; + uint8_t gBacklightTimeOriginal; uint8_t gPttOnePushCounter = 0; uint32_t gBlinkCounter = 0; #endif diff --git a/misc.h b/misc.h index ad05906..f4a68fd 100644 --- a/misc.h +++ b/misc.h @@ -344,6 +344,7 @@ extern volatile uint8_t boot_counter_10ms; #ifdef ENABLE_FEAT_F4HWN extern bool gBackLight; + extern uint8_t gBacklightTimeOriginal; extern uint8_t gPttOnePushCounter; extern uint32_t gBlinkCounter; #endif diff --git a/ui/menu.c b/ui/menu.c index 5efc378..56d72a6 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -424,7 +424,6 @@ const t_sidefunction gSubMenu_SIDEFUNCTIONS[] = {"SWITCH\nRX MODE", ACTION_OPT_RXMODE}, {"SWITCH\nPTT", ACTION_OPT_PTT}, {"SWITCH\nWIDE\nNARROW", ACTION_OPT_WN}, - {"SWITCH\nBACKLIGHT", ACTION_OPT_BACKLIGHT}, #endif };