Skip to content

Commit 684d330

Browse files
committed
ENABLE_FEAT_F4HWN_CTR and ENABLE_FEAT_F4HWN_INV refactoring
1 parent 6e35a63 commit 684d330

File tree

10 files changed

+62
-41
lines changed

10 files changed

+62
-41
lines changed

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ ENABLE_FEAT_F4HWN_CHARGING_C ?= 0
4848
ENABLE_FEAT_F4HWN_SLEEP ?= 1
4949
ENABLE_FEAT_F4HWN_RESUME_STATE ?= 1
5050
ENABLE_FEAT_F4HWN_NARROWER ?= 1
51-
ENABLE_FEAT_F4HWN_CONTRAST ?= 1
51+
ENABLE_FEAT_F4HWN_INV ?= 1
52+
ENABLE_FEAT_F4HWN_CTR ?= 1
5253
ENABLE_FEAT_F4HWN_RESCUE_OPS ?= 0
5354
ENABLE_FEAT_F4HWN_VOL ?= 0
5455
ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0
@@ -450,8 +451,11 @@ endif
450451
ifeq ($(ENABLE_FEAT_F4HWN_NARROWER),1)
451452
CFLAGS += -DENABLE_FEAT_F4HWN_NARROWER
452453
endif
453-
ifeq ($(ENABLE_FEAT_F4HWN_CONTRAST),1)
454-
CFLAGS += -DENABLE_FEAT_F4HWN_CONTRAST
454+
ifeq ($(ENABLE_FEAT_F4HWN_INV),1)
455+
CFLAGS += -DENABLE_FEAT_F4HWN_INV
456+
endif
457+
ifeq ($(ENABLE_FEAT_F4HWN_CTR),1)
458+
CFLAGS += -DENABLE_FEAT_F4HWN_CTR
455459
endif
456460
ifneq ($(filter $(ENABLE_FEAT_F4HWN_RESCUE_OPS),1 2),)
457461
CFLAGS += -DENABLE_FEAT_F4HWN_RESCUE_OPS=$(ENABLE_FEAT_F4HWN_RESCUE_OPS)

app/app.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -969,19 +969,10 @@ void APP_Update(void)
969969
//if (gKeyReading1 != KEY_INVALID)
970970
// gPttWasReleased = true;
971971
}
972+
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
972973
ST7565_ContrastAndInv();
974+
#endif
973975
}
974-
/*
975-
if (gSetting_set_ptt_session) // Improve OnePush if TOT
976-
{
977-
ProcessKey(KEY_PTT, false, false);
978-
gPttIsPressed = false;
979-
gPttOnePushCounter = 0;
980-
if (gKeyReading1 != KEY_INVALID)
981-
gPttWasReleased = true;
982-
ST7565_ContrastAndInv();
983-
}
984-
*/
985976
#endif
986977

987978
APP_EndTransmission();
@@ -1216,7 +1207,9 @@ static void CheckKeys(void)
12161207
if (gKeyReading1 != KEY_INVALID)
12171208
gPttWasReleased = true;
12181209
gPttOnePushCounter = 0;
1219-
ST7565_ContrastAndInv();
1210+
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
1211+
ST7565_ContrastAndInv();
1212+
#endif
12201213
}
12211214
}
12221215
else
@@ -1236,7 +1229,9 @@ static void CheckKeys(void)
12361229
gPttIsPressed = false;
12371230
if (gKeyReading1 != KEY_INVALID)
12381231
gPttWasReleased = true;
1232+
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
12391233
ST7565_ContrastAndInv();
1234+
#endif
12401235
}
12411236
}
12421237
else

app/menu.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,19 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
400400
//*pMin = 0;
401401
*pMax = ARRAY_SIZE(gSubMenu_SET_TOT) - 1;
402402
break;
403-
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
403+
#ifdef ENABLE_FEAT_F4HWN_CTR
404404
case MENU_SET_CTR:
405405
*pMin = 1;
406406
*pMax = 15;
407407
break;
408408
#endif
409409
case MENU_TX_LOCK:
410+
#ifdef ENABLE_FEAT_F4HWN_INV
410411
case MENU_SET_INV:
411412
//*pMin = 0;
412413
*pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1;
413414
break;
415+
#endif
414416
case MENU_SET_LCK:
415417
//*pMin = 0;
416418
*pMax = ARRAY_SIZE(gSubMenu_SET_LCK) - 1;
@@ -928,7 +930,7 @@ void MENU_AcceptSetting(void)
928930
case MENU_SET_EOT:
929931
gSetting_set_eot = gSubMenuSelection;
930932
break;
931-
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
933+
#ifdef ENABLE_FEAT_F4HWN_CTR
932934
case MENU_SET_CTR:
933935
gSetting_set_ctr = gSubMenuSelection;
934936
break;
@@ -1381,7 +1383,7 @@ void MENU_ShowCurrentSetting(void)
13811383
case MENU_SET_EOT:
13821384
gSubMenuSelection = gSetting_set_eot;
13831385
break;
1384-
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
1386+
#ifdef ENABLE_FEAT_F4HWN_CTR
13851387
case MENU_SET_CTR:
13861388
gSubMenuSelection = gSetting_set_ctr;
13871389
break;

