diff --git a/am_fix.c b/am_fix.c index ad8ef0a..54a4bce 100644 --- a/am_fix.c +++ b/am_fix.c @@ -447,8 +447,10 @@ const uint8_t orig_pga = 6; // -3dB gain_table_index[vfo] = (index <= max_index) ? index : max_index; // limit the gain index } - if (gain_table_index[vfo] == gain_table_index_prev[vfo]) - return; // no gain change + #if 0 + if (gain_table_index[vfo] == gain_table_index_prev[vfo]) + return; // no gain change + #endif #endif diff --git a/app/app.c b/app/app.c index 88268aa..db123a0 100644 --- a/app/app.c +++ b/app/app.c @@ -1281,47 +1281,21 @@ void APP_CheckKeys(void) if (gPttIsPressed) { - if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) - { // PTT released - #if 0 - // denoise the PTT - unsigned int i = 6; // test the PTT button for 6ms - unsigned int count = 0; - while (i-- > 0) - { - SYSTEM_DelayMs(1); - - if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) - { // PTT pressed - if (count > 0) - count--; - continue; - } - if (++count < 3) - continue; - - // stop transmitting - APP_ProcessKey(KEY_PTT, false, false); - gPttIsPressed = false; - if (gKeyReading1 != KEY_INVALID) - gPttWasReleased = true; - break; - } - #else - if (++gPttDebounceCounter >= 3) // 30ms - { // stop transmitting - APP_ProcessKey(KEY_PTT, false, false); - gPttIsPressed = false; - if (gKeyReading1 != KEY_INVALID) - gPttWasReleased = true; - } - #endif + if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0) + { // PTT released or serial comms config in progress + if (++gPttDebounceCounter >= 3 || gSerialConfigCountDown_500ms > 0) // 30ms + { // stop transmitting + APP_ProcessKey(KEY_PTT, false, false); + gPttIsPressed = false; + if (gKeyReading1 != KEY_INVALID) + gPttWasReleased = true; + } } else gPttDebounceCounter = 0; } else - if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) + if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0) { // PTT pressed if (++gPttDebounceCounter >= 3) // 30ms { // start transmitting @@ -1739,6 +1713,16 @@ void APP_TimeSlice500ms(void) if (--gDTMF_RX_timeout == 0) DTMF_clear_RX(); + if (gSerialConfigCountDown_500ms > 0) + { + gReducedService = true; // a serial config upload/download is in progress + +// if (gCurrentFunction == FUNCTION_TRANSMIT) +// { // stop transmitting +// +// } + } + // Skipped authentic device check #ifdef ENABLE_FMRADIO @@ -1815,6 +1799,8 @@ void APP_TimeSlice500ms(void) if (gScanState == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) #endif { + bool exit_menu = false; + if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode) { if (--gKeyLockCountdown == 0) @@ -1823,52 +1809,55 @@ void APP_TimeSlice500ms(void) gUpdateStatus = true; // lock symbol needs showing } - if (gVoltageMenuCountdown > 0) + if (gMenuCountdown > 0) + if (--gMenuCountdown == 0) + exit_menu = true; // exit menu mode + + if (exit_menu) { - if (--gVoltageMenuCountdown == 0) + gMenuCountdown = 0; + + if (gEeprom.BACKLIGHT == 0 && gScreenToDisplay == DISPLAY_MENU) { - if (gEeprom.BACKLIGHT == 0 && gScreenToDisplay == DISPLAY_MENU) - { - gBacklightCountdown = 0; - GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF - } - - if (gInputBoxIndex > 0 || gDTMF_InputMode || gScreenToDisplay == DISPLAY_MENU) - AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); - - if (gScreenToDisplay == DISPLAY_SCANNER) - { - BK4819_StopScan(); - - RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); - RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD); - - RADIO_SetupRegisters(true); - } - - gWasFKeyPressed = false; - gUpdateStatus = true; - gInputBoxIndex = 0; - gDTMF_InputMode = false; - gDTMF_InputIndex = 0; - gAskToSave = false; - gAskToDelete = false; - - #ifdef ENABLE_FMRADIO - if (gFmRadioMode && - gCurrentFunction != FUNCTION_RECEIVE && - gCurrentFunction != FUNCTION_MONITOR && - gCurrentFunction != FUNCTION_TRANSMIT) - { - GUI_SelectNextDisplay(DISPLAY_FM); - } - else - #endif - #ifndef ENABLE_CODE_SCAN_TIMEOUT - if (gScreenToDisplay != DISPLAY_SCANNER) - #endif - GUI_SelectNextDisplay(DISPLAY_MAIN); + gBacklightCountdown = 0; + GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF } + + if (gInputBoxIndex > 0 || gDTMF_InputMode || gScreenToDisplay == DISPLAY_MENU) + AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); + + if (gScreenToDisplay == DISPLAY_SCANNER) + { + BK4819_StopScan(); + + RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); + RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD); + + RADIO_SetupRegisters(true); + } + + gWasFKeyPressed = false; + gUpdateStatus = true; + gInputBoxIndex = 0; + gDTMF_InputMode = false; + gDTMF_InputIndex = 0; + gAskToSave = false; + gAskToDelete = false; + + #ifdef ENABLE_FMRADIO + if (gFmRadioMode && + gCurrentFunction != FUNCTION_RECEIVE && + gCurrentFunction != FUNCTION_MONITOR && + gCurrentFunction != FUNCTION_TRANSMIT) + { + GUI_SelectNextDisplay(DISPLAY_FM); + } + else + #endif + #ifndef ENABLE_CODE_SCAN_TIMEOUT + if (gScreenToDisplay != DISPLAY_SCANNER) + #endif + GUI_SelectNextDisplay(DISPLAY_MAIN); } } } @@ -2117,8 +2106,10 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) else { if (Key != KEY_PTT) - gVoltageMenuCountdown = menu_timeout_500ms; - + { + gMenuCountdown = menu_timeout_500ms; + } + BACKLIGHT_TurnOn(); if (gDTMF_DecodeRingCountdown_500ms > 0) @@ -2360,6 +2351,8 @@ Skip: if (gFlagAcceptSetting) { + gMenuCountdown = menu_timeout_500ms; + MENU_AcceptSetting(); gFlagRefreshSetting = true; @@ -2467,6 +2460,8 @@ Skip: if (gFlagRefreshSetting) { gFlagRefreshSetting = false; + gMenuCountdown = menu_timeout_500ms; + MENU_ShowCurrentSetting(); } diff --git a/app/main.c b/app/main.c index 9115f87..54a3554 100644 --- a/app/main.c +++ b/app/main.c @@ -597,7 +597,6 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) if (bFlag) { gFlagRefreshSetting = true; - gFlagBackupSetting = true; gRequestDisplayScreen = DISPLAY_MENU; diff --git a/app/menu.c b/app/menu.c index 11df72e..b97a6be 100644 --- a/app/menu.c +++ b/app/menu.c @@ -1107,12 +1107,6 @@ void MENU_ShowCurrentSetting(void) default: return; } - -// if (gFlagBackupSetting) - { // save a copy incase the user wants to back out -// gFlagBackupSetting = false; - gSubMenuSelection_original = gSubMenuSelection; - } } static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) @@ -1166,7 +1160,6 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { gMenuCursor = Value - 1; gFlagRefreshSetting = true; - gFlagBackupSetting = true; return; } @@ -1182,7 +1175,6 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { gMenuCursor = Value - 1; gFlagRefreshSetting = true; - gFlagBackupSetting = true; return; } break; @@ -1595,7 +1587,6 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) gMenuCursor = NUMBER_AddWithWraparound(gMenuCursor, -Direction, 0, gMenuListCount - 1); gFlagRefreshSetting = true; - gFlagBackupSetting = true; gRequestDisplayScreen = DISPLAY_MENU; @@ -1715,6 +1706,19 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) break; } - if (gScreenToDisplay == DISPLAY_MENU && gMenuCursor == MENU_VOL) - gVoltageMenuCountdown = menu_timeout_500ms; + if (gScreenToDisplay == DISPLAY_MENU) + { + if (gMenuCursor == MENU_VOL || + #ifdef ENABLE_F_CAL_MENU + gMenuCursor == MENU_F_CALI || + #endif + gMenuCursor == MENU_BATCAL) + { + gMenuCountdown = menu_timeout_long_500ms; + } + else + { + gMenuCountdown = menu_timeout_500ms; + } + } } diff --git a/app/uart.c b/app/uart.c index 0a64d1e..21f7f1d 100644 --- a/app/uart.c +++ b/app/uart.c @@ -225,10 +225,17 @@ static void CMD_0514(const uint8_t *pBuffer) const CMD_0514_t *pCmd = (const CMD_0514_t *)pBuffer; Timestamp = pCmd->Timestamp; + #ifdef ENABLE_FMRADIO gFmRadioCountdown_500ms = fm_radio_countdown_500ms; #endif + + gSerialConfigCountDown_500ms = 6; // 3 sec + gSerialConfigCountDown_done = false; + + // turn the LCD backlight off GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); + SendVersion(); } @@ -241,9 +248,13 @@ static void CMD_051B(const uint8_t *pBuffer) if (pCmd->Timestamp != Timestamp) return; + gSerialConfigCountDown_500ms = 6; // 3 sec + gSerialConfigCountDown_done = false; + #ifdef ENABLE_FMRADIO gFmRadioCountdown_500ms = fm_radio_countdown_500ms; #endif + memset(&Reply, 0, sizeof(Reply)); Reply.Header.ID = 0x051C; Reply.Header.Size = pCmd->Size + 4; @@ -269,11 +280,15 @@ static void CMD_051D(const uint8_t *pBuffer) if (pCmd->Timestamp != Timestamp) return; + gSerialConfigCountDown_500ms = 6; // 3 sec + gSerialConfigCountDown_done = false; + bReloadEeprom = false; #ifdef ENABLE_FMRADIO gFmRadioCountdown_500ms = fm_radio_countdown_500ms; #endif + Reply.Header.ID = 0x051E; Reply.Header.Size = sizeof(Reply.Data); Reply.Data.Offset = pCmd->Offset; @@ -389,8 +404,12 @@ static void CMD_052F(const uint8_t *pBuffer) if (gCurrentFunction == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); + gSerialConfigCountDown_500ms = 6; // 3 sec + gSerialConfigCountDown_done = false; + Timestamp = pCmd->Timestamp; + // turn the LCD backlight off GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); SendVersion(); diff --git a/firmware.bin b/firmware.bin index d24f389..85791de 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index f77d23c..b721073 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/misc.c b/misc.c index d8fe1d4..ab3897b 100644 --- a/misc.c +++ b/misc.c @@ -24,7 +24,8 @@ const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds -const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds +const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds +const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes const uint8_t DTMF_RX_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen const uint8_t DTMF_RX_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver @@ -124,6 +125,9 @@ volatile uint16_t gDualWatchCountdown_10ms; volatile bool gDualWatchCountdownExpired = true; bool gDualWatchActive = false; +volatile uint8_t gSerialConfigCountDown_500ms; +volatile bool gSerialConfigCountDown_done; + volatile bool gNextTimeslice_500ms; volatile uint16_t gTxTimerCountdown_500ms; @@ -155,7 +159,7 @@ bool gUpdateRSSI; #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) AlarmState_t gAlarmState; #endif -uint8_t gVoltageMenuCountdown; +uint16_t gMenuCountdown; bool gPttWasReleased; bool gPttWasPressed; uint8_t gKeypadLocked; @@ -172,7 +176,6 @@ bool gFlagPrepareTX; bool gFlagAcceptSetting; bool gFlagRefreshSetting; -bool gFlagBackupSetting; bool gFlagSaveVfo; bool gFlagSaveSettings; diff --git a/misc.h b/misc.h index 2dca736..5d8bd8a 100644 --- a/misc.h +++ b/misc.h @@ -96,6 +96,7 @@ extern const uint16_t fm_play_countdown_noscan_10ms; extern const uint16_t fm_restore_countdown_10ms; extern const uint8_t menu_timeout_500ms; +extern const uint16_t menu_timeout_long_500ms; extern const uint8_t DTMF_RX_live_timeout_500ms; extern const uint8_t DTMF_RX_timeout_500ms; @@ -194,6 +195,9 @@ extern volatile uint16_t gDualWatchCountdown_10ms; extern volatile bool gDualWatchCountdownExpired; extern bool gDualWatchActive; +extern volatile uint8_t gSerialConfigCountDown_500ms; +extern volatile bool gSerialConfigCountDown_done; + extern volatile bool gNextTimeslice_500ms; extern volatile uint16_t gTxTimerCountdown_500ms; @@ -225,7 +229,7 @@ extern uint8_t gBatteryVoltageIndex; extern CssScanMode_t gCssScanMode; extern bool gUpdateRSSI; extern AlarmState_t gAlarmState; -extern uint8_t gVoltageMenuCountdown; +extern uint16_t gMenuCountdown; extern bool gPttWasReleased; extern bool gPttWasPressed; extern bool gFlagReconfigureVfos; @@ -242,7 +246,6 @@ extern bool gFlagPrepareTX; extern bool gFlagAcceptSetting; // accept menu setting extern bool gFlagRefreshSetting; // refresh menu display -extern bool gFlagBackupSetting; // save a copy of the current menu setting extern bool gFlagSaveVfo; extern bool gFlagSaveSettings; @@ -267,7 +270,7 @@ extern uint8_t gNextMrChannel; extern ReceptionMode_t gRxReceptionMode; extern uint8_t gRestoreMrChannel; -extern uint8_t gCurrentScanList; +extern scan_next_chan_t gCurrentScanList; extern uint32_t gRestoreFrequency; extern bool gRxVfoIsActive; diff --git a/scheduler.c b/scheduler.c index ca0121c..2afecfa 100644 --- a/scheduler.c +++ b/scheduler.c @@ -57,6 +57,7 @@ void SystickHandler(void) gNextTimeslice_500ms = true; DECREMENT_AND_TRIGGER(gTxTimerCountdown_500ms, gTxTimeoutReached); + DECREMENT_AND_TRIGGER(gSerialConfigCountDown_500ms, gSerialConfigCountDown_done); } if ((gGlobalSysTickCounter & 3) == 0) diff --git a/ui/menu.c b/ui/menu.c index 2c0f243..76cbd2f 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -335,7 +335,6 @@ bool gIsInSubMenu; uint8_t gMenuCursor; int8_t gMenuScrollDirection; int32_t gSubMenuSelection; -int32_t gSubMenuSelection_original = 0; // copy of the original value // edit box char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/difference diff --git a/ui/menu.h b/ui/menu.h index f6646b8..f9bf805 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -159,7 +159,6 @@ extern bool gIsInSubMenu; extern uint8_t gMenuCursor; extern int8_t gMenuScrollDirection; extern int32_t gSubMenuSelection; -extern int32_t gSubMenuSelection_original; extern char edit_original[17]; extern char edit[17];