From 1260bc8fb209971b082c0cbc563d493509f820a0 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Wed, 17 Jul 2024 23:36:04 +0200 Subject: [PATCH] Fix issue #192 --- app/app.c | 6 ++++++ app/main.c | 52 ++++++++++++++++++++++++++++++---------------------- app/main.h | 2 +- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/app/app.c b/app/app.c index 46d2f4c..9388566 100644 --- a/app/app.c +++ b/app/app.c @@ -1469,6 +1469,12 @@ void APP_TimeSlice500ms(void) if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE) && (gInputBoxIndex == 1 || gInputBoxIndex == 2)) { + channelMoveSwitch(); + + if (gBeepToPlay == BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL) { + AUDIO_PlayBeep(gBeepToPlay); + } + SETTINGS_SaveVfoIndices(); } diff --git a/app/main.c b/app/main.c index 8507dfb..251eb81 100644 --- a/app/main.c +++ b/app/main.c @@ -314,20 +314,20 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) } } -void channelMove(uint16_t Channel, bool End) +void channelMove(uint16_t Channel) { const uint8_t Vfo = gEeprom.TX_VFO; - if(End) - { - gInputBoxIndex = 0; - } - if (!RADIO_CheckValidChannel(Channel, false, 0)) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (gKeyInputCountdown <= 1) { + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + } + return; } + gBeepToPlay = BEEP_NONE; + #ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; #endif @@ -338,34 +338,40 @@ void channelMove(uint16_t Channel, bool End) gVfoConfigureMode = VFO_CONFIGURE_RELOAD; RADIO_ConfigureChannel(gEeprom.TX_VFO, gVfoConfigureMode); - if(End) - { - SETTINGS_SaveVfoIndices(); - } - + return; } void channelMoveSwitch(void) { if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering channel number + uint16_t Channel = 0; + switch (gInputBoxIndex) { case 1: - if (gInputBox[0] != 0) { - channelMove(gInputBox[0] - 1, false); - } - + Channel = gInputBox[0]; break; case 2: - if (!((gInputBox[0] == 0) && (gInputBox[1] == 0))) { - channelMove(((gInputBox[0] * 10) + gInputBox[1]) - 1, false); - } - + Channel = (gInputBox[0] * 10) + gInputBox[1]; break; case 3: - channelMove(((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1, true); + Channel = (gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]; break; } + + if ((Channel == 0) && (gInputBoxIndex != 3)) { + return; + } + + if (gInputBoxIndex == 3) { + gInputBoxIndex = 0; + gKeyInputCountdown = 1; + + channelMove(Channel - 1); + return; + } + + channelMove(Channel - 1); } } @@ -425,10 +431,12 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) const uint8_t Vfo = gEeprom.TX_VFO; INPUTBOX_Append(Key); gKeyInputCountdown = key_input_timeout_500ms; + + channelMoveSwitch(); + gRequestDisplayScreen = DISPLAY_MAIN; if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering channel number - channelMoveSwitch(); gKeyInputCountdown = (key_input_timeout_500ms / 5); // short time... diff --git a/app/main.h b/app/main.h index ddcc9ff..bfe2417 100644 --- a/app/main.h +++ b/app/main.h @@ -20,7 +20,7 @@ #include "driver/keyboard.h" void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); -void channelMove(uint16_t Channel, bool End); +void channelMoveSwitch(void); #endif