Add Narrower feature

This commit is contained in:
Armel FAUVEAU
2024-10-31 00:37:47 +01:00
parent 07c31a0e48
commit 18daf70365
10 changed files with 162 additions and 35 deletions

View File

@@ -47,8 +47,9 @@ ENABLE_FEAT_F4HWN_RX_TX_TIMER ?= 1
ENABLE_FEAT_F4HWN_CHARGING_C ?= 1 ENABLE_FEAT_F4HWN_CHARGING_C ?= 1
ENABLE_FEAT_F4HWN_SLEEP ?= 1 ENABLE_FEAT_F4HWN_SLEEP ?= 1
ENABLE_FEAT_F4HWN_RESTORE_SCAN ?= 1 ENABLE_FEAT_F4HWN_RESTORE_SCAN ?= 1
ENABLE_FEAT_F4HWN_NARROWER ?= 1
ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0 ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0
ENABLE_FEAT_F4HWN_PMR ?= 0 ENABLE_FEAT_F4HWN_PMR ?= 0
ENABLE_FEAT_F4HWN_GMRS_FRS_MURS ?= 0 ENABLE_FEAT_F4HWN_GMRS_FRS_MURS ?= 0
ENABLE_FEAT_F4HWN_CA ?= 1 ENABLE_FEAT_F4HWN_CA ?= 1
@@ -427,6 +428,9 @@ endif
ifeq ($(ENABLE_FEAT_F4HWN_RESTORE_SCAN),1) ifeq ($(ENABLE_FEAT_F4HWN_RESTORE_SCAN),1)
CFLAGS += -DENABLE_FEAT_F4HWN_RESTORE_SCAN CFLAGS += -DENABLE_FEAT_F4HWN_RESTORE_SCAN
endif endif
ifeq ($(ENABLE_FEAT_F4HWN_NARROWER),1)
CFLAGS += -DENABLE_FEAT_F4HWN_NARROWER
endif
ifeq ($(ENABLE_FEAT_F4HWN_RESET_CHANNEL),1) ifeq ($(ENABLE_FEAT_F4HWN_RESET_CHANNEL),1)
CFLAGS += -DENABLE_FEAT_F4HWN_RESET_CHANNEL CFLAGS += -DENABLE_FEAT_F4HWN_RESET_CHANNEL
endif endif

View File

@@ -525,24 +525,56 @@ void ACTION_Ptt(void)
void ACTION_Wn(void) void ACTION_Wn(void)
{ {
if (FUNCTION_IsRx()) #ifdef ENABLE_FEAT_F4HWN_NARROWER
{ bool narrower = 0;
gRxVfo->CHANNEL_BANDWIDTH = (gRxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0; if (FUNCTION_IsRx())
#ifdef ENABLE_AM_FIX {
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH, true); gRxVfo->CHANNEL_BANDWIDTH = (gRxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
#else if(gRxVfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1)
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH, false); {
#endif narrower = 1;
} }
else
{ #ifdef ENABLE_AM_FIX
gTxVfo->CHANNEL_BANDWIDTH = (gTxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0; BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH + narrower, true);
#ifdef ENABLE_AM_FIX #else
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, true); BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH + narrower, false);
#else #endif
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, false); }
#endif else
} {
gTxVfo->CHANNEL_BANDWIDTH = (gTxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
if(gTxVfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1)
{
narrower = 1;
}
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, true);
#else
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, false);
#endif
}
#else
if (FUNCTION_IsRx())
{
gRxVfo->CHANNEL_BANDWIDTH = (gRxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH, true);
#else
BK4819_SetFilterBandwidth(gRxVfo->CHANNEL_BANDWIDTH, false);
#endif
}
else
{
gTxVfo->CHANNEL_BANDWIDTH = (gTxVfo->CHANNEL_BANDWIDTH == 0) ? 1: 0;
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, true);
#else
BK4819_SetFilterBandwidth(gTxVfo->CHANNEL_BANDWIDTH, false);
#endif
}
#endif
} }
void ACTION_BackLight(void) void ACTION_BackLight(void)

