ENABLE_FEAT_F4HWN_CTR and ENABLE_FEAT_F4HWN_INV refactoring

This commit is contained in:
Armel FAUVEAU
2025-02-16 05:05:19 +01:00
parent 6e35a63b05
commit 684d330965
10 changed files with 62 additions and 41 deletions

View File

@@ -48,7 +48,8 @@ ENABLE_FEAT_F4HWN_CHARGING_C ?= 0
ENABLE_FEAT_F4HWN_SLEEP ?= 1
ENABLE_FEAT_F4HWN_RESUME_STATE ?= 1
ENABLE_FEAT_F4HWN_NARROWER ?= 1
ENABLE_FEAT_F4HWN_CONTRAST ?= 1
ENABLE_FEAT_F4HWN_INV ?= 1
ENABLE_FEAT_F4HWN_CTR ?= 1
ENABLE_FEAT_F4HWN_RESCUE_OPS ?= 0
ENABLE_FEAT_F4HWN_VOL ?= 0
ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0
@@ -450,8 +451,11 @@ endif
ifeq ($(ENABLE_FEAT_F4HWN_NARROWER),1)
CFLAGS += -DENABLE_FEAT_F4HWN_NARROWER
endif
ifeq ($(ENABLE_FEAT_F4HWN_CONTRAST),1)
CFLAGS += -DENABLE_FEAT_F4HWN_CONTRAST
ifeq ($(ENABLE_FEAT_F4HWN_INV),1)
CFLAGS += -DENABLE_FEAT_F4HWN_INV
endif
ifeq ($(ENABLE_FEAT_F4HWN_CTR),1)
CFLAGS += -DENABLE_FEAT_F4HWN_CTR
endif
ifneq ($(filter $(ENABLE_FEAT_F4HWN_RESCUE_OPS),1 2),)
CFLAGS += -DENABLE_FEAT_F4HWN_RESCUE_OPS=$(ENABLE_FEAT_F4HWN_RESCUE_OPS)

View File

@@ -969,19 +969,10 @@ void APP_Update(void)
//if (gKeyReading1 != KEY_INVALID)
// gPttWasReleased = true;
}
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
}
/*
if (gSetting_set_ptt_session) // Improve OnePush if TOT
{
ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
gPttOnePushCounter = 0;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
ST7565_ContrastAndInv();
}
*/
#endif
APP_EndTransmission();
@@ -1216,7 +1207,9 @@ static void CheckKeys(void)
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
gPttOnePushCounter = 0;
ST7565_ContrastAndInv();
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
}
}
else
@@ -1236,7 +1229,9 @@ static void CheckKeys(void)
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
}
}
else

View File

@@ -400,17 +400,19 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_TOT) - 1;
break;
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
#ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR:
*pMin = 1;
*pMax = 15;
break;
#endif
case MENU_TX_LOCK:
#ifdef ENABLE_FEAT_F4HWN_INV
case MENU_SET_INV:
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
break;
#endif
case MENU_SET_LCK:
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_LCK) - 1;
@@ -928,7 +930,7 @@ void MENU_AcceptSetting(void)
case MENU_SET_EOT:
gSetting_set_eot = gSubMenuSelection;
break;
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
#ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR:
gSetting_set_ctr = gSubMenuSelection;
break;
@@ -1381,7 +1383,7 @@ void MENU_ShowCurrentSetting(void)
case MENU_SET_EOT:
gSubMenuSelection = gSetting_set_eot;
break;
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
#ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR:
gSubMenuSelection = gSetting_set_ctr;
break;

View File

@@ -75,6 +75,8 @@ voxless() {
ENABLE_FEAT_F4HWN_RESUME_STATE=0 \
ENABLE_FEAT_F4HWN_CHARGING_C=0 \
ENABLE_FEAT_F4HWN_NARROWER=0 \
ENABLE_FEAT_F4HWN_INV=0 \
ENABLE_FEAT_F4HWN_CTR=0 \
ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \
EDITION_STRING=Voxless \
TARGET=f4hwn.voxless \

View File

@@ -209,6 +209,7 @@ uint8_t cmds[] = {
}
}
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
void ST7565_ContrastAndInv(void)
{
SPI_ToggleMasterMode(&SPI0->CR, false);
@@ -219,6 +220,7 @@ uint8_t cmds[] = {
ST7565_Cmd(i);
}
}
#endif
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

View File

@@ -42,7 +42,9 @@ void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
void ST7565_WriteByte(uint8_t Value);
#ifdef ENABLE_FEAT_F4HWN
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
void ST7565_ContrastAndInv(void);
#endif
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
void ST7565_Gauge(uint8_t line, uint8_t min, uint8_t max, uint8_t value);
#endif

View File

@@ -363,12 +363,16 @@ void SETTINGS_InitEEPROM(void)
int tmp = (Data[5] & 0xF0) >> 4;
#ifdef ENABLE_FEAT_F4HWN_INV
gSetting_set_inv = (tmp >> 0) & 0x01;
#else
gSetting_set_inv = 0;
#endif
gSetting_set_lck = (tmp >> 1) & 0x01;
gSetting_set_met = (tmp >> 2) & 0x01;
gSetting_set_gui = (tmp >> 3) & 0x01;
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
#ifdef ENABLE_FEAT_F4HWN_CTR
int ctr_value = Data[5] & 0x0F;
gSetting_set_ctr = (ctr_value > 0 && ctr_value < 16) ? ctr_value : 10;
#else

View File

