diff --git a/app/action.c b/app/action.c index 3f9cb1ed9..61490dbab 100644 --- a/app/action.c +++ b/app/action.c @@ -193,6 +193,8 @@ void ACTION_Scan(bool bRestart) GUI_SelectNextDisplay(DISPLAY_MAIN); + gUpdateStatus = true; + if (gScanStateDir != SCAN_OFF) { // already scanning @@ -227,7 +229,6 @@ void ACTION_Scan(bool bRestart) gDualWatchActive = false; } - gUpdateStatus = true; } @@ -291,22 +292,26 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) break; } - if (!bKeyHeld && bKeyPressed) // button pushed - { + if (bKeyPressed && !bKeyHeld) { + // button pushed + return; + } + + if (!bKeyPressed && bKeyHeld) { + //ignore release if held return; } // held or released beyond this point - if(!(bKeyHeld && !bKeyPressed)) // don't beep on released after hold + if(bKeyPressed || !bKeyHeld) { + // don't beep on released after hold gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + } - if (bKeyHeld || bKeyPressed) // held - { + if (bKeyPressed || bKeyHeld) { + // held funcShort = funcLong; - - if (!bKeyPressed) //ignore release if held - return; } // held or released after short press beyond this point @@ -318,32 +323,34 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) #ifdef ENABLE_FMRADIO void ACTION_FM(void) { - if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR) - { - gInputBoxIndex = 0; + if (gCurrentFunction == FUNCTION_TRANSMIT || gCurrentFunction == FUNCTION_MONITOR) { + return; + } - if (gFmRadioMode) { - FM_TurnOff(); - gFlagReconfigureVfos = true; - gRequestDisplayScreen = DISPLAY_MAIN; + gInputBoxIndex = 0; + + if (gFmRadioMode) { + FM_TurnOff(); + gFlagReconfigureVfos = true; + gRequestDisplayScreen = DISPLAY_MAIN; #ifdef ENABLE_VOX - gVoxResumeCountdown = 80; + gVoxResumeCountdown = 80; #endif - return; - } + return; + } - gMonitor = false; + gMonitor = false; - RADIO_SelectVfos(); - RADIO_SetupRegisters(true); + RADIO_SelectVfos(); + RADIO_SetupRegisters(true); - FM_Start(); + FM_Start(); - gRequestDisplayScreen = DISPLAY_FM; - } + gRequestDisplayScreen = DISPLAY_FM; } + static void ACTION_Scan_FM(bool bRestart) { if (FUNCTION_IsRx()) { @@ -363,17 +370,14 @@ static void ACTION_Scan_FM(bool bRestart) return; } + gFM_ChannelPosition = 0; + gFM_AutoScan = bRestart; uint16_t Frequency; - if (bRestart) { - gFM_AutoScan = true; - gFM_ChannelPosition = 0; FM_EraseChannels(); - Frequency = gEeprom.FM_LowerLimit; + Frequency = gEeprom.FM_LowerLimit; } else { - gFM_AutoScan = false; - gFM_ChannelPosition = 0; - Frequency = gEeprom.FM_FrequencyPlaying; + Frequency = gEeprom.FM_FrequencyPlaying; } BK1080_GetFrequencyDeviation(Frequency); diff --git a/app/app.c b/app/app.c index 0dc13ace6..278f4368d 100644 --- a/app/app.c +++ b/app/app.c @@ -1113,9 +1113,7 @@ void APP_TimeSlice10ms(void) #endif } - if (gUpdateDisplay) - { - gUpdateDisplay = false; + if (gUpdateDisplay) { GUI_DisplayScreen(); } diff --git a/app/fm.c b/app/fm.c index 5e9086fd2..7ac7404a4 100644 --- a/app/fm.c +++ b/app/fm.c @@ -392,16 +392,8 @@ static void Key_EXIT(uint8_t state) { gInputBox[--gInputBoxIndex] = 10; - if (gInputBoxIndex) - { - if (gInputBoxIndex != 1) - { - gRequestDisplayScreen = DISPLAY_FM; - return; - } - - if (gInputBox[0] != 0) - { + if (gInputBoxIndex) { + if (gInputBoxIndex != 1 || gInputBox[0] != 0) { gRequestDisplayScreen = DISPLAY_FM; return; } diff --git a/ui/helper.c b/ui/helper.c index 63bf58199..605cc4d0f 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -29,29 +29,18 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel) { - unsigned int i; - - if (gInputBoxIndex == 0) - { + if (gInputBoxIndex == 0) { sprintf(pString, "CH-%02u", Channel + 1); return; } - pString[0] = 'C'; - pString[1] = 'H'; - pString[2] = '-'; - for (i = 0; i < 2; i++) - pString[i + 3] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; + sprintf(pString, "CH-%2s", INPUTBOX_GetAscii()); } void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber) { if (gInputBoxIndex > 0) { - for (unsigned int i = 0; i < 3; i++) { - pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; - } - - pString[3] = 0; + sprintf(pString, "%3s", INPUTBOX_GetAscii()); return; } diff --git a/ui/ui.c b/ui/ui.c index 50963aa4a..6aaa34771 100644 --- a/ui/ui.c +++ b/ui/ui.c @@ -63,6 +63,7 @@ static_assert(ARRAY_SIZE(UI_DisplayFunctions) == DISPLAY_N_ELEM); void GUI_DisplayScreen(void) { + gUpdateDisplay = false; if (gScreenToDisplay != DISPLAY_INVALID) { UI_DisplayFunctions[gScreenToDisplay](); }