diff --git a/app/app.c b/app/app.c index f38feab..df9f4fa 100644 --- a/app/app.c +++ b/app/app.c @@ -432,7 +432,7 @@ void APP_StartListening(FUNCTION_Type_t Function) if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) { gRxVfoIsActive = true; - + gDualWatchCountdown = dual_watch_count_after_2; gScheduleDualWatch = false; } @@ -650,7 +650,7 @@ void APP_CheckRadioInterrupts(void) if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode) { gBatterySave = 20; - gBatterySaveCountdownExpired = 0; + gBatterySaveCountdownExpired = false; } if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown < dual_watch_count_after_vox)) @@ -926,12 +926,12 @@ void APP_Update(void) gCssScanMode != CSS_SCAN_MODE_OFF || gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE) - gBatterySaveCountdown = 1000; + gBatterySaveCountdown = battery_save_count; else if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode) FUNCTION_Select(FUNCTION_POWER_SAVE); else - gBatterySaveCountdown = 1000; + gBatterySaveCountdown = battery_save_count; #else if (gFmRadioMode || gPttIsPressed || @@ -941,7 +941,7 @@ void APP_Update(void) gCssScanMode != CSS_SCAN_MODE_OFF || gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE) - gBatterySaveCountdown = 1000; + gBatterySaveCountdown = battery_save_count; else FUNCTION_Select(FUNCTION_POWER_SAVE); #endif @@ -1435,9 +1435,9 @@ void APP_TimeSlice500ms(void) if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode) { if (--gKeyLockCountdown == 0) - gEeprom.KEY_LOCK = true; + gEeprom.KEY_LOCK = true; // lock the keyboard - gUpdateStatus = true; + gUpdateStatus = true; // lock symbol needs showing } if (gVoltageMenuCountdown > 0) @@ -1453,6 +1453,7 @@ void APP_TimeSlice500ms(void) RADIO_ConfigureChannel(0, 2); RADIO_ConfigureChannel(1, 2); + RADIO_SetupRegisters(true); } @@ -1644,10 +1645,10 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gCurrentFunction == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); - gBatterySaveCountdown = 1000; + gBatterySaveCountdown = battery_save_count; if (gEeprom.AUTO_KEYPAD_LOCK) - gKeyLockCountdown = 30; + gKeyLockCountdown = 30; // 15 seconds if (!bKeyPressed) { @@ -1698,41 +1699,32 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } if (gEeprom.KEY_LOCK && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT) - { + { // keyboard is locked + if (Key == KEY_F) - { - if (!bKeyHeld) - { - if (!bKeyPressed) - return; - - if (bKeyHeld) - return; - - AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); - - gKeypadLocked = 4; - - gUpdateDisplay = true; - return; - } + { // function/key-lock key if (!bKeyPressed) return; + + if (!bKeyHeld) + { + // keypad is locked, tell the user + AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); + gKeypadLocked = 4; + gUpdateDisplay = true; + return; + } } else if (Key != KEY_SIDE1 && Key != KEY_SIDE2) { - if (!bKeyPressed) - return; - - if (bKeyHeld) + if (!bKeyPressed || bKeyHeld) return; + // keypad is locked, tell the user AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); - - gKeypadLocked = 4; - + gKeypadLocked = 4; gUpdateDisplay = true; return; } diff --git a/firmware b/firmware index db86f3d..0ae34d7 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index e308153..e92fb67 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 7273796..3ed4546 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index c1f7c49..0853767 100644 --- a/functions.c +++ b/functions.c @@ -184,7 +184,8 @@ void FUNCTION_Select(FUNCTION_Type_t Function) break; } - gBatterySaveCountdown = 1000; + gBatterySaveCountdown = battery_save_count; gSchedulePowerSave = false; + gFM_RestoreCountdown = Countdown; } diff --git a/misc.c b/misc.c index 5a53cfd..7f3d79d 100644 --- a/misc.c +++ b/misc.c @@ -30,6 +30,8 @@ const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0xFFD2DABB, 0x6BB const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31}; +const uint16_t battery_save_count = 10000 / 10; // 10 seconds + // 10ms count down resolution const uint16_t dual_watch_count_after_tx = 3600 / 10; // 3.6 sec after TX ends const uint16_t dual_watch_count_after_rx = 1000 / 10; // 1 sec after RX ends ? @@ -65,13 +67,14 @@ uint16_t gEEPROM_1F8C; uint8_t gMR_ChannelAttributes[207]; volatile bool gNextTimeslice500ms; -volatile uint16_t gBatterySaveCountdown = 1000; +volatile uint16_t gBatterySaveCountdown = battery_save_count; volatile uint16_t gDualWatchCountdown; volatile uint16_t gTxTimerCountdown; volatile uint16_t gTailNoteEliminationCountdown; #ifndef DISABLE_NOAA volatile uint16_t gNOAA_Countdown; #endif + bool gEnableSpeaker; uint8_t gKeyLockCountdown; uint8_t gRTTECountdown; @@ -148,10 +151,11 @@ uint8_t gNeverUsed; uint8_t gNoaaChannel; #endif -volatile bool gNextTimeslice; bool gUpdateDisplay; bool gF_LOCK; uint8_t gShowChPrefix; + +volatile bool gNextTimeslice; volatile uint16_t gSystickCountdown2; volatile uint8_t gFoundCDCSSCountdown; volatile uint8_t gFoundCTCSSCountdown; diff --git a/misc.h b/misc.h index f87ccc3..c98764e 100644 --- a/misc.h +++ b/misc.h @@ -83,6 +83,8 @@ extern const uint16_t gMin_bat_v; extern const uint8_t gMicGain_dB2[5]; +extern const uint16_t battery_save_count; + extern const uint16_t dual_watch_count_after_tx; extern const uint16_t dual_watch_count_after_rx; extern const uint16_t dual_watch_count_after_1; diff --git a/ui/main.c b/ui/main.c index 8c75895..5211962 100644 --- a/ui/main.c +++ b/ui/main.c @@ -36,7 +36,7 @@ void UI_DisplayMain(void) memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); - if (gEeprom.KEY_LOCK && gKeypadLocked) + if (gEeprom.KEY_LOCK && gKeypadLocked > 0) { UI_PrintString("Long press #", 0, display_width - 1, 1, 8); UI_PrintString("to unlock", 0, display_width - 1, 3, 8);