diff --git a/app/menu.c b/app/menu.c index d0cb7e8..44ad59f 100644 --- a/app/menu.c +++ b/app/menu.c @@ -378,6 +378,10 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_SET_TOT) - 1; break; + case MENU_SET_CTR: + *pMin = 0; + *pMax = 20; + break; #endif default: @@ -829,6 +833,9 @@ void MENU_AcceptSetting(void) gSetting_set_tot = gSubMenuSelection; gRequestSaveChannel = 1; break; + case MENU_SET_CTR: + gSetting_set_ctr = gSubMenuSelection; + break; #endif } @@ -1204,6 +1211,9 @@ void MENU_ShowCurrentSetting(void) case MENU_SET_TOT: gSubMenuSelection = gSetting_set_tot; break; + case MENU_SET_CTR: + gSubMenuSelection = gSetting_set_ctr; + break; #endif default: diff --git a/driver/st7565.c b/driver/st7565.c index c7070c1..dea3509 100644 --- a/driver/st7565.c +++ b/driver/st7565.c @@ -155,7 +155,16 @@ void ST7565_Init(void) SYSTEM_DelayMs(120); for(uint8_t i = 0; i < 8; i++) + { +#ifdef ENABLE_FEAT_F4HWN + if(i == 7) + ST7565_WriteByte(20 + gSetting_set_ctr); + else + ST7565_WriteByte(cmds[i]); +#else ST7565_WriteByte(cmds[i]); +#endif + } ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1 SYSTEM_DelayMs(1); @@ -175,6 +184,22 @@ void ST7565_Init(void) ST7565_FillScreen(0x00); } +#ifdef ENABLE_FEAT_F4HWN + void ST7565_Contrast(void) + { + SPI_ToggleMasterMode(&SPI0->CR, false); + ST7565_WriteByte(ST7565_CMD_SOFTWARE_RESET); // software reset + + for(uint8_t i = 0; i < 8; i++) + { + if(i == 7) + ST7565_WriteByte(20 + gSetting_set_ctr); + else + ST7565_WriteByte(cmds[i]); + } + } +#endif + void ST7565_FixInterfGlitch(void) { SPI_ToggleMasterMode(&SPI0->CR, false); diff --git a/driver/st7565.h b/driver/st7565.h index 69060bf..d29c2bd 100644 --- a/driver/st7565.h +++ b/driver/st7565.h @@ -38,5 +38,9 @@ void ST7565_HardwareReset(void); void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); void ST7565_WriteByte(uint8_t Value); +#ifdef ENABLE_FEAT_F4HWN + void ST7565_Contrast(void); +#endif + #endif diff --git a/misc.c b/misc.c index 6e6797e..56d65cc 100644 --- a/misc.c +++ b/misc.c @@ -99,6 +99,7 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; uint8_t gSetting_set_low; bool gSetting_set_ptt; uint8_t gSetting_set_tot; + uint8_t gSetting_set_ctr = 11; #endif #ifdef ENABLE_AUDIO_BAR diff --git a/misc.h b/misc.h index d02cbd6..3445317 100644 --- a/misc.h +++ b/misc.h @@ -160,6 +160,7 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx; extern uint8_t gSetting_set_low; extern bool gSetting_set_ptt; extern uint8_t gSetting_set_tot; + extern uint8_t gSetting_set_ctr; #endif #ifdef ENABLE_AUDIO_BAR diff --git a/settings.c b/settings.c index c83c780..2ce18f2 100644 --- a/settings.c +++ b/settings.c @@ -284,6 +284,7 @@ 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; #endif } @@ -604,6 +605,7 @@ void SETTINGS_SaveSettings(void) #ifdef ENABLE_FEAT_F4HWN memset(State, 0xFF, sizeof(State)); + State[4] = gSetting_set_ctr; 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 04c682e..cbcb8b1 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -129,6 +129,7 @@ const t_menu_item MenuList[] = {"SetLow", VOICE_ID_INVALID, MENU_SET_LOW }, {"SetPtt", VOICE_ID_INVALID, MENU_SET_PTT }, {"SetTot", VOICE_ID_INVALID, MENU_SET_TOT }, + {"SetCtr", VOICE_ID_INVALID, MENU_SET_CTR }, #endif // hidden menu items from here on // enabled if pressing both the PTT and upper side button at power-on @@ -899,6 +900,12 @@ void UI_DisplayMenu(void) case MENU_SET_TOT: strcpy(String, gSubMenu_SET_TOT[gSubMenuSelection]); break; + + case MENU_SET_CTR: + sprintf(String, "%d", gSubMenuSelection); + gSetting_set_ctr = gSubMenuSelection; + ST7565_Contrast(); + break; #endif } diff --git a/ui/menu.h b/ui/menu.h index 38e043a..33a4bbc 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -123,6 +123,7 @@ enum MENU_SET_LOW, MENU_SET_PTT, MENU_SET_TOT, + MENU_SET_CTR, #endif MENU_BATCAL, // battery voltage calibration MENU_F1SHRT, diff --git a/ui/welcome.c b/ui/welcome.c index 08d95bf..8426980 100644 --- a/ui/welcome.c +++ b/ui/welcome.c @@ -71,6 +71,7 @@ void UI_DisplayWelcome(void) UI_PrintString(WelcomeString1, 0, 127, 2, 10); #ifdef ENABLE_FEAT_F4HWN + ST7565_Contrast(); UI_PrintStringSmallNormal(Version, 0, 128, 5); UI_PrintStringSmallNormal(Feat, 0, 128, 6); #else