From ad3b8b5b9af6929efe493e96a5744176fc8362cc Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Mon, 11 Mar 2024 02:48:21 +0100 Subject: [PATCH] Add Switch BackLight action --- Makefile | 2 +- app/action.c | 15 +++++++++++++++ app/action.h | 1 + app/menu.c | 3 +++ bitmaps.c | 16 ++++++++++++---- bitmaps.h | 5 ++--- driver/backlight.c | 5 +++++ driver/backlight.h | 4 ++++ misc.c | 2 +- misc.h | 1 + settings.h | 1 + ui/menu.c | 1 + ui/status.c | 11 ++++++----- 13 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 33b5515..99e2310 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ ENABLE_COPY_CHAN_TO_VFO ?= 1 ENABLE_SPECTRUM ?= 1 ENABLE_REDUCE_LOW_MID_TX_POWER?= 0 ENABLE_BYP_RAW_DEMODULATORS ?= 0 -ENABLE_BLMIN_TMP_OFF ?= 1 +ENABLE_BLMIN_TMP_OFF ?= 0 ENABLE_SCAN_RANGES ?= 1 ENABLE_FEAT_F4HWN ?= 1 diff --git a/app/action.c b/app/action.c index cf93bf9..6c3a7f4 100644 --- a/app/action.c +++ b/app/action.c @@ -105,6 +105,7 @@ void (*action_opt_table[])(void) = { [ACTION_OPT_RXMODE] = &ACTION_RxMode, [ACTION_OPT_PTT] = &ACTION_Ptt, [ACTION_OPT_WN] = &ACTION_Wn, + [ACTION_OPT_BACKLIGHT] = &ACTION_BackLight, #else [ACTION_OPT_RXMODE] = &FUNCTION_NOP, #endif @@ -487,4 +488,18 @@ void ACTION_Wn(void) BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, false); #endif } + +void ACTION_BackLight(void) +{ + gBackLight = true; + 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 4dc7937..8aec306 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_BackLight(void); #endif void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); diff --git a/app/menu.c b/app/menu.c index ab5ab3c..78ca0b3 100644 --- a/app/menu.c +++ b/app/menu.c @@ -559,6 +559,9 @@ void MENU_AcceptSetting(void) case MENU_ABR: gEeprom.BACKLIGHT_TIME = gSubMenuSelection; + #ifdef ENABLE_FEAT_F4HWN + gBackLight = false; + #endif break; case MENU_ABR_MIN: diff --git a/bitmaps.c b/bitmaps.c index d6b3185..2adcfad 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -58,12 +58,20 @@ const uint8_t gFontScanAll[10] = 0b00111110 }; -/* -const uint8_t gFontF[1][7] = +const uint8_t gFontLight[11] = { - {0x7f, 0x7f, 0x41, 0x75, 0x75, 0x7f, 0x7f}, + 0b00000000, + 0b00011100, + 0b00100010, + 0b01000001, + 0b01001101, + 0b01110001, + 0b01001101, + 0b01000001, + 0b00100010, + 0b00011100, + 0b00000000, }; -*/ const uint8_t gFontXB[2][6] = { // "XB" diff --git a/bitmaps.h b/bitmaps.h index 8db1421..ffca734 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -12,9 +12,8 @@ extern const uint8_t gFontPttClassic[2][6]; extern const uint8_t gFontFM[2][6]; extern const uint8_t gFontKeyLock[1][8]; extern const uint8_t gFontScanAll[10]; -/* -extern const uint8_t gFontF[1][7]; -*/ +extern const uint8_t gFontLight[11]; + extern const uint8_t gFontXB[2][6]; extern const uint8_t gFontMO[2][6]; extern const uint8_t gFontDWR[3][6]; diff --git a/driver/backlight.c b/driver/backlight.c index 8705a01..da1132e 100644 --- a/driver/backlight.c +++ b/driver/backlight.c @@ -24,6 +24,7 @@ #ifdef ENABLE_FEAT_F4HWN #include "driver/system.h" #include "audio.h" + uint8_t gBacklightBrightnessOld = 0; #endif // this is decremented once every 500ms @@ -59,6 +60,10 @@ void BACKLIGHT_InitHardware() void BACKLIGHT_TurnOn(void) { + #ifdef ENABLE_FEAT_F4HWN + gBacklightBrightnessOld = BACKLIGHT_GetBrightness(); + #endif + if (gEeprom.BACKLIGHT_TIME == 0) { BACKLIGHT_TurnOff(); return; diff --git a/driver/backlight.h b/driver/backlight.h index ae3b268..f0688a6 100644 --- a/driver/backlight.h +++ b/driver/backlight.h @@ -38,4 +38,8 @@ bool BACKLIGHT_IsOn(); void BACKLIGHT_SetBrightness(uint8_t brigtness); uint8_t BACKLIGHT_GetBrightness(void); +#ifdef ENABLE_FEAT_F4HWN + extern uint8_t gBacklightBrightnessOld; +#endif + #endif diff --git a/misc.c b/misc.c index 9d34549..2d84bd0 100644 --- a/misc.c +++ b/misc.c @@ -276,7 +276,7 @@ uint8_t gIsLocked = 0xFF; #ifdef ENABLE_FEAT_F4HWN - bool gPttOnePush = true; + bool gBackLight = false; uint8_t gPttOnePushCounter = 0; uint32_t gBlinkCounter = 0; #endif diff --git a/misc.h b/misc.h index 7ed63c6..ad05906 100644 --- a/misc.h +++ b/misc.h @@ -343,6 +343,7 @@ extern uint8_t gIsLocked; extern volatile uint8_t boot_counter_10ms; #ifdef ENABLE_FEAT_F4HWN + extern bool gBackLight; extern uint8_t gPttOnePushCounter; extern uint32_t gBlinkCounter; #endif diff --git a/settings.h b/settings.h index d0d6b97..6ae4e87 100644 --- a/settings.h +++ b/settings.h @@ -99,6 +99,7 @@ enum ACTION_OPT_t { ACTION_OPT_RXMODE, ACTION_OPT_PTT, ACTION_OPT_WN, + ACTION_OPT_BACKLIGHT, #endif ACTION_OPT_LEN }; diff --git a/ui/menu.c b/ui/menu.c index 56d72a6..5efc378 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -424,6 +424,7 @@ 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 }; diff --git a/ui/status.c b/ui/status.c index b267d37..6c4ea3f 100644 --- a/ui/status.c +++ b/ui/status.c @@ -160,11 +160,6 @@ void UI_DisplayStatus() x1 = x; } else if (gWasFKeyPressed) { - /* - memcpy(line + x, gFontF, sizeof(gFontF)); - x += sizeof(gFontF); - */ - UI_PrintStringSmallBufferNormal("F", line + x + 1); x += sizeof(gFontKeyLock); @@ -174,6 +169,12 @@ void UI_DisplayStatus() } x1 = x; } + else if(gBackLight) + { + memcpy(line + x + 1, gFontLight, sizeof(gFontLight)); + x += sizeof(gFontLight); + x1 = x; + } { // battery voltage or percentage char s[8] = "";