From 89d308293f7107e7e2237b504fe3e924157350ae Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Tue, 6 Feb 2024 05:00:55 +0100 Subject: [PATCH] Add SetInv menu --- app/menu.c | 13 +++++++++++-- driver/st7565.c | 8 ++++++-- misc.c | 1 + misc.h | 1 + settings.c | 8 ++++++-- ui/menu.c | 8 +++++++- ui/menu.h | 1 + 7 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/menu.c b/app/menu.c index b36adf0..c5e0067 100644 --- a/app/menu.c +++ b/app/menu.c @@ -249,11 +249,10 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) case MENU_350EN: #ifndef ENABLE_FEAT_F4HWN case MENU_SCREN: +#endif *pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1; break; -#endif - case MENU_AM: *pMin = 0; *pMax = ARRAY_SIZE(gModulationStr) - 1; @@ -384,6 +383,10 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMin = 0; *pMax = 20; break; + case MENU_SET_INV: + *pMin = 0; + *pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1; + break; #endif default: @@ -848,6 +851,9 @@ void MENU_AcceptSetting(void) case MENU_SET_CTR: gSetting_set_ctr = gSubMenuSelection; break; + case MENU_SET_INV: + gSetting_set_inv = gSubMenuSelection; + break; #endif } @@ -1232,6 +1238,9 @@ void MENU_ShowCurrentSetting(void) case MENU_SET_CTR: gSubMenuSelection = gSetting_set_ctr; break; + case MENU_SET_INV: + gSubMenuSelection = gSetting_set_inv; + break; #endif default: diff --git a/driver/st7565.c b/driver/st7565.c index dea3509..f9a8645 100644 --- a/driver/st7565.c +++ b/driver/st7565.c @@ -157,7 +157,9 @@ void ST7565_Init(void) for(uint8_t i = 0; i < 8; i++) { #ifdef ENABLE_FEAT_F4HWN - if(i == 7) + if(i == 3) + ST7565_WriteByte(ST7565_CMD_INVERSE_DISPLAY | gSetting_set_inv); + else if(i == 7) ST7565_WriteByte(20 + gSetting_set_ctr); else ST7565_WriteByte(cmds[i]); @@ -192,7 +194,9 @@ void ST7565_Init(void) for(uint8_t i = 0; i < 8; i++) { - if(i == 7) + if(i == 3) + ST7565_WriteByte(ST7565_CMD_INVERSE_DISPLAY | gSetting_set_inv); + else if(i == 7) ST7565_WriteByte(20 + gSetting_set_ctr); else ST7565_WriteByte(cmds[i]); diff --git a/misc.c b/misc.c index c81338b..9339dbf 100644 --- a/misc.c +++ b/misc.c @@ -100,6 +100,7 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; bool gSetting_set_ptt; uint8_t gSetting_set_tot; uint8_t gSetting_set_ctr = 11; + bool gSetting_set_inv = false; bool gSetting_set_ptt_session; uint8_t gSetting_set_dual_watch_session; uint8_t gSetting_set_cross_band_RX_TX_session; diff --git a/misc.h b/misc.h index 2b55605..02f177b 100644 --- a/misc.h +++ b/misc.h @@ -161,6 +161,7 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; extern bool gSetting_set_ptt; extern uint8_t gSetting_set_tot; extern uint8_t gSetting_set_ctr; + extern bool gSetting_set_inv; extern bool gSetting_set_ptt_session; extern uint8_t gSetting_set_dual_watch_session; extern uint8_t gSetting_set_cross_band_RX_TX_session; diff --git a/settings.c b/settings.c index 0572591..fb554d8 100644 --- a/settings.c +++ b/settings.c @@ -284,7 +284,10 @@ void SETTINGS_InitEEPROM(void) gSetting_set_low = (Data[7] < 5) ? Data[7] : 0; gSetting_set_ptt = (Data[6] < 2) ? Data[6] : 0; gSetting_set_tot = (Data[5] < 4) ? Data[5] : 0; - gSetting_set_ctr = (Data[4] < 21) ? Data[4] : 11; + uint8_t inv = (Data[4] & 0xF0) >> 4; + uint8_t ctr = (Data[4] & 0x0F); + gSetting_set_inv = (inv < 2) ? inv : 0; + gSetting_set_ctr = (ctr < 21) ? ctr : 11; // And set special session settings for actions gSetting_set_ptt_session = gSetting_set_ptt; @@ -609,7 +612,8 @@ void SETTINGS_SaveSettings(void) #ifdef ENABLE_FEAT_F4HWN memset(State, 0xFF, sizeof(State)); - State[4] = gSetting_set_ctr; + + State[4] = ((gSetting_set_inv << 4) | (gSetting_set_ctr & 0x0F)); State[5] = gSetting_set_tot; State[6] = gSetting_set_ptt; State[7] = gSetting_set_low; diff --git a/ui/menu.c b/ui/menu.c index 1efea11..c284db8 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -130,6 +130,7 @@ const t_menu_item MenuList[] = {"SetPtt", VOICE_ID_INVALID, MENU_SET_PTT }, {"SetTot", VOICE_ID_INVALID, MENU_SET_TOT }, {"SetCtr", VOICE_ID_INVALID, MENU_SET_CTR }, + {"SetInv", VOICE_ID_INVALID, MENU_SET_INV }, #endif // hidden menu items from here on // enabled if pressing both the PTT and upper side button at power-on @@ -683,9 +684,9 @@ void UI_DisplayMenu(void) case MENU_350EN: #ifndef ENABLE_FEAT_F4HWN case MENU_SCREN: +#endif strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); break; -#endif case MENU_MEM_CH: case MENU_1_CALL: @@ -911,6 +912,11 @@ void UI_DisplayMenu(void) gSetting_set_ctr = gSubMenuSelection; ST7565_Contrast(); break; + + case MENU_SET_INV: + strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); + ST7565_Contrast(); + break; #endif } diff --git a/ui/menu.h b/ui/menu.h index e1d373e..5996fcb 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -126,6 +126,7 @@ enum MENU_SET_PTT, MENU_SET_TOT, MENU_SET_CTR, + MENU_SET_INV, #endif MENU_BATCAL, // battery voltage calibration MENU_F1SHRT,