compile-with-docker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ voxless() {
7575
ENABLE_FEAT_F4HWN_RESUME_STATE=0 \
7676
ENABLE_FEAT_F4HWN_CHARGING_C=0 \
7777
ENABLE_FEAT_F4HWN_NARROWER=0 \
78+
ENABLE_FEAT_F4HWN_INV=0 \
79+
ENABLE_FEAT_F4HWN_CTR=0 \
7880
ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \
7981
EDITION_STRING=Voxless \
8082
TARGET=f4hwn.voxless \

driver/st7565.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ uint8_t cmds[] = {
209209
}
210210
}
211211

212+
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
212213
void ST7565_ContrastAndInv(void)
213214
{
214215
SPI_ToggleMasterMode(&SPI0->CR, false);
@@ -219,6 +220,7 @@ uint8_t cmds[] = {
219220
ST7565_Cmd(i);
220221
}
221222
}
223+
#endif
222224

223225
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max) {
224226
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

driver/st7565.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
4242
void ST7565_WriteByte(uint8_t Value);
4343

4444
#ifdef ENABLE_FEAT_F4HWN
45+
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
4546
void ST7565_ContrastAndInv(void);
47+
#endif
4648
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
4749
void ST7565_Gauge(uint8_t line, uint8_t min, uint8_t max, uint8_t value);
4850
#endif

settings.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,16 @@ void SETTINGS_InitEEPROM(void)
363363

364364
int tmp = (Data[5] & 0xF0) >> 4;
365365

366+
#ifdef ENABLE_FEAT_F4HWN_INV
366367
gSetting_set_inv = (tmp >> 0) & 0x01;
368+
#else
369+
gSetting_set_inv = 0;
370+
#endif
367371
gSetting_set_lck = (tmp >> 1) & 0x01;
368372
gSetting_set_met = (tmp >> 2) & 0x01;
369373
gSetting_set_gui = (tmp >> 3) & 0x01;
370374

371-
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
375+
#ifdef ENABLE_FEAT_F4HWN_CTR
372376
int ctr_value = Data[5] & 0x0F;
373377
gSetting_set_ctr = (ctr_value > 0 && ctr_value < 16) ? ctr_value : 10;
374378
#else

ui/menu.c

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ const t_menu_item MenuList[] =
139139
{"SetPTT", MENU_SET_PTT },
140140
{"SetTOT", MENU_SET_TOT },
141141
{"SetEOT", MENU_SET_EOT },
142-
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
143142
{"SetCtr", MENU_SET_CTR },
144-
#endif
145143
{"SetInv", MENU_SET_INV },
146144
{"SetLck", MENU_SET_LCK },
147145
{"SetMet", MENU_SET_MET },
@@ -218,6 +216,11 @@ const char gSubMenu_OFF_ON[][4] =
218216
"ON"
219217
};
220218