@@ -139,9 +139,7 @@ const t_menu_item MenuList[] =
{"SetPTT", MENU_SET_PTT },
{"SetTOT", MENU_SET_TOT },
{"SetEOT", MENU_SET_EOT },
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
{"SetCtr", MENU_SET_CTR },
#endif
{"SetInv", MENU_SET_INV },
{"SetLck", MENU_SET_LCK },
{"SetMet", MENU_SET_MET },
@@ -218,6 +216,11 @@ const char gSubMenu_OFF_ON[][4] =
"ON"
};
const char gSubMenu_NA[4] =
{
"N/A"
};
const char* const gSubMenu_RXMode[] =
{
"MAIN\nONLY", // TX and RX on main only
@@ -618,7 +621,7 @@ void UI_DisplayMenu(void)
#ifdef ENABLE_AUDIO_BAR
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
#else
strcpy(String, gSubMenu_OFF_ON[0]);
strcpy(String, gSubMenu_NA);
#endif
break;
@@ -642,7 +645,7 @@ void UI_DisplayMenu(void)
case MENU_R_DCS:
case MENU_T_DCS:
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
strcpy(String, gSubMenu_OFF_ON[0]);
else if (gSubMenuSelection < 105)
sprintf(String, "D%03oN", DCS_Options[gSubMenuSelection - 1]);
else
@@ -653,7 +656,7 @@ void UI_DisplayMenu(void)
case MENU_T_CTCS:
{
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
strcpy(String, gSubMenu_OFF_ON[0]);
else
sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10);
break;
@@ -699,16 +702,16 @@ void UI_DisplayMenu(void)
case MENU_VOX:
#ifdef ENABLE_VOX
sprintf(String, gSubMenuSelection == 0 ? "OFF" : "%u", gSubMenuSelection);
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%u", gSubMenuSelection);
#else
strcpy(String, gSubMenu_OFF_ON[0]);
strcpy(String, gSubMenu_NA);
#endif
break;
case MENU_ABR:
if(gSubMenuSelection == 0)
{
strcpy(String, "OFF");
strcpy(String, gSubMenu_OFF_ON[0]);
}
else if(gSubMenuSelection < 61)
{
@@ -743,7 +746,7 @@ void UI_DisplayMenu(void)
case MENU_AUTOLK:
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
strcpy(String, gSubMenu_OFF_ON[0]);
else
{
sprintf(String, "%02dm:%02ds", ((gSubMenuSelection * 15) / 60), ((gSubMenuSelection * 15) % 60));
@@ -855,7 +858,7 @@ void UI_DisplayMenu(void)
}
case MENU_SAVE:
sprintf(String, gSubMenuSelection == 0 ? "OFF" : "1:%u", gSubMenuSelection);
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "1:%u", gSubMenuSelection);
break;
case MENU_TDR:
@@ -901,7 +904,7 @@ void UI_DisplayMenu(void)
break;
case MENU_RP_STE:
sprintf(String, gSubMenuSelection == 0 ? "OFF" : "%u*100ms", gSubMenuSelection);
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%u*100ms", gSubMenuSelection);
break;
case MENU_S_LIST:
@@ -1039,7 +1042,7 @@ void UI_DisplayMenu(void)
case MENU_SET_OFF:
if(gSubMenuSelection == 0)
{
strcpy(String, "OFF");
strcpy(String, gSubMenu_OFF_ON[0]);
}
else if(gSubMenuSelection < 121)
{
@@ -1065,17 +1068,23 @@ void UI_DisplayMenu(void)
strcpy(String, gSubMenu_SET_TOT[gSubMenuSelection]); // Same as SET_TOT
break;
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
case MENU_SET_CTR:
sprintf(String, "%d", gSubMenuSelection);
gSetting_set_ctr = gSubMenuSelection;
ST7565_ContrastAndInv();
#ifdef ENABLE_FEAT_F4HWN_CTR
sprintf(String, "%d", gSubMenuSelection);
gSetting_set_ctr = gSubMenuSelection;
ST7565_ContrastAndInv();
#else
strcpy(String, gSubMenu_NA);
#endif
break;
#endif
case MENU_SET_INV:
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
ST7565_ContrastAndInv();
#ifdef ENABLE_FEAT_F4HWN_INV
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
ST7565_ContrastAndInv();
#else
strcpy(String, gSubMenu_NA);
#endif
break;
case MENU_TX_LOCK:
@@ -1108,7 +1117,7 @@ void UI_DisplayMenu(void)
case MENU_SET_VOL:
if(gSubMenuSelection == 0)
{
strcpy(String, "OFF");
strcpy(String, gSubMenu_OFF_ON[0]);
}
else if(gSubMenuSelection < 64)
{

View File

@@ -168,6 +168,7 @@ extern const char gSubMenu_TXP[8][6];
extern const char gSubMenu_SFT_D[3][4];
extern const char gSubMenu_W_N[2][7];
extern const char gSubMenu_OFF_ON[2][4];
extern const char gSubMenu_NA[4];
extern const char gSubMenu_TOT[11][7];
extern const char* const gSubMenu_RXMode[4];

View File

@@ -31,7 +31,7 @@
void UI_DisplayReleaseKeys(void)
{
memset(gStatusLine, 0, sizeof(gStatusLine));
#ifdef ENABLE_FEAT_F4HWN
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
UI_DisplayClear();
@@ -52,7 +52,7 @@ void UI_DisplayWelcome(void)
memset(gStatusLine, 0, sizeof(gStatusLine));
#ifdef ENABLE_FEAT_F4HWN
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
UI_DisplayClear();