View File

@@ -418,6 +418,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
//*pMin = 0; //*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_MET) - 1; *pMax = ARRAY_SIZE(gSubMenu_SET_MET) - 1;
break; break;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_NFM) - 1;
break;
#endif
#endif #endif
default: default:
@@ -917,6 +923,13 @@ void MENU_AcceptSetting(void)
case MENU_SET_GUI: case MENU_SET_GUI:
gSetting_set_gui = gSubMenuSelection; gSetting_set_gui = gSubMenuSelection;
break; break;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
gSetting_set_nfm = gSubMenuSelection;
RADIO_SetTxParameters();
RADIO_SetupRegisters(true);
break;
#endif
case MENU_SET_TMR: case MENU_SET_TMR:
gSetting_set_tmr = gSubMenuSelection; gSetting_set_tmr = gSubMenuSelection;
break; break;
@@ -1351,6 +1364,11 @@ void MENU_ShowCurrentSetting(void)
case MENU_SET_GUI: case MENU_SET_GUI:
gSubMenuSelection = gSetting_set_gui; gSubMenuSelection = gSetting_set_gui;
break; break;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
gSubMenuSelection = gSetting_set_nfm;
break;
#endif
case MENU_SET_TMR: case MENU_SET_TMR:
gSubMenuSelection = gSetting_set_tmr; gSubMenuSelection = gSetting_set_tmr;
break; break;

3
misc.c
View File

@@ -125,6 +125,9 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
bool gSetting_set_lck = false; bool gSetting_set_lck = false;
bool gSetting_set_met = 0; bool gSetting_set_met = 0;
bool gSetting_set_gui = 0; bool gSetting_set_gui = 0;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
bool gSetting_set_nfm = 0;
#endif
bool gSetting_set_tmr = 0; bool gSetting_set_tmr = 0;
bool gSetting_set_ptt_session; bool gSetting_set_ptt_session;
uint8_t gDebug; uint8_t gDebug;

3
misc.h
View File

@@ -178,6 +178,9 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
extern bool gSetting_set_lck; extern bool gSetting_set_lck;
extern bool gSetting_set_met; extern bool gSetting_set_met;
extern bool gSetting_set_gui; extern bool gSetting_set_gui;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
extern bool gSetting_set_nfm;
#endif
extern bool gSetting_set_tmr; extern bool gSetting_set_tmr;
extern bool gSetting_set_ptt_session; extern bool gSetting_set_ptt_session;
extern uint8_t gDebug; extern uint8_t gDebug;

16
radio.c
View File

@@ -658,6 +658,13 @@ void RADIO_SetupRegisters(bool switchToForeground)
{ {
BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH; BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
if(Bandwidth == BK4819_FILTER_BW_NARROW && gSetting_set_nfm == 1)
{
Bandwidth = BK4819_FILTER_BW_NARROWER;
}
#endif
AUDIO_AudioPathOff(); AUDIO_AudioPathOff();
gEnableSpeaker = false; gEnableSpeaker = false;
@@ -671,6 +678,7 @@ void RADIO_SetupRegisters(bool switchToForeground)
[[fallthrough]]; [[fallthrough]];
case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
case BK4819_FILTER_BW_NARROWER:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix); // BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix);
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
@@ -892,6 +900,13 @@ void RADIO_SetTxParameters(void)
{ {
BK4819_FilterBandwidth_t Bandwidth = gCurrentVfo->CHANNEL_BANDWIDTH; BK4819_FilterBandwidth_t Bandwidth = gCurrentVfo->CHANNEL_BANDWIDTH;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
if(Bandwidth == BK4819_FILTER_BW_NARROW && gSetting_set_nfm == 1)
{
Bandwidth = BK4819_FILTER_BW_NARROWER;
}
#endif
AUDIO_AudioPathOff(); AUDIO_AudioPathOff();
gEnableSpeaker = false; gEnableSpeaker = false;
@@ -905,6 +920,7 @@ void RADIO_SetTxParameters(void)
[[fallthrough]]; [[fallthrough]];
case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
case BK4819_FILTER_BW_NARROWER:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->Modulation == MODULATION_AM && gSetting_AM_fix); // BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->Modulation == MODULATION_AM && gSetting_AM_fix);
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);

View File

@@ -70,7 +70,12 @@ void SETTINGS_InitEEPROM(void)
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4; gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4;
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A;
gEeprom.BACKLIGHT_TIME = (Data[5] < 62) ? Data[5] : 12; gEeprom.BACKLIGHT_TIME = (Data[5] < 62) ? Data[5] : 12;
gEeprom.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false; #ifdef ENABLE_FEAT_F4HWN_NARROWER
gEeprom.TAIL_TONE_ELIMINATION = ((Data[6] & 0x01) < 2) ? (Data[6] & 0x01) : false;
gSetting_set_nfm = (((Data[6] >> 1) & 0x03) < 3) ? ((Data[6] >> 1) & 0x03) : 0;
#else
gEeprom.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false;
#endif
#ifdef ENABLE_FEAT_F4HWN_RESTORE_SCAN #ifdef ENABLE_FEAT_F4HWN_RESTORE_SCAN
gEeprom.VFO_OPEN = Data[7] & 0x01; gEeprom.VFO_OPEN = Data[7] & 0x01;
@@ -620,7 +625,11 @@ void SETTINGS_SaveSettings(void)
State[5] = gEeprom.BACKLIGHT_TIME; State[5] = gEeprom.BACKLIGHT_TIME;
#endif #endif
State[6] = gEeprom.TAIL_TONE_ELIMINATION; #ifdef ENABLE_FEAT_F4HWN_NARROWER
State[6] = (gEeprom.TAIL_TONE_ELIMINATION & 0x01) | ((gSetting_set_nfm & 0x03) << 1);
#else
State[6] = gEeprom.TAIL_TONE_ELIMINATION;
#endif
#ifdef ENABLE_FEAT_F4HWN_RESTORE_SCAN #ifdef ENABLE_FEAT_F4HWN_RESTORE_SCAN
State[7] = (gEeprom.VFO_OPEN & 0x01) | ((gEeprom.CURRENT_STATE & 0x07) << 1) | ((gEeprom.SCAN_LIST_DEFAULT & 0x07) << 4); State[7] = (gEeprom.VFO_OPEN & 0x01) | ((gEeprom.CURRENT_STATE & 0x07) << 1) | ((gEeprom.SCAN_LIST_DEFAULT & 0x07) << 4);

View File

@@ -1276,16 +1276,36 @@ void UI_DisplayMain(void)
#endif #endif
#if ENABLE_FEAT_F4HWN #if ENABLE_FEAT_F4HWN
if (isMainOnly(true)) #ifdef ENABLE_FEAT_F4HWN_NARROWER
{ bool narrower = 0;
const char *bandWidthNames[] = {"W", "N"};
UI_PrintStringSmallNormal(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH], LCD_WIDTH + 80, 0, line + 1); if(vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1)
} {
else narrower = 1;
{ }
const char *bandWidthNames[] = {"WIDE", "NAR"};
GUI_DisplaySmallest(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH], 91, line == 0 ? 17 : 49, false, true); if (isMainOnly(true))
} {
const char *bandWidthNames[] = {"W", "N", "N+"};
UI_PrintStringSmallNormal(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH + narrower], LCD_WIDTH + 80, 0, line + 1);
}
else
{
const char *bandWidthNames[] = {"WIDE", "NAR", "NAR+"};
GUI_DisplaySmallest(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH + narrower], 91, line == 0 ? 17 : 49, false, true);
}
#else
if (isMainOnly(true))
{
const char *bandWidthNames[] = {"W", "N"};
UI_PrintStringSmallNormal(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH], LCD_WIDTH + 80, 0, line + 1);
}
else
{
const char *bandWidthNames[] = {"WIDE", "NAR"};
GUI_DisplaySmallest(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH], 91, line == 0 ? 17 : 49, false, true);
}
#endif
#else #else
if (vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) if (vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW)
UI_PrintStringSmallNormal("N", LCD_WIDTH + 70, 0, line + 1); UI_PrintStringSmallNormal("N", LCD_WIDTH + 70, 0, line + 1);

View File

@@ -138,18 +138,21 @@ const t_menu_item MenuList[] =
{"Sql", MENU_SQL }, {"Sql", MENU_SQL },
#ifdef ENABLE_FEAT_F4HWN #ifdef ENABLE_FEAT_F4HWN
{"SetPwr", MENU_SET_PWR }, {"SetPwr", MENU_SET_PWR },
{"SetPtt", MENU_SET_PTT }, {"SetPTT", MENU_SET_PTT },
{"SetTot", MENU_SET_TOT }, {"SetTOT", MENU_SET_TOT },
{"SetEot", MENU_SET_EOT }, {"SetEOT", MENU_SET_EOT },
{"SetCtr", MENU_SET_CTR }, {"SetCtr", MENU_SET_CTR },
{"SetInv", MENU_SET_INV }, {"SetInv", MENU_SET_INV },
{"SetLck", MENU_SET_LCK }, {"SetLck", MENU_SET_LCK },
{"SetMet", MENU_SET_MET }, {"SetMet", MENU_SET_MET },
{"SetGui", MENU_SET_GUI }, {"SetGUI", MENU_SET_GUI },
{"SetTmr", MENU_SET_TMR }, {"SetTmr", MENU_SET_TMR },
#ifdef ENABLE_FEAT_F4HWN_SLEEP #ifdef ENABLE_FEAT_F4HWN_SLEEP
{"SetOff", MENU_SET_OFF }, {"SetOff", MENU_SET_OFF },
#endif #endif
#ifdef ENABLE_FEAT_F4HWN_NARROWER
{"SetNFM", MENU_SET_NFM },
#endif
#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
@@ -390,6 +393,14 @@ const char gSubMenu_SCRAMBLER[][7] =
"TINY", "TINY",
"CLASSIC" "CLASSIC"
}; };
#ifdef ENABLE_FEAT_F4HWN_NARROWER
const char gSubMenu_SET_NFM[][8] =
{
"12.5kHz",
"6.25kHz"
};
#endif
#endif #endif
const t_sidefunction gSubMenu_SIDEFUNCTIONS[] = const t_sidefunction gSubMenu_SIDEFUNCTIONS[] =
@@ -1045,6 +1056,11 @@ void UI_DisplayMenu(void)
strcpy(String, gSubMenu_SET_MET[gSubMenuSelection]); // Same as SET_MET strcpy(String, gSubMenu_SET_MET[gSubMenuSelection]); // Same as SET_MET
break; break;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
strcpy(String, gSubMenu_SET_NFM[gSubMenuSelection]);
break;
#endif
#endif #endif
} }

View File

@@ -141,6 +141,9 @@ enum
MENU_SET_MET, MENU_SET_MET,
MENU_SET_GUI, MENU_SET_GUI,
MENU_SET_TMR, MENU_SET_TMR,
#ifdef ENABLE_FEAT_F4HWN_NARROWER
MENU_SET_NFM,
#endif
#endif #endif
MENU_BATCAL, // battery voltage calibration MENU_BATCAL, // battery voltage calibration
MENU_F1SHRT, MENU_F1SHRT,
@@ -179,6 +182,9 @@ extern const char gSubMenu_D_RSP[4][11];
extern const char gSubMenu_SET_TOT[4][7]; extern const char gSubMenu_SET_TOT[4][7];
extern const char gSubMenu_SET_LCK[2][9]; extern const char gSubMenu_SET_LCK[2][9];
extern const char gSubMenu_SET_MET[2][8]; extern const char gSubMenu_SET_MET[2][8];
#ifdef ENABLE_FEAT_F4HWN_NARROWER
extern const char gSubMenu_SET_NFM[2][8];
#endif
#endif #endif
extern const char* const gSubMenu_PTT_ID[5]; extern const char* const gSubMenu_PTT_ID[5];