Improvements to the FM radio and side buttons

This commit is contained in:
mrkusypl committed 2026-03-24 00:31:45 +01:00
1 parent aa69d698a7
commit bbbc553064
10 files changed
+117 -39

No files matched your search

+53
View File
@@ -290,6 +290,8 @@ void ACTION_SwitchDemodul(void)
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
HideFKeyIcon();
if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode){ if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode){
// entering DTMF code // entering DTMF code
@@ -358,6 +360,55 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// held or released after short press beyond this point // held or released after short press beyond this point
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK) { // do not run these actions in RescueOps mode
switch (func) {
case ACTION_OPT_SCAN:
case ACTION_OPT_VFO_MR:
#ifdef ENABLE_FMRADIO
case ACTION_OPT_FM:
#endif
return;
break;
default:
break;
}
}
#endif
#ifdef ENABLE_FMRADIO
if (gFmRadioMode) { // do not run these actions in FM radio mode
switch (func) {
case ACTION_OPT_POWER:
case ACTION_OPT_MONITOR:
case ACTION_OPT_A_B:
case ACTION_OPT_VFO_MR:
case ACTION_OPT_SWITCH_DEMODUL:
#ifdef ENABLE_VOX
case ACTION_OPT_VOX:
#endif
#ifdef ENABLE_FEAT_F4HWN
case ACTION_OPT_RXMODE:
case ACTION_OPT_MAINONLY:
case ACTION_OPT_WN:
#ifdef ENABLE_FEAT_F4HWN_AUDIO
case ACTION_OPT_RXA:
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
case ACTION_OPT_POWER_HIGH:
case ACTION_OPT_REMOVE_OFFSET:
#endif
#endif
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
default:
break;
}
}
#endif
action_opt_table[func](); action_opt_table[func]();
} }
@@ -546,6 +597,8 @@ void ACTION_RxA(void)
void ACTION_Ptt(void) void ACTION_Ptt(void)
{ {
gSetting_set_ptt_session = !gSetting_set_ptt_session; gSetting_set_ptt_session = !gSetting_set_ptt_session;
ACTION_Update();
} }
void ACTION_Wn(void) void ACTION_Wn(void)
+5 -7
View File
@@ -1503,10 +1503,10 @@ void cancelUserInputModes(void)
if (gWasFKeyPressed || gKeyInputCountdown > 0 || gInputBoxIndex > 0) if (gWasFKeyPressed || gKeyInputCountdown > 0 || gInputBoxIndex > 0)
{ {
gWasFKeyPressed = false; HideFKeyIcon();
gInputBoxIndex = 0; gInputBoxIndex = 0;
gKeyInputCountdown = 0; gKeyInputCountdown = 0;
gUpdateStatus = true;
gUpdateDisplay = true; gUpdateDisplay = true;
} }
} }
@@ -1528,7 +1528,7 @@ void APP_TimeSlice500ms(void)
if (--gKeyInputCountdown == 0) if (--gKeyInputCountdown == 0)
{ {
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE) && (gInputBoxIndex > 0 && gInputBoxIndex < 4)) if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE) && (gInputBoxIndex > 0 && gInputBoxIndex < 4) && (!gFmRadioMode))
{ {
channelMoveSwitch(); channelMoveSwitch();
@@ -1724,13 +1724,12 @@ void APP_TimeSlice500ms(void)
*/ */
DTMF_clear_input_box(); DTMF_clear_input_box();
gWasFKeyPressed = false; HideFKeyIcon();
gInputBoxIndex = 0; gInputBoxIndex = 0;
gAskToSave = false; gAskToSave = false;
gAskToDelete = false; gAskToDelete = false;
gUpdateStatus = true;
gUpdateDisplay = true; gUpdateDisplay = true;
GUI_DisplayType_t disp = DISPLAY_INVALID; GUI_DisplayType_t disp = DISPLAY_INVALID;
@@ -2022,8 +2021,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) { if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) {
#endif #endif
// cancel the F-key // cancel the F-key
gWasFKeyPressed = false; HideFKeyIcon();
gUpdateStatus = true;
} }
if (bFlag) { if (bFlag) {
+29 -6
View File
@@ -257,6 +257,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
} }
INPUTBOX_Append(Key); INPUTBOX_Append(Key);
gKeyInputCountdown = key_input_timeout_500ms;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
@@ -272,6 +273,8 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
uint32_t Frequency; uint32_t Frequency;
gInputBoxIndex = 0; gInputBoxIndex = 0;
gKeyInputCountdown = 1;
Frequency = StrToUL(INPUTBOX_GetAscii()); Frequency = StrToUL(INPUTBOX_GetAscii());
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band) || BK1080_GetFreqHiLimit(gEeprom.FM_Band) < Frequency) { if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band) || BK1080_GetFreqHiLimit(gEeprom.FM_Band) < Frequency) {
@@ -294,6 +297,8 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
uint8_t Channel; uint8_t Channel;
gInputBoxIndex = 0; gInputBoxIndex = 0;
gKeyInputCountdown = 1;
Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1; Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1;
if (State == STATE_MR_MODE) { if (State == STATE_MR_MODE) {
@@ -336,8 +341,7 @@ static void Key_FUNC(KEY_Code_t Key, uint8_t state)
bool autoScan = gWasFKeyPressed || (state == BUTTON_EVENT_HELD); bool autoScan = gWasFKeyPressed || (state == BUTTON_EVENT_HELD);
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gWasFKeyPressed = false; HideFKeyIcon();
gUpdateStatus = true;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
switch (Key) { switch (Key) {
@@ -404,6 +408,7 @@ static void Key_EXIT(uint8_t state)
} }
else { else {
gInputBox[--gInputBoxIndex] = 10; gInputBox[--gInputBoxIndex] = 10;
gKeyInputCountdown = key_input_timeout_500ms;
if (gInputBoxIndex) { if (gInputBoxIndex) {
if (gInputBoxIndex != 1) { if (gInputBoxIndex != 1) {
@@ -435,14 +440,25 @@ static void Key_EXIT(uint8_t state)
static void Key_MENU(uint8_t state) static void Key_MENU(uint8_t state)
{ {
if (state != BUTTON_EVENT_SHORT) if (state == BUTTON_EVENT_HELD) {
ACTION_Handle(KEY_MENU, true, true);
return; return;
}
else if (state != BUTTON_EVENT_SHORT) {
return;
}
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
HideFKeyIcon();
if (gFM_ScanState == FM_SCAN_OFF) { if (gFM_ScanState == FM_SCAN_OFF) {
if (gInputBoxIndex) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (!gEeprom.FM_IsMrMode) { if (!gEeprom.FM_IsMrMode) {
if (gAskToSave) { if (gAskToSave) {
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
@@ -479,6 +495,8 @@ static void Key_MENU(uint8_t state)
static void Key_UP_DOWN(uint8_t state, int8_t Step) static void Key_UP_DOWN(uint8_t state, int8_t Step)
{ {
HideFKeyIcon();
if (state == BUTTON_EVENT_PRESSED) { if (state == BUTTON_EVENT_PRESSED) {
if (gInputBoxIndex) { if (gInputBoxIndex) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@@ -563,9 +581,14 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
case KEY_PTT: case KEY_PTT:
GENERIC_Key_PTT(bKeyPressed); GENERIC_Key_PTT(bKeyPressed);
break; break;
default: case KEY_SIDE1:
if (!bKeyHeld && bKeyPressed) case KEY_SIDE2:
if (state != BUTTON_EVENT_PRESSED) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
HideFKeyIcon();
}
break;
default:
break; break;
} }
} }
+8 -16
View File
@@ -120,8 +120,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true && Key != 2) { if(gEeprom.MENU_LOCK == true && Key != 2) {
gUpdateStatus = true; HideFKeyIcon();
gWasFKeyPressed = false;
return; return;
} }
@@ -141,8 +140,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
case KEY_1: case KEY_1:
if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) { if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gWasFKeyPressed = false; HideFKeyIcon();
gUpdateStatus = true;
#ifdef ENABLE_COPY_CHAN_TO_VFO #ifdef ENABLE_COPY_CHAN_TO_VFO
if (!gEeprom.VFO_OPEN || gCssBackgroundScan) { if (!gEeprom.VFO_OPEN || gCssBackgroundScan) {
@@ -224,11 +222,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
case KEY_4: case KEY_4:
gWasFKeyPressed = false; HideFKeyIcon();
gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
gUpdateStatus = true;
SCANNER_Start(false); SCANNER_Start(false);
gRequestDisplayScreen = DISPLAY_SCANNER; gRequestDisplayScreen = DISPLAY_SCANNER;
@@ -339,8 +336,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#endif #endif
default: default:
gUpdateStatus = true; HideFKeyIcon();
gWasFKeyPressed = false;
if (beep) if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@@ -430,8 +426,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
} }
gWasFKeyPressed = false; HideFKeyIcon();
gUpdateStatus = true;
processFKeyFunction(Key, true); processFKeyFunction(Key, true);
} }
@@ -654,8 +649,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
gWasFKeyPressed = false; HideFKeyIcon();
gUpdateStatus = true;
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true && Key != 2) { if(gEeprom.MENU_LOCK == true && Key != 2) {
@@ -815,8 +809,7 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true) { if(gEeprom.MENU_LOCK == true) {
gUpdateStatus = true; HideFKeyIcon();
gWasFKeyPressed = false;
return; return;
} }
@@ -852,8 +845,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
if(gEeprom.MENU_LOCK == true) { if(gEeprom.MENU_LOCK == true) {
gUpdateStatus = true; HideFKeyIcon();
gWasFKeyPressed = false;
return; // prevent F function if MENU LOCK is true return; // prevent F function if MENU LOCK is true
} }
+9 -1
View File
@@ -177,11 +177,19 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
SYSTEM_DelayMs(5); SYSTEM_DelayMs(5);
BK4819_WriteRegister(BK4819_REG_71, ToneConfig); BK4819_WriteRegister(BK4819_REG_71, ToneConfig);
#ifdef ENABLE_FMRADIO
const bool isFmRadio = gFmRadioMode;
if (isFmRadio)
SYSTEM_DelayMs(10);
#endif
if (gEnableSpeaker) if (gEnableSpeaker)
AUDIO_AudioPathOn(); AUDIO_AudioPathOn();
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode) if (isFmRadio)
BK1080_Mute(false); BK1080_Mute(false);
#endif #endif
+5
View File
@@ -261,3 +261,8 @@ KEY_Code_t KEYBOARD_GetKey(void)
} }
return btn; return btn;
} }
void HideFKeyIcon(void) {
gWasFKeyPressed = false;
gUpdateStatus = true;
}
+2
View File
@@ -71,4 +71,6 @@ bool KEYBOARD_ProcessProtocolByte(ParseState_t *state, uint8_t b);
KEY_Code_t KEYBOARD_Poll(void); KEY_Code_t KEYBOARD_Poll(void);
KEY_Code_t KEYBOARD_GetKey(void); KEY_Code_t KEYBOARD_GetKey(void);
void HideFKeyIcon(void);
#endif #endif
+4 -7
View File
@@ -163,11 +163,8 @@ int32_t TX_freq_check(const uint32_t Frequency)
{ // return '0' if TX frequency is allowed { // return '0' if TX frequency is allowed
// otherwise return '-1' // otherwise return '-1'
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper) if (RX_freq_check(Frequency))
return -1; // not allowed outside this range return -1;
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
return -1; // BX chip does not work in this range
switch (gSetting_F_LOCK) switch (gSetting_F_LOCK)
{ {
@@ -280,10 +277,10 @@ int32_t RX_freq_check(const uint32_t Frequency)
// otherwise return '-1' // otherwise return '-1'
if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper) if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper)
return -1; return -1; // not allowed outside this range
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
return -1; return -1; // BX chip does not work in this range
return 0; // OK frequency return 0; // OK frequency
} }
+1
View File
@@ -129,6 +129,7 @@ void Main(void)
if (BootMode == BOOT_MODE_RESCUE_OPS) if (BootMode == BOOT_MODE_RESCUE_OPS)
{ {
gEeprom.MENU_LOCK = !gEeprom.MENU_LOCK; gEeprom.MENU_LOCK = !gEeprom.MENU_LOCK;
gEeprom.CURRENT_STATE = 0; // Don't resume is active...
SETTINGS_SaveSettings(); SETTINGS_SaveSettings();
} }
+1 -2
View File
@@ -94,9 +94,8 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
gAskForConfirmation = 0; gAskForConfirmation = 0;
gAskToSave = false; gAskToSave = false;
gAskToDelete = false; gAskToDelete = false;
gWasFKeyPressed = false;
gUpdateStatus = true; HideFKeyIcon();
} }
gScreenToDisplay = Display; gScreenToDisplay = Display;