219+
const char gSubMenu_NA[4] =
220+
{
221+
"N/A"
222+
};
223+
221224
const char* const gSubMenu_RXMode[] =
222225
{
223226
"MAIN\nONLY", // TX and RX on main only
@@ -618,7 +621,7 @@ void UI_DisplayMenu(void)
618621
#ifdef ENABLE_AUDIO_BAR
619622
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
620623
#else
621-
strcpy(String, gSubMenu_OFF_ON[0]);
624+
strcpy(String, gSubMenu_NA);
622625
#endif
623626
break;
624627

@@ -642,7 +645,7 @@ void UI_DisplayMenu(void)
642645
case MENU_R_DCS:
643646
case MENU_T_DCS:
644647
if (gSubMenuSelection == 0)
645-
strcpy(String, "OFF");
648+
strcpy(String, gSubMenu_OFF_ON[0]);
646649
else if (gSubMenuSelection < 105)
647650
sprintf(String, "D%03oN", DCS_Options[gSubMenuSelection - 1]);
648651
else
@@ -653,7 +656,7 @@ void UI_DisplayMenu(void)
653656
case MENU_T_CTCS:
654657
{
655658
if (gSubMenuSelection == 0)
656-
strcpy(String, "OFF");
659+
strcpy(String, gSubMenu_OFF_ON[0]);
657660
else
658661
sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10);
659662
break;
@@ -699,16 +702,16 @@ void UI_DisplayMenu(void)
699702

700703
case MENU_VOX:
701704
#ifdef ENABLE_VOX
702-
sprintf(String, gSubMenuSelection == 0 ? "OFF" : "%u", gSubMenuSelection);
705+
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%u", gSubMenuSelection);
703706
#else
704-
strcpy(String, gSubMenu_OFF_ON[0]);
707+
strcpy(String, gSubMenu_NA);
705708
#endif
706709
break;
707710

708711
case MENU_ABR:
709712
if(gSubMenuSelection == 0)
710713
{
711-
strcpy(String, "OFF");
714+
strcpy(String, gSubMenu_OFF_ON[0]);
712715
}
713716
else if(gSubMenuSelection < 61)
714717
{
@@ -743,7 +746,7 @@ void UI_DisplayMenu(void)
743746

744747
case MENU_AUTOLK:
745748
if (gSubMenuSelection == 0)
746-
strcpy(String, "OFF");
749+
strcpy(String, gSubMenu_OFF_ON[0]);
747750
else
748751
{
749752
sprintf(String, "%02dm:%02ds", ((gSubMenuSelection * 15) / 60), ((gSubMenuSelection * 15) % 60));
@@ -855,7 +858,7 @@ void UI_DisplayMenu(void)
855858
}
856859

857860
case MENU_SAVE:
858-
sprintf(String, gSubMenuSelection == 0 ? "OFF" : "1:%u", gSubMenuSelection);
861+
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "1:%u", gSubMenuSelection);
859862
break;
860863

861864
case MENU_TDR:
@@ -901,7 +904,7 @@ void UI_DisplayMenu(void)
901904
break;
902905

903906
case MENU_RP_STE:
904-
sprintf(String, gSubMenuSelection == 0 ? "OFF" : "%u*100ms", gSubMenuSelection);
907+
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%u*100ms", gSubMenuSelection);
905908
break;
906909

907910
case MENU_S_LIST:
@@ -1039,7 +1042,7 @@ void UI_DisplayMenu(void)
10391042
case MENU_SET_OFF:
10401043
if(gSubMenuSelection == 0)
10411044
{
1042-
strcpy(String, "OFF");
1045+
strcpy(String, gSubMenu_OFF_ON[0]);
10431046
}
10441047
else if(gSubMenuSelection < 121)
10451048
{
@@ -1065,17 +1068,23 @@ void UI_DisplayMenu(void)
10651068
strcpy(String, gSubMenu_SET_TOT[gSubMenuSelection]); // Same as SET_TOT
10661069
break;
10671070

1068-
#ifdef ENABLE_FEAT_F4HWN_CONTRAST
10691071
case MENU_SET_CTR:
1070-
sprintf(String, "%d", gSubMenuSelection);
1071-
gSetting_set_ctr = gSubMenuSelection;
1072-
ST7565_ContrastAndInv();
1072+
#ifdef ENABLE_FEAT_F4HWN_CTR
1073+
sprintf(String, "%d", gSubMenuSelection);
1074+
gSetting_set_ctr = gSubMenuSelection;
1075+
ST7565_ContrastAndInv();
1076+
#else
1077+
strcpy(String, gSubMenu_NA);
1078+
#endif
10731079
break;
1074-
#endif
10751080

10761081
case MENU_SET_INV:
1077-
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
1078-
ST7565_ContrastAndInv();
1082+
#ifdef ENABLE_FEAT_F4HWN_INV
1083+
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
1084+
ST7565_ContrastAndInv();
1085+
#else
1086+
strcpy(String, gSubMenu_NA);
1087+
#endif
10791088
break;
10801089

10811090
case MENU_TX_LOCK:
@@ -1108,7 +1117,7 @@ void UI_DisplayMenu(void)
11081117
case MENU_SET_VOL:
11091118
if(gSubMenuSelection == 0)
11101119
{
1111-
strcpy(String, "OFF");
1120+
strcpy(String, gSubMenu_OFF_ON[0]);
11121121
}
11131122
else if(gSubMenuSelection < 64)
11141123
{

ui/menu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ extern const char gSubMenu_TXP[8][6];
168168
extern const char gSubMenu_SFT_D[3][4];
169169
extern const char gSubMenu_W_N[2][7];
170170
extern const char gSubMenu_OFF_ON[2][4];
171+
extern const char gSubMenu_NA[4];
171172
extern const char gSubMenu_TOT[11][7];
172173
extern const char* const gSubMenu_RXMode[4];
173174

ui/welcome.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
void UI_DisplayReleaseKeys(void)
3232
{
3333
memset(gStatusLine, 0, sizeof(gStatusLine));
34-
#ifdef ENABLE_FEAT_F4HWN
34+
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
3535
ST7565_ContrastAndInv();
3636
#endif
3737
UI_DisplayClear();
@@ -52,7 +52,7 @@ void UI_DisplayWelcome(void)
5252

5353
memset(gStatusLine, 0, sizeof(gStatusLine));
5454

55-
#ifdef ENABLE_FEAT_F4HWN
55+
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
5656
ST7565_ContrastAndInv();
5757
#endif
5858
UI_DisplayClear();

0 commit comments

Comments
 (0)