From 2119f1a931c2ec342082949de8211a551a72ac15 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Sat, 29 Jun 2024 03:50:49 +0200 Subject: [PATCH] Try to improve channel input --- app/app.c | 14 ++++++++++++++ app/main.c | 48 +++++++++++++++++++++++++++++------------------- app/main.h | 1 + 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/app/app.c b/app/app.c index 8de5ab0..6785e1f 100644 --- a/app/app.c +++ b/app/app.c @@ -1474,6 +1474,20 @@ void APP_TimeSlice500ms(void) gBeepToPlay = BEEP_NONE; } } + else + { + if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering channel number + switch (gInputBoxIndex) + { + case 1: + channelMove(gInputBox[0] - 1, false); + break; + case 2: + channelMove(((gInputBox[0] * 10) + gInputBox[1]) - 1, false); + break; + } + } + } } if (gDTMF_RX_live_timeout > 0) diff --git a/app/main.c b/app/main.c index 9023ebf..862011c 100644 --- a/app/main.c +++ b/app/main.c @@ -316,6 +316,32 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) } } +void channelMove(uint16_t Channel, bool End) +{ + const uint8_t Vfo = gEeprom.TX_VFO; + + if(End) + { + gInputBoxIndex = 0; + } + + if (!RADIO_CheckValidChannel(Channel, false, 0)) { + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + return; + } + + #ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; + #endif + + gEeprom.MrChannel[Vfo] = (uint8_t)Channel; + gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel; + gRequestSaveVFO = true; + gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + + return; +} + static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { if (bKeyHeld) { // key held down @@ -349,6 +375,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering channel number + gKeyInputCountdown = (key_input_timeout_500ms / 8); // short time... + if (gInputBoxIndex != 3) { #ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; @@ -357,25 +385,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - gInputBoxIndex = 0; - - const uint16_t Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; - - if (!RADIO_CheckValidChannel(Channel, false, 0)) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - return; - } - - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif - - gEeprom.MrChannel[Vfo] = (uint8_t)Channel; - gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel; - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - - return; + channelMove(((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1, true); } // #ifdef ENABLE_NOAA diff --git a/app/main.h b/app/main.h index f679aac..ddcc9ff 100644 --- a/app/main.h +++ b/app/main.h @@ -20,6 +20,7 @@ #include "driver/keyboard.h" void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); +void channelMove(uint16_t Channel, bool End); #endif