Add Contrast feature

This commit is contained in:
Armel FAUVEAU
2024-02-03 05:50:00 +01:00
parent 4b7dd4bdde
commit e8760bda5f
9 changed files with 52 additions and 0 deletions

View File

@@ -378,6 +378,10 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_TOT) - 1; *pMax = ARRAY_SIZE(gSubMenu_SET_TOT) - 1;
break; break;
case MENU_SET_CTR:
*pMin = 0;
*pMax = 20;
break;
#endif #endif
default: default:
@@ -829,6 +833,9 @@ void MENU_AcceptSetting(void)
gSetting_set_tot = gSubMenuSelection; gSetting_set_tot = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
break; break;
case MENU_SET_CTR:
gSetting_set_ctr = gSubMenuSelection;
break;
#endif #endif
} }
@@ -1204,6 +1211,9 @@ void MENU_ShowCurrentSetting(void)
case MENU_SET_TOT: case MENU_SET_TOT:
gSubMenuSelection = gSetting_set_tot; gSubMenuSelection = gSetting_set_tot;
break; break;
case MENU_SET_CTR:
gSubMenuSelection = gSetting_set_ctr;
break;
#endif #endif
default: default:

View File

@@ -155,7 +155,16 @@ void ST7565_Init(void)
SYSTEM_DelayMs(120); SYSTEM_DelayMs(120);
for(uint8_t i = 0; i < 8; i++) 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]); ST7565_WriteByte(cmds[i]);
#endif
}
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1 ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1
SYSTEM_DelayMs(1); SYSTEM_DelayMs(1);
@@ -175,6 +184,22 @@ void ST7565_Init(void)
ST7565_FillScreen(0x00); 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) void ST7565_FixInterfGlitch(void)
{ {
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);

View File

@@ -38,5 +38,9 @@ void ST7565_HardwareReset(void);
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
void ST7565_WriteByte(uint8_t Value); void ST7565_WriteByte(uint8_t Value);
#ifdef ENABLE_FEAT_F4HWN
void ST7565_Contrast(void);
#endif
#endif #endif

1
misc.c
View File

@@ -99,6 +99,7 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
uint8_t gSetting_set_low; uint8_t gSetting_set_low;
bool gSetting_set_ptt; bool gSetting_set_ptt;
uint8_t gSetting_set_tot; uint8_t gSetting_set_tot;
uint8_t gSetting_set_ctr = 11;
#endif #endif
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR

1
misc.h
View File

@@ -160,6 +160,7 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
extern uint8_t gSetting_set_low; extern uint8_t gSetting_set_low;
extern bool gSetting_set_ptt; extern bool gSetting_set_ptt;
extern uint8_t gSetting_set_tot; extern uint8_t gSetting_set_tot;
extern uint8_t gSetting_set_ctr;
#endif #endif
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR

View File

@@ -284,6 +284,7 @@ void SETTINGS_InitEEPROM(void)
gSetting_set_low = (Data[7] < 5) ? Data[7] : 0; gSetting_set_low = (Data[7] < 5) ? Data[7] : 0;
gSetting_set_ptt = (Data[6] < 2) ? Data[6] : 0; gSetting_set_ptt = (Data[6] < 2) ? Data[6] : 0;
gSetting_set_tot = (Data[5] < 4) ? Data[5] : 0; gSetting_set_tot = (Data[5] < 4) ? Data[5] : 0;
gSetting_set_ctr = (Data[4] < 21) ? Data[4] : 11;
#endif #endif
} }
@@ -604,6 +605,7 @@ void SETTINGS_SaveSettings(void)
#ifdef ENABLE_FEAT_F4HWN #ifdef ENABLE_FEAT_F4HWN
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
State[4] = gSetting_set_ctr;
State[5] = gSetting_set_tot; State[5] = gSetting_set_tot;
State[6] = gSetting_set_ptt; State[6] = gSetting_set_ptt;
State[7] = gSetting_set_low; State[7] = gSetting_set_low;

View File

@@ -129,6 +129,7 @@ const t_menu_item MenuList[] =
{"SetLow", VOICE_ID_INVALID, MENU_SET_LOW }, {"SetLow", VOICE_ID_INVALID, MENU_SET_LOW },
{"SetPtt", VOICE_ID_INVALID, MENU_SET_PTT }, {"SetPtt", VOICE_ID_INVALID, MENU_SET_PTT },
{"SetTot", VOICE_ID_INVALID, MENU_SET_TOT }, {"SetTot", VOICE_ID_INVALID, MENU_SET_TOT },
{"SetCtr", VOICE_ID_INVALID, MENU_SET_CTR },
#endif #endif
// hidden menu items from here on // hidden menu items from here on
// enabled if pressing both the PTT and upper side button at power-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: case MENU_SET_TOT:
strcpy(String, gSubMenu_SET_TOT[gSubMenuSelection]); strcpy(String, gSubMenu_SET_TOT[gSubMenuSelection]);
break; break;
case MENU_SET_CTR:
sprintf(String, "%d", gSubMenuSelection);
gSetting_set_ctr = gSubMenuSelection;
ST7565_Contrast();
break;
#endif #endif
} }

View File

@@ -123,6 +123,7 @@ enum
MENU_SET_LOW, MENU_SET_LOW,
MENU_SET_PTT, MENU_SET_PTT,
MENU_SET_TOT, MENU_SET_TOT,
MENU_SET_CTR,
#endif #endif
MENU_BATCAL, // battery voltage calibration MENU_BATCAL, // battery voltage calibration
MENU_F1SHRT, MENU_F1SHRT,

View File

@@ -71,6 +71,7 @@ void UI_DisplayWelcome(void)
UI_PrintString(WelcomeString1, 0, 127, 2, 10); UI_PrintString(WelcomeString1, 0, 127, 2, 10);
#ifdef ENABLE_FEAT_F4HWN #ifdef ENABLE_FEAT_F4HWN
ST7565_Contrast();
UI_PrintStringSmallNormal(Version, 0, 128, 5); UI_PrintStringSmallNormal(Version, 0, 128, 5);
UI_PrintStringSmallNormal(Feat, 0, 128, 6); UI_PrintStringSmallNormal(Feat, 0, 128, 6);
#else #else