mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 22:58:04 +03:00
Live DTMF decoder display tidy up
This commit is contained in:
56
app/app.c
56
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)
|
||||
|
@ -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;
|
||||
|
||||
|
18
app/fm.c
18
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;
|
||||
|
46
app/fm.h
46
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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
14
app/uart.c
14
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)
|
||||
|
Reference in New Issue
Block a user