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_SLEEP ?= 1
ENABLE_FEAT_F4HWN_RESUME_STATE ?= 1 ENABLE_FEAT_F4HWN_RESUME_STATE ?= 1
ENABLE_FEAT_F4HWN_NARROWER ?= 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_RESCUE_OPS ?= 0
ENABLE_FEAT_F4HWN_VOL ?= 0 ENABLE_FEAT_F4HWN_VOL ?= 0
ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0 ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0
@@ -450,8 +451,11 @@ endif
ifeq ($(ENABLE_FEAT_F4HWN_NARROWER),1) ifeq ($(ENABLE_FEAT_F4HWN_NARROWER),1)
CFLAGS += -DENABLE_FEAT_F4HWN_NARROWER CFLAGS += -DENABLE_FEAT_F4HWN_NARROWER
endif endif
ifeq ($(ENABLE_FEAT_F4HWN_CONTRAST),1) ifeq ($(ENABLE_FEAT_F4HWN_INV),1)
CFLAGS += -DENABLE_FEAT_F4HWN_CONTRAST CFLAGS += -DENABLE_FEAT_F4HWN_INV
endif
ifeq ($(ENABLE_FEAT_F4HWN_CTR),1)
CFLAGS += -DENABLE_FEAT_F4HWN_CTR
endif endif
ifneq ($(filter $(ENABLE_FEAT_F4HWN_RESCUE_OPS),1 2),) ifneq ($(filter $(ENABLE_FEAT_F4HWN_RESCUE_OPS),1 2),)
CFLAGS += -DENABLE_FEAT_F4HWN_RESCUE_OPS=$(ENABLE_FEAT_F4HWN_RESCUE_OPS) 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) //if (gKeyReading1 != KEY_INVALID)
// gPttWasReleased = true; // gPttWasReleased = true;
} }
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv(); 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 #endif
APP_EndTransmission(); APP_EndTransmission();
@@ -1216,7 +1207,9 @@ static void CheckKeys(void)
if (gKeyReading1 != KEY_INVALID) if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true; gPttWasReleased = true;
gPttOnePushCounter = 0; gPttOnePushCounter = 0;
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv(); ST7565_ContrastAndInv();
#endif
} }
} }
else else
@@ -1236,7 +1229,9 @@ static void CheckKeys(void)
gPttIsPressed = false; gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID) if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true; gPttWasReleased = true;
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv(); ST7565_ContrastAndInv();
#endif
} }
} }
else else

View File

@@ -400,17 +400,19 @@ 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;
#ifdef ENABLE_FEAT_F4HWN_CONTRAST #ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR: case MENU_SET_CTR:
*pMin = 1; *pMin = 1;
*pMax = 15; *pMax = 15;
break; break;
#endif #endif
case MENU_TX_LOCK: case MENU_TX_LOCK:
#ifdef ENABLE_FEAT_F4HWN_INV
case MENU_SET_INV: case MENU_SET_INV:
//*pMin = 0; //*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1; *pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
break; break;
#endif
case MENU_SET_LCK: case MENU_SET_LCK:
//*pMin = 0; //*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_LCK) - 1; *pMax = ARRAY_SIZE(gSubMenu_SET_LCK) - 1;
@@ -928,7 +930,7 @@ void MENU_AcceptSetting(void)
case MENU_SET_EOT: case MENU_SET_EOT:
gSetting_set_eot = gSubMenuSelection; gSetting_set_eot = gSubMenuSelection;
break; break;
#ifdef ENABLE_FEAT_F4HWN_CONTRAST #ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR: case MENU_SET_CTR:
gSetting_set_ctr = gSubMenuSelection; gSetting_set_ctr = gSubMenuSelection;
break; break;
@@ -1381,7 +1383,7 @@ void MENU_ShowCurrentSetting(void)
case MENU_SET_EOT: case MENU_SET_EOT:
gSubMenuSelection = gSetting_set_eot; gSubMenuSelection = gSetting_set_eot;
break; break;
#ifdef ENABLE_FEAT_F4HWN_CONTRAST #ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR: case MENU_SET_CTR:
gSubMenuSelection = gSetting_set_ctr; gSubMenuSelection = gSetting_set_ctr;
break; break;

View File

@@ -75,6 +75,8 @@ voxless() {
ENABLE_FEAT_F4HWN_RESUME_STATE=0 \ ENABLE_FEAT_F4HWN_RESUME_STATE=0 \
ENABLE_FEAT_F4HWN_CHARGING_C=0 \ ENABLE_FEAT_F4HWN_CHARGING_C=0 \
ENABLE_FEAT_F4HWN_NARROWER=0 \ ENABLE_FEAT_F4HWN_NARROWER=0 \
ENABLE_FEAT_F4HWN_INV=0 \
ENABLE_FEAT_F4HWN_CTR=0 \
ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \ ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \
EDITION_STRING=Voxless \ EDITION_STRING=Voxless \
TARGET=f4hwn.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) void ST7565_ContrastAndInv(void)
{ {
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
@@ -219,6 +220,7 @@ uint8_t cmds[] = {
ST7565_Cmd(i); 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) { 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; 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); void ST7565_WriteByte(uint8_t Value);
#ifdef ENABLE_FEAT_F4HWN #ifdef ENABLE_FEAT_F4HWN
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
void ST7565_ContrastAndInv(void); void ST7565_ContrastAndInv(void);
#endif
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
void ST7565_Gauge(uint8_t line, uint8_t min, uint8_t max, uint8_t value); void ST7565_Gauge(uint8_t line, uint8_t min, uint8_t max, uint8_t value);
#endif #endif

View File

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

View File

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

View File

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