diff --git a/app/app.c b/app/app.c index 738fa5e..fb1eb59 100644 --- a/app/app.c +++ b/app/app.c @@ -650,28 +650,30 @@ void APP_CheckRadioInterrupts(void) // fetch the RX'ed char const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code()); - - gDTMF_RequestPending = true; - gDTMF_RecvTimeout = DTMF_RX_timeout_500ms; - // shift the RX buffer down one - if need be - if (gDTMF_WriteIndex >= sizeof(gDTMF_Received)) - memmove(gDTMF_Received, &gDTMF_Received[1], gDTMF_WriteIndex-- - 1); - gDTMF_Received[gDTMF_WriteIndex++] = c; - - if (gCurrentFunction == FUNCTION_RECEIVE) + if (c != 0xff) { - #ifdef ENABLE_DTMF_DECODER - gDTMF_RecvTimeoutSaved = DTMF_RX_timeout_saved_500ms; - size_t len = strlen(gDTMF_ReceivedSaved); - // shift the RX buffer down one - if (len >= (sizeof(gDTMF_ReceivedSaved) - 1)) - memmove(gDTMF_ReceivedSaved, &gDTMF_ReceivedSaved[1], len--); - gDTMF_ReceivedSaved[len++] = c; - gDTMF_ReceivedSaved[len] = '\0'; - gUpdateDisplay = true; - #endif - - DTMF_HandleRequest(); + gDTMF_RequestPending = true; + gDTMF_RecvTimeout = DTMF_RX_timeout_500ms; + // shift the RX buffer down one - if need be + if (gDTMF_WriteIndex >= sizeof(gDTMF_Received)) + memmove(gDTMF_Received, &gDTMF_Received[1], gDTMF_WriteIndex-- - 1); + gDTMF_Received[gDTMF_WriteIndex++] = c; + + if (gCurrentFunction == FUNCTION_RECEIVE) + { + #ifdef ENABLE_DTMF_DECODER + gDTMF_RecvTimeoutSaved = DTMF_RX_timeout_saved_500ms; + size_t len = strlen(gDTMF_ReceivedSaved); + // shift the RX buffer down one - if need be + if (len >= (sizeof(gDTMF_ReceivedSaved) - 1)) + memmove(gDTMF_ReceivedSaved, &gDTMF_ReceivedSaved[1], len--); + gDTMF_ReceivedSaved[len++] = c; + gDTMF_ReceivedSaved[len] = '\0'; + gUpdateDisplay = true; + #endif + + DTMF_HandleRequest(); + } } } @@ -877,7 +879,7 @@ void APP_Update(void) APP_HandleFunction(); #ifdef ENABLE_FMRADIO - if (gFmRadioCountdown) + if (gFmRadioCountdown_500ms > 0) return; #endif @@ -1253,7 +1255,7 @@ void APP_TimeSlice10ms(void) // Skipping authentic device checks #ifdef ENABLE_FMRADIO - if (gFmRadioCountdown > 0) + if (gFmRadioCountdown_500ms > 0) return; #endif @@ -1496,9 +1498,9 @@ void APP_TimeSlice500ms(void) // Skipped authentic device check #ifdef ENABLE_FMRADIO - if (gFmRadioCountdown > 0) + if (gFmRadioCountdown_500ms > 0) { - gFmRadioCountdown--; + gFmRadioCountdown_500ms--; return; } #endif @@ -1597,9 +1599,9 @@ void APP_TimeSlice500ms(void) } #ifdef ENABLE_FMRADIO - if (!gPttIsPressed && gFM_ResumeCountdown > 0) + if (!gPttIsPressed && gFM_ResumeCountdown_500ms > 0) { - if (--gFM_ResumeCountdown == 0) + if (--gFM_ResumeCountdown_500ms == 0) { RADIO_SetVfoState(VFO_STATE_NORMAL); if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR && gFmRadioMode) diff --git a/app/dtmf.c b/app/dtmf.c index 6a93a75..126552c 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -113,7 +113,7 @@ bool DTMF_FindContact(const char *pContact, char *pResult) if (j == 3) { - memcpy(pResult, Contact, 8); + memmove(pResult, Contact, 8); pResult[8] = 0; return true; } @@ -263,8 +263,8 @@ void DTMF_HandleRequest(void) if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 4, true)) { gDTMF_CallState = DTMF_CALL_STATE_RECEIVED; - memcpy(gDTMF_Callee, gDTMF_Received + Offset, 3); - memcpy(gDTMF_Caller, gDTMF_Received + Offset + 4, 3); + memmove(gDTMF_Callee, gDTMF_Received + Offset, 3); + memmove(gDTMF_Caller, gDTMF_Received + Offset + 4, 3); gUpdateDisplay = true; diff --git a/app/fm.c b/app/fm.c index 56eb4ba..1573ab9 100644 --- a/app/fm.c +++ b/app/fm.c @@ -38,14 +38,14 @@ uint16_t gFM_Channels[20]; bool gFmRadioMode; -uint8_t gFmRadioCountdown; -volatile uint16_t gFmPlayCountdown; +uint8_t gFmRadioCountdown_500ms; +volatile uint16_t gFmPlayCountdown_10ms; volatile int8_t gFM_ScanState; bool gFM_AutoScan; uint8_t gFM_ChannelPosition; bool gFM_FoundFrequency; bool gFM_AutoScan; -uint8_t gFM_ResumeCountdown; +uint8_t gFM_ResumeCountdown_500ms; uint16_t gFM_RestoreCountdown; bool FM_CheckValidChannel(uint8_t Channel) @@ -120,7 +120,7 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag) gEnableSpeaker = false; - gFmPlayCountdown = (gFM_ScanState == FM_SCAN_OFF) ? 120 : 10; + gFmPlayCountdown_10ms = (gFM_ScanState == FM_SCAN_OFF) ? fm_play_countdown_noscan_10ms : fm_play_countdown_scan_10ms; gScheduleFM = false; gFM_FoundFrequency = false; @@ -159,9 +159,9 @@ void FM_PlayAndUpdate(void) BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); SETTINGS_SaveFM(); - gFmPlayCountdown = 0; - gScheduleFM = false; - gAskToSave = false; + gFmPlayCountdown_10ms = 0; + gScheduleFM = false; + gAskToSave = false; GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); @@ -617,8 +617,8 @@ void FM_Play(void) { if (!gFM_AutoScan) { - gFmPlayCountdown = 0; - gFM_FoundFrequency = true; + gFmPlayCountdown_10ms = 0; + gFM_FoundFrequency = true; if (!gEeprom.FM_IsMrMode) gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; diff --git a/app/fm.h b/app/fm.h index eef7b6f..462852a 100644 --- a/app/fm.h +++ b/app/fm.h @@ -28,34 +28,34 @@ enum { FM_SCAN_OFF = 0U, }; -extern uint16_t gFM_Channels[20]; -extern bool gFmRadioMode; -extern uint8_t gFmRadioCountdown; -extern volatile uint16_t gFmPlayCountdown; -extern volatile int8_t gFM_ScanState; -extern bool gFM_AutoScan; -extern uint8_t gFM_ChannelPosition; -// Doubts about whether this should be signed or not. -extern uint16_t gFM_FrequencyDeviation; -extern bool gFM_FoundFrequency; -extern bool gFM_AutoScan; -extern uint8_t gFM_ResumeCountdown; -extern uint16_t gFM_RestoreCountdown; +extern uint16_t gFM_Channels[20]; +extern bool gFmRadioMode; +extern uint8_t gFmRadioCountdown_500ms; +extern volatile uint16_t gFmPlayCountdown_10ms; +extern volatile int8_t gFM_ScanState; +extern bool gFM_AutoScan; +extern uint8_t gFM_ChannelPosition; +// Doubts about whether this should be signed or not +extern uint16_t gFM_FrequencyDeviation; +extern bool gFM_FoundFrequency; +extern bool gFM_AutoScan; +extern uint8_t gFM_ResumeCountdown_500ms; +extern uint16_t gFM_RestoreCountdown; -bool FM_CheckValidChannel(uint8_t Channel); +bool FM_CheckValidChannel(uint8_t Channel); uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction); -int FM_ConfigureChannelState(void); -void FM_TurnOff(void); -void FM_EraseChannels(void); +int FM_ConfigureChannelState(void); +void FM_TurnOff(void); +void FM_EraseChannels(void); -void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag); -void FM_PlayAndUpdate(void); -int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit); +void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag); +void FM_PlayAndUpdate(void); +int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit); -void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); +void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); -void FM_Play(void); -void FM_Start(void); +void FM_Play(void); +void FM_Start(void); #endif diff --git a/app/main.c b/app/main.c index e6402ca..422c57c 100644 --- a/app/main.c +++ b/app/main.c @@ -509,7 +509,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) { gKeyInputCountdown = key_input_timeout_500ms; gDTMF_InputMode = true; - memcpy(gDTMF_InputBox, gDTMF_String, 15); + memmove(gDTMF_InputBox, gDTMF_String, 15); gDTMF_InputIndex = 0; gRequestDisplayScreen = DISPLAY_MAIN; return; diff --git a/app/menu.c b/app/menu.c index 08febd9..7c4f89b 100644 --- a/app/menu.c +++ b/app/menu.c @@ -616,7 +616,7 @@ void MENU_AcceptSetting(void) GUI_SelectNextDisplay(DISPLAY_MAIN); gDTMF_InputMode = true; gDTMF_InputIndex = 3; - memcpy(gDTMF_InputBox, gDTMF_ID, 4); + memmove(gDTMF_InputBox, gDTMF_ID, 4); gRequestDisplayScreen = DISPLAY_INVALID; } return; diff --git a/app/uart.c b/app/uart.c index 96fc79f..cb34c71 100644 --- a/app/uart.c +++ b/app/uart.c @@ -223,7 +223,7 @@ static void CMD_0514(const uint8_t *pBuffer) Timestamp = pCmd->Timestamp; #ifdef ENABLE_FMRADIO - gFmRadioCountdown = 4; + gFmRadioCountdown_500ms = fm_radio_countdown_500ms; #endif GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); SendVersion(); @@ -240,7 +240,7 @@ static void CMD_051B(const uint8_t *pBuffer) } #ifdef ENABLE_FMRADIO - gFmRadioCountdown = 4; + gFmRadioCountdown_500ms = fm_radio_countdown_500ms; #endif memset(&Reply, 0, sizeof(Reply)); Reply.Header.ID = 0x051C; @@ -273,7 +273,7 @@ static void CMD_051D(const uint8_t *pBuffer) bReloadEeprom = false; #ifdef ENABLE_FMRADIO - gFmRadioCountdown = 4; + gFmRadioCountdown_500ms = fm_radio_countdown_500ms; #endif Reply.Header.ID = 0x051E; Reply.Header.Size = sizeof(Reply.Data); @@ -340,7 +340,7 @@ static void CMD_052D(const uint8_t *pBuffer) bool bIsLocked; #ifdef ENABLE_FMRADIO - gFmRadioCountdown = 4; + gFmRadioCountdown_500ms = fm_radio_countdown_500ms; #endif Reply.Header.ID = 0x052E; Reply.Header.Size = sizeof(Reply.Data); @@ -458,11 +458,11 @@ bool UART_IsCommandAvailable(void) if (TailIndex < Index) { const uint16_t ChunkSize = sizeof(UART_DMA_Buffer) - Index; - memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize); - memcpy(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex); + memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize); + memmove(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex); } else - memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index); + memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index); TailIndex = DMA_INDEX(TailIndex, 2); if (TailIndex < gUART_WriteIndex) diff --git a/board.c b/board.c index 2b341b8..5d3e35c 100644 --- a/board.c +++ b/board.c @@ -609,7 +609,7 @@ void BOARD_EEPROM_Init(void) // 0E98..0E9F EEPROM_ReadBuffer(0x0E98, Data, 8); - memcpy(&gEeprom.POWER_ON_PASSWORD, Data, 4); + memmove(&gEeprom.POWER_ON_PASSWORD, Data, 4); // 0EA0..0EA7 #ifdef ENABLE_VOICE @@ -646,38 +646,38 @@ void BOARD_EEPROM_Init(void) // 0EE0..0EE7 EEPROM_ReadBuffer(0x0EE0, Data, 8); if (DTMF_ValidateCodes((char *)Data, 8)) - memcpy(gEeprom.ANI_DTMF_ID, Data, 8); + memmove(gEeprom.ANI_DTMF_ID, Data, 8); else // Original firmware overflows into the next string - memcpy(gEeprom.ANI_DTMF_ID, "123\0\0\0\0", 8); + memmove(gEeprom.ANI_DTMF_ID, "123\0\0\0\0", 8); // 0EE8..0EEF EEPROM_ReadBuffer(0x0EE8, Data, 8); if (DTMF_ValidateCodes((char *)Data, 8)) - memcpy(gEeprom.KILL_CODE, Data, 8); + memmove(gEeprom.KILL_CODE, Data, 8); else - memcpy(gEeprom.KILL_CODE, "ABCD9\0\0", 8); + memmove(gEeprom.KILL_CODE, "ABCD9\0\0", 8); // 0EF0..0EF7 EEPROM_ReadBuffer(0x0EF0, Data, 8); if (DTMF_ValidateCodes((char *)Data, 8)) - memcpy(gEeprom.REVIVE_CODE, Data, 8); + memmove(gEeprom.REVIVE_CODE, Data, 8); else - memcpy(gEeprom.REVIVE_CODE, "9DCBA\0\0", 8); + memmove(gEeprom.REVIVE_CODE, "9DCBA\0\0", 8); // 0EF8..0F07 EEPROM_ReadBuffer(0x0EF8, Data, 16); if (DTMF_ValidateCodes((char *)Data, 16)) - memcpy(gEeprom.DTMF_UP_CODE, Data, 16); + memmove(gEeprom.DTMF_UP_CODE, Data, 16); else - memcpy(gEeprom.DTMF_UP_CODE, "12345\0\0\0\0\0\0\0\0\0\0", 16); + memmove(gEeprom.DTMF_UP_CODE, "12345\0\0\0\0\0\0\0\0\0\0", 16); // 0F08..0F17 EEPROM_ReadBuffer(0x0F08, Data, 16); if (DTMF_ValidateCodes((char *)Data, 16)) - memcpy(gEeprom.DTMF_DOWN_CODE, Data, 16); + memmove(gEeprom.DTMF_DOWN_CODE, Data, 16); else - memcpy(gEeprom.DTMF_DOWN_CODE, "54321\0\0\0\0\0\0\0\0\0\0", 16); + memmove(gEeprom.DTMF_DOWN_CODE, "54321\0\0\0\0\0\0\0\0\0\0", 16); // 0F18..0F1F EEPROM_ReadBuffer(0x0F18, Data, 8); @@ -728,16 +728,16 @@ void BOARD_EEPROM_LoadMoreSettings(void) // uint8_t Mic; EEPROM_ReadBuffer(0x1EC0, gEEPROM_1EC0_0, 8); - memcpy(gEEPROM_1EC0_1, gEEPROM_1EC0_0, 8); - memcpy(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8); - memcpy(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8); + memmove(gEEPROM_1EC0_1, gEEPROM_1EC0_0, 8); + memmove(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8); + memmove(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8); // 3 bands, 4 * 16-bit values per band // both my radios are -70dBm, -65dBm, -60dBm, -55dBm (0xB4, 0xBE, 0xC8, 0xD2) // -93, -75, -57, -39 seems to be a better choice (0x86, 0xAA, 0xCE, 0xF2) EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[0], 8); - memcpy(gEEPROM_RSSI_CALIB[1], gEEPROM_RSSI_CALIB[0], 8); - memcpy(gEEPROM_RSSI_CALIB[2], gEEPROM_RSSI_CALIB[0], 8); + memmove(gEEPROM_RSSI_CALIB[1], gEEPROM_RSSI_CALIB[0], 8); + memmove(gEEPROM_RSSI_CALIB[2], gEEPROM_RSSI_CALIB[0], 8); EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12); if (gBatteryCalibration[0] >= 5000) diff --git a/firmware b/firmware index 33c0a7a..c5fb271 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index 4f911f5..7f427a8 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 370dcfd..cc72b90 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 845184a..32fb1d8 100644 --- a/functions.c +++ b/functions.c @@ -134,11 +134,14 @@ void FUNCTION_Select(FUNCTION_Type_t Function) case FUNCTION_POWER_SAVE: gBatterySave = gEeprom.BATTERY_SAVE * 10; gRxIdleMode = true; + BK4819_DisableVox(); BK4819_Sleep(); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); + gBatterySaveCountdownExpired = false; gUpdateStatus = true; + GUI_SelectNextDisplay(DISPLAY_MAIN); return; @@ -184,8 +187,8 @@ void FUNCTION_Select(FUNCTION_Type_t Function) } #endif - if (gCurrentVfo->SCRAMBLING_TYPE && gSetting_ScrambleEnable) - BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1U); + if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) + BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); else BK4819_DisableScramble(); diff --git a/misc.c b/misc.c index 759e0ae..d9d6f27 100644 --- a/misc.c +++ b/misc.c @@ -18,6 +18,11 @@ #include "misc.h" +const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds +const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds +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 uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds const uint8_t DTMF_RX_timeout_500ms = 2500 / 500; // 2.5 seconds diff --git a/misc.h b/misc.h index 91289d6..4062f02 100644 --- a/misc.h +++ b/misc.h @@ -78,6 +78,11 @@ enum CssScanMode_t typedef enum CssScanMode_t CssScanMode_t; +extern const uint8_t fm_resume_countdown_500ms; +extern const uint8_t fm_radio_countdown_500ms; +extern const uint16_t fm_play_countdown_scan_10ms; +extern const uint16_t fm_play_countdown_noscan_10ms; + extern const uint8_t menu_timeout_500ms; extern const uint8_t DTMF_RX_timeout_500ms; @@ -138,7 +143,7 @@ extern volatile uint16_t gDualWatchCountdown; extern volatile uint16_t gTxTimerCountdown; extern volatile uint16_t gTailNoteEliminationCountdown; #ifdef ENABLE_FMRADIO - extern volatile uint16_t gFmPlayCountdown; + extern volatile uint16_t gFmPlayCountdown_10ms; #endif #ifdef ENABLE_NOAA extern volatile uint16_t gNOAA_Countdown; diff --git a/radio.c b/radio.c index aa488fb..4a3f174 100644 --- a/radio.c +++ b/radio.c @@ -645,10 +645,10 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) break; } - if (gRxVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable) - BK4819_DisableScramble(); - else + if (gRxVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) BK4819_EnableScramble(gRxVfo->SCRAMBLING_TYPE - 1); + else + BK4819_DisableScramble(); } } #ifdef ENABLE_NOAA @@ -688,18 +688,26 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) #endif #ifndef ENABLE_DTMF_DECODER + // there's no reason the DTMF decoder can't be used in AM RX mode too + // aircraft comms use it on HF (AM and SSB) if (gRxVfo->IsAM || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)) { BK4819_DisableDTMF(); } else + { + BK4819_EnableDTMF(); + InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND; + } + #else + if (!gSetting_KILLED) + { + BK4819_EnableDTMF(); + InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND; + } #endif - { - BK4819_EnableDTMF(); - InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND; - } - // enable/disable BK4819 interrupts + // enable/disable BK4819 selected interrupts BK4819_WriteRegister(BK4819_REG_3F, InterruptMask); FUNCTION_Init(); @@ -765,7 +773,7 @@ void RADIO_SetTxParameters(void) Bandwidth = gCurrentVfo->CHANNEL_BANDWIDTH; if (Bandwidth != BK4819_FILTER_BW_WIDE) - Bandwidth = BK4819_FILTER_BW_NARROW; + Bandwidth = BK4819_FILTER_BW_NARROW; BK4819_SetFilterBandwidth(Bandwidth); BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); @@ -816,7 +824,7 @@ void RADIO_SetVfoState(VfoState_t State) VfoState[1] = VFO_STATE_NORMAL; #ifdef ENABLE_FMRADIO - gFM_ResumeCountdown = 0; + gFM_ResumeCountdown_500ms = 0; #endif } else @@ -833,7 +841,7 @@ void RADIO_SetVfoState(VfoState_t State) } #ifdef ENABLE_FMRADIO - gFM_ResumeCountdown = 5; + gFM_ResumeCountdown_500ms = fm_resume_countdown_500ms; #endif } @@ -858,7 +866,9 @@ void RADIO_PrepareTX(void) RADIO_SelectCurrentVfo(); #ifdef ENABLE_ALARM - if (gAlarmState == ALARM_STATE_OFF || gAlarmState == ALARM_STATE_TX1750 || (gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE)) + if (gAlarmState == ALARM_STATE_OFF || + gAlarmState == ALARM_STATE_TX1750 || + (gAlarmState == ALARM_STATE_ALARM && gEeprom.ALARM_MODE == ALARM_MODE_TONE)) #endif { VfoState_t State; @@ -892,10 +902,9 @@ void RADIO_PrepareTX(void) gAlarmState = ALARM_STATE_OFF; #endif - AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); - gDTMF_ReplyState = DTMF_REPLY_NONE; + AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); return; } @@ -953,7 +962,9 @@ void RADIO_EnableCxCSS(void) void RADIO_PrepareCssTX(void) { RADIO_PrepareTX(); + SYSTEM_DelayMs(200); + RADIO_EnableCxCSS(); RADIO_SetupRegisters(true); } diff --git a/scheduler.c b/scheduler.c index 27a441b..94a6ce7 100644 --- a/scheduler.c +++ b/scheduler.c @@ -98,7 +98,7 @@ void SystickHandler(void) #ifdef ENABLE_FMRADIO if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR) if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE) - DECREMENT_AND_TRIGGER(gFmPlayCountdown, gScheduleFM); + DECREMENT_AND_TRIGGER(gFmPlayCountdown_10ms, gScheduleFM); #endif if (gVoxStopCountdown) diff --git a/ui/helper.c b/ui/helper.c index 8510eef..83b3b43 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -76,8 +76,8 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin { const unsigned int Index = pString[i] - ' '; const unsigned int ofs = (unsigned int)Start + (i * Width); - memcpy(gFrameBuffer[Line + 0] + ofs, &gFontBig[Index][0], 8); - memcpy(gFrameBuffer[Line + 1] + ofs, &gFontBig[Index][8], 7); + memmove(gFrameBuffer[Line + 0] + ofs, &gFontBig[Index][0], 8); + memmove(gFrameBuffer[Line + 1] + ofs, &gFontBig[Index][8], 7); } } } @@ -99,7 +99,7 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ { const unsigned int Index = (unsigned int)pString[i] - 32; if (Index < ARRAY_SIZE(gFontSmall)) - memcpy(pFb + (i * char_spacing), &gFontSmall[Index], char_width); + memmove(pFb + (i * char_spacing), &gFontSmall[Index], char_width); } } } @@ -119,8 +119,8 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla if (bDisplayLeadingZero || bCanDisplay || Digit > 0) { bCanDisplay = true; - memcpy(pFb0, gFontBigDigits[Digit], char_width); - memcpy(pFb1, gFontBigDigits[Digit] + char_width, char_width); + memmove(pFb0, gFontBigDigits[Digit], char_width); + memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width); } else if (bFlag) @@ -141,8 +141,8 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla while (i < 6) { const unsigned int Digit = pDigits[i++]; - memcpy(pFb0, gFontBigDigits[Digit], char_width); - memcpy(pFb1, gFontBigDigits[Digit] + char_width, char_width); + memmove(pFb0, gFontBigDigits[Digit], char_width); + memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width); pFb0 += char_width; pFb1 += char_width; } @@ -162,7 +162,7 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD if (bDisplayLeadingZero || bCanDisplay || Digit > 0) { bCanDisplay = true; - memcpy(pFb, gFontSmallDigits[Digit], char_width); + memmove(pFb, gFontSmallDigits[Digit], char_width); pFb += char_width; } } @@ -178,7 +178,7 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD while (i < 8) { const unsigned int Digit = pDigits[i++]; - memcpy(pFb, gFontSmallDigits[Digit], char_width); + memmove(pFb, gFontSmallDigits[Digit], char_width); pFb += char_width; } } @@ -196,7 +196,7 @@ void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, display = true; if (display && c < ARRAY_SIZE(gFontSmallDigits)) { - memcpy(gFrameBuffer[y] + xx, gFontSmallDigits[c], char_width); + memmove(gFrameBuffer[y] + xx, gFontSmallDigits[c], char_width); xx += char_width; } } diff --git a/ui/main.c b/ui/main.c index f9f7e38..3e22201 100644 --- a/ui/main.c +++ b/ui/main.c @@ -54,6 +54,10 @@ void UI_DisplayMain(void) const bool single_vfo = false; // #endif + #ifdef ENABLE_DTMF_DECODER + bool show_dtmf_rx = true; + #endif + for (vfo_num = 0; vfo_num < 2; vfo_num++) { uint8_t Channel = gEeprom.TX_CHANNEL; @@ -112,24 +116,28 @@ void UI_DisplayMain(void) } UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8); + #ifdef ENABLE_DTMF_DECODER + show_dtmf_rx = false; + #endif + continue; } // highlight the selected/used VFO with a marker if (!single_vfo && bIsSameVfo) - memcpy(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + memmove(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); else if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) - memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); + memmove(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); } else if (!single_vfo) { // highlight the selected/used VFO with a marker if (bIsSameVfo) - memcpy(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + memmove(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); else //if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) - memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); + memmove(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); } uint32_t SomeValue = 0; @@ -167,7 +175,7 @@ void UI_DisplayMain(void) if (!inputting) NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); // show the memory channel number else - memcpy(String + 5, gInputBox, 3); // show the input text + memmove(String + 5, gInputBox, 3); // show the input text UI_PrintStringSmall("M", x, 0, Line + 1); UI_DisplaySmallDigits(3, String + 5, x + 7, Line + 1, inputting); } @@ -234,9 +242,9 @@ void UI_DisplayMain(void) { // show the scanlist symbols const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; if (Attributes & MR_CH_SCANLIST1) - memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); + memmove(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); if (Attributes & MR_CH_SCANLIST2) - memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); + memmove(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); } switch (gEeprom.CHANNEL_DISPLAY_MODE) @@ -270,7 +278,7 @@ void UI_DisplayMain(void) else { // channel name memset(String, 0, sizeof(String)); - memcpy(String, gEeprom.VfoInfo[vfo_num].Name, 10); + memmove(String, gEeprom.VfoInfo[vfo_num].Name, 10); } UI_PrintString(String, 31, 112, Line, 8); break; @@ -285,7 +293,7 @@ void UI_DisplayMain(void) else { // channel name memset(String, 0, sizeof(String)); - memcpy(String, gEeprom.VfoInfo[vfo_num].Name, 10); + memmove(String, gEeprom.VfoInfo[vfo_num].Name, 10); } UI_PrintStringSmall(String, 31 + 8, 0, Line); @@ -336,18 +344,18 @@ void UI_DisplayMain(void) if (Level >= 1) { - memcpy(pLine1 + display_width + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); - memcpy(pLine1 + display_width + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); + memmove(pLine1 + display_width + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); + memmove(pLine1 + display_width + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); if (Level >= 2) - memcpy(pLine1 + display_width + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); + memmove(pLine1 + display_width + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); if (Level >= 3) - memcpy(pLine1 + display_width + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); + memmove(pLine1 + display_width + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); if (Level >= 4) - memcpy(pLine1 + display_width + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); + memmove(pLine1 + display_width + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); if (Level >= 5) - memcpy(pLine1 + display_width + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); + memmove(pLine1 + display_width + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); if (Level >= 6) - memcpy(pLine1 + display_width + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); + memmove(pLine1 + display_width + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); } } @@ -404,7 +412,7 @@ void UI_DisplayMain(void) } #ifdef ENABLE_DTMF_DECODER - if (gDTMF_ReceivedSaved[0] >= 32) + if (show_dtmf_rx && gDTMF_ReceivedSaved[0] >= 32) { // show the incoming DTMF live on-screen UI_PrintStringSmall(gDTMF_ReceivedSaved, 8, 0, 3); } diff --git a/ui/menu.c b/ui/menu.c index 320796b..41c9a38 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -302,7 +302,7 @@ void UI_DisplayMenu(void) #endif if (gIsInSubMenu) - memcpy(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); + memmove(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); memset(String, 0, sizeof(String)); @@ -523,7 +523,7 @@ void UI_DisplayMenu(void) if (!gIsDtmfContactValid) strcpy(String, "NULL"); else - memcpy(String, Contact, 8); + memmove(String, Contact, 8); break; case MENU_PONMSG: @@ -650,7 +650,7 @@ void UI_DisplayMenu(void) if (gMenuCursor == MENU_D_LIST && gIsDtmfContactValid) { Contact[11] = 0; - memcpy(&gDTMF_ID, Contact + 8, 4); + memmove(&gDTMF_ID, Contact + 8, 4); sprintf(String, "ID:%s", Contact + 8); UI_PrintString(String, 50, 127, 4, 8); } diff --git a/ui/rssi.c b/ui/rssi.c index 7ed70db..0aa7cc3 100644 --- a/ui/rssi.c +++ b/ui/rssi.c @@ -53,19 +53,19 @@ static void Render(uint8_t RssiLevel, uint8_t VFO) } else { - memcpy(pLine, BITMAP_Antenna, 5); + memmove(pLine, BITMAP_Antenna, 5); if (RssiLevel >= 2) - memcpy(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); + memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); if (RssiLevel >= 3) - memcpy(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); + memmove(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); if (RssiLevel >= 4) - memcpy(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); + memmove(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); if (RssiLevel >= 5) - memcpy(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); + memmove(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); if (RssiLevel >= 6) - memcpy(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); + memmove(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); if (RssiLevel >= 7) - memcpy(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); + memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); } ST7565_DrawLine(0, Line, 23 , pLine, bIsClearMode); diff --git a/ui/status.c b/ui/status.c index af633ff..a4ae278 100644 --- a/ui/status.c +++ b/ui/status.c @@ -34,11 +34,11 @@ void UI_DisplayStatus(const bool test_display) memset(gStatusLine, 0, sizeof(gStatusLine)); if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display) - memcpy(gStatusLine, BITMAP_PowerSave, sizeof(BITMAP_PowerSave)); + memmove(gStatusLine, BITMAP_PowerSave, sizeof(BITMAP_PowerSave)); #ifdef ENABLE_NOAA if (gIsNoaaMode || test_display) - memcpy(gStatusLine + 7, BITMAP_NOAA, sizeof(BITMAP_NOAA)); + memmove(gStatusLine + 7, BITMAP_NOAA, sizeof(BITMAP_NOAA)); #endif if (gSetting_KILLED || test_display) @@ -46,46 +46,46 @@ void UI_DisplayStatus(const bool test_display) #ifdef ENABLE_FMRADIO else if (gFmRadioMode || test_display) - memcpy(gStatusLine + 21, BITMAP_FM, sizeof(BITMAP_FM)); + memmove(gStatusLine + 21, BITMAP_FM, sizeof(BITMAP_FM)); #endif #ifdef ENABLE_VOICE if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF || test_display) - memcpy(gStatusLine + 34, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt)); + memmove(gStatusLine + 34, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt)); #endif if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF || test_display) - memcpy(gStatusLine + 45, BITMAP_TDR, sizeof(BITMAP_TDR)); + memmove(gStatusLine + 45, BITMAP_TDR, sizeof(BITMAP_TDR)); if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF || test_display) - memcpy(gStatusLine + 58, BITMAP_XB, sizeof(BITMAP_XB)); + memmove(gStatusLine + 58, BITMAP_XB, sizeof(BITMAP_XB)); if (gEeprom.VOX_SWITCH || test_display) - memcpy(gStatusLine + 71, BITMAP_VOX, sizeof(BITMAP_VOX)); + memmove(gStatusLine + 71, BITMAP_VOX, sizeof(BITMAP_VOX)); if (gEeprom.KEY_LOCK || test_display) - memcpy(gStatusLine + 90, BITMAP_KeyLock, sizeof(BITMAP_KeyLock)); + memmove(gStatusLine + 90, BITMAP_KeyLock, sizeof(BITMAP_KeyLock)); else if (gWasFKeyPressed) - memcpy(gStatusLine + 90, BITMAP_F_Key, sizeof(BITMAP_F_Key)); + memmove(gStatusLine + 90, BITMAP_F_Key, sizeof(BITMAP_F_Key)); if (gChargingWithTypeC || test_display) - memcpy(gStatusLine + 100, BITMAP_USB_C, sizeof(BITMAP_USB_C)); + memmove(gStatusLine + 100, BITMAP_USB_C, sizeof(BITMAP_USB_C)); if (gBatteryDisplayLevel >= 5 || test_display) - memcpy(gStatusLine + 110, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5)); + memmove(gStatusLine + 110, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5)); else if (gBatteryDisplayLevel >= 4) - memcpy(gStatusLine + 110, BITMAP_BatteryLevel4, sizeof(BITMAP_BatteryLevel4)); + memmove(gStatusLine + 110, BITMAP_BatteryLevel4, sizeof(BITMAP_BatteryLevel4)); else if (gBatteryDisplayLevel >= 3) - memcpy(gStatusLine + 110, BITMAP_BatteryLevel3, sizeof(BITMAP_BatteryLevel3)); + memmove(gStatusLine + 110, BITMAP_BatteryLevel3, sizeof(BITMAP_BatteryLevel3)); else if (gBatteryDisplayLevel >= 2) - memcpy(gStatusLine + 110, BITMAP_BatteryLevel2, sizeof(BITMAP_BatteryLevel2)); + memmove(gStatusLine + 110, BITMAP_BatteryLevel2, sizeof(BITMAP_BatteryLevel2)); else if (gLowBatteryBlink == 1) - memcpy(gStatusLine + 110, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); + memmove(gStatusLine + 110, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); ST7565_BlitStatusLine(); }