mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 06:39:49 +03:00
Fix-n-clean DTMF live decoder
This commit is contained in:
63
app/app.c
63
app/app.c
@ -783,25 +783,26 @@ void APP_CheckRadioInterrupts(void)
|
||||
const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code());
|
||||
if (c != 0xff)
|
||||
{
|
||||
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 (gCurrentFunction == FUNCTION_RECEIVE ||
|
||||
gCurrentFunction == FUNCTION_INCOMING ||
|
||||
gCurrentFunction == FUNCTION_MONITOR)
|
||||
{
|
||||
{ // live 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;
|
||||
}
|
||||
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);
|
||||
gDTMF_Received[gDTMF_WriteIndex++] = c;
|
||||
|
||||
// live DTMF decoder
|
||||
size_t len = strlen(gDTMF_RX_live);
|
||||
// shift the RX buffer down one - if need be
|
||||
if (len >= (sizeof(gDTMF_RX_live) - 1))
|
||||
memmove(&gDTMF_RX_live[0], &gDTMF_RX_live[1], --len);
|
||||
gDTMF_RX_live[len++] = c;
|
||||
gDTMF_RX_live[len] = 0;
|
||||
gDTMF_RX_live_timeout = DTMF_RX_live_timeout_500ms; // time till we delete it
|
||||
gUpdateDisplay = true;
|
||||
|
||||
DTMF_HandleRequest();
|
||||
}
|
||||
@ -1687,6 +1688,15 @@ void APP_TimeSlice500ms(void)
|
||||
if (--gKeyInputCountdown == 0)
|
||||
cancelUserInputModes();
|
||||
|
||||
if (gDTMF_RX_live_timeout > 0)
|
||||
{
|
||||
if (--gDTMF_RX_live_timeout == 0)
|
||||
{
|
||||
gDTMF_RX_live[0] = 0;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Skipped authentic device check
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
@ -1936,15 +1946,6 @@ void APP_TimeSlice500ms(void)
|
||||
memset(gDTMF_Received, 0, sizeof(gDTMF_Received));
|
||||
}
|
||||
}
|
||||
|
||||
if (gDTMF_RecvTimeoutSaved > 0)
|
||||
{
|
||||
if (--gDTMF_RecvTimeoutSaved == 0)
|
||||
{
|
||||
gDTMF_ReceivedSaved[0] = '\0';
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
@ -2019,11 +2020,11 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
if (gEeprom.AUTO_KEYPAD_LOCK)
|
||||
gKeyLockCountdown = 30; // 15 seconds
|
||||
|
||||
if (Key == KEY_EXIT && bKeyPressed && bKeyHeld && gDTMF_ReceivedSaved[0] > 0)
|
||||
if (Key == KEY_EXIT && bKeyPressed && bKeyHeld && gDTMF_RX_live[0] != 0)
|
||||
{ // clear the live DTMF decoder if the EXIT key is held
|
||||
gDTMF_RecvTimeoutSaved = 0;
|
||||
gDTMF_ReceivedSaved[0] = '\0';
|
||||
gUpdateDisplay = true;
|
||||
gDTMF_RX_live_timeout = 0;
|
||||
gDTMF_RX_live[0] = 0;
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
|
||||
if (!bKeyPressed)
|
||||
|
@ -40,8 +40,8 @@ uint8_t gDTMF_WriteIndex = 0;
|
||||
uint8_t gDTMF_PreviousIndex = 0;
|
||||
uint8_t gDTMF_RecvTimeout = 0;
|
||||
|
||||
char gDTMF_ReceivedSaved[20];
|
||||
uint8_t gDTMF_RecvTimeoutSaved = 0;
|
||||
char gDTMF_RX_live[20];
|
||||
uint8_t gDTMF_RX_live_timeout = 0;
|
||||
|
||||
bool gIsDtmfContactValid;
|
||||
char gDTMF_ID[4];
|
||||
|
@ -63,8 +63,8 @@ extern uint8_t gDTMF_WriteIndex;
|
||||
extern uint8_t gDTMF_PreviousIndex;
|
||||
extern uint8_t gDTMF_RecvTimeout;
|
||||
|
||||
extern char gDTMF_ReceivedSaved[20];
|
||||
extern uint8_t gDTMF_RecvTimeoutSaved;
|
||||
extern char gDTMF_RX_live[20];
|
||||
extern uint8_t gDTMF_RX_live_timeout;
|
||||
|
||||
extern bool gIsDtmfContactValid;
|
||||
extern char gDTMF_ID[4];
|
||||
|
@ -595,8 +595,8 @@ void MENU_AcceptSetting(void)
|
||||
return;
|
||||
|
||||
case MENU_D_LIVE_DEC:
|
||||
gDTMF_RecvTimeoutSaved = 0;
|
||||
gDTMF_ReceivedSaved[0] = '\0';
|
||||
gDTMF_RX_live_timeout = 0;
|
||||
gDTMF_RX_live[0] = '\0';
|
||||
gSetting_live_DTMF_decoder = gSubMenuSelection;
|
||||
if (!gSetting_live_DTMF_decoder)
|
||||
BK4819_DisableDTMF();
|
||||
|
Reference in New Issue
Block a user