Improved DTMF and moved to app/dtmf.

This commit is contained in:
Dual Tachyon 2023-08-31 14:22:08 +01:00
parent b08f7c05b0
commit 630fd265d9
17 changed files with 343 additions and 336 deletions

View File

@ -36,6 +36,7 @@ OBJS += driver/uart.o
# Main
OBJS += app/aircopy.o
OBJS += app/app.o
OBJS += app/dtmf.o
OBJS += app/fm.o
OBJS += app/generic.o
OBJS += app/main.o
@ -45,7 +46,6 @@ OBJS += audio.o
OBJS += bitmaps.o
OBJS += board.o
OBJS += dcs.o
OBJS += dtmf.o
OBJS += font.o
OBJS += frequencies.o
OBJS += functions.o

153
app/app.c
View File

@ -17,6 +17,7 @@
#include <string.h>
#include "app/aircopy.h"
#include "app/app.h"
#include "app/dtmf.h"
#include "app/fm.h"
#include "app/generic.h"
#include "app/main.h"
@ -88,113 +89,6 @@ static void FUN_00005144(void)
FUNCTION_Select(FUNCTION_3);
}
void APP_CheckDTMFStuff(void)
{
char String[20];
uint8_t Offset;
if (!g_200003AA) {
return;
}
g_200003AA = 0;
if (gStepDirection || g_20000381) {
return;
}
if (!gRxInfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) {
return;
}
if (gDTMF_WriteIndex >= 9) {
Offset = gDTMF_WriteIndex - 9;
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.KILL_CODE);
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true)) {
if (gEeprom.PERMIT_REMOTE_KILL) {
gSetting_KILLED = true;
SETTINGS_SaveSettings();
g_200003BE = 2;
if (gFmRadioMode) {
FM_TurnOff();
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
} else {
g_200003BE = 0;
}
} else {
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.REVIVE_CODE);
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true)) {
gSetting_KILLED = false;
SETTINGS_SaveSettings();
g_200003BE = 2;
}
}
g_200003BC = 0;
gUpdateDisplay = true;
gUpdateStatus = true;
return;
}
if (gDTMF_WriteIndex >= 2) {
if (DTMF_CompareMessage(gDTMF_Received + gDTMF_WriteIndex - 2, "AB", 2, true)) {
g_CalloutAndDTMF_State = 1;
gUpdateDisplay = true;
return;
}
}
if (g_200003BC == 1 && g_20000438 == 0 && gDTMF_WriteIndex >= 9) {
Offset = gDTMF_WriteIndex - 9;
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, "AAAAA");
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, false)) {
g_CalloutAndDTMF_State = 2;
gUpdateDisplay = true;
}
}
if (gSetting_KILLED) {
return;
}
if (g_200003BC) {
return;
}
if (gDTMF_WriteIndex < 7) {
return;
}
Offset = gDTMF_WriteIndex - 7;
sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE);
g_20000439 = false;
if (!DTMF_CompareMessage(gDTMF_Received + Offset, String, 4, true)) {
return;
}
g_200003BC = 2;
memcpy(gDTMF_Contact1, gDTMF_Received + Offset, 3);
memcpy(gDTMF_Contact0, gDTMF_Received + Offset + 4, 3);
gUpdateDisplay = true;
switch (gEeprom.DTMF_DECODE_RESPONSE) {
case 3:
gDTMF_DecodeRing = true;
gDTMF_DecodeRingCountdown = 20;
// Fallthrough
case 2:
g_200003BE = 3;
break;
case 1:
gDTMF_DecodeRing = true;
gDTMF_DecodeRingCountdown = 20;
break;
default:
gDTMF_DecodeRing = false;
g_200003BE = 0;
break;
}
if (g_20000439) {
g_200003BE = 0;
}
}
void FUN_000051e8(void)
{
bool bFlag;
@ -221,7 +115,7 @@ void FUN_000051e8(void)
return;
}
}
APP_CheckDTMFStuff();
DTMF_HandleRequest();
if (gStepDirection == 0 && g_20000381 == 0) {
if (gRxInfo->DTMF_DECODING_ENABLE || gSetting_KILLED) {
if (g_200003BC == 0) {
@ -640,9 +534,9 @@ void APP_CheckRadioInterrupts(void)
BK4819_WriteRegister(BK4819_REG_02, 0);
Mask = BK4819_GetRegister(BK4819_REG_02);
if (Mask & BK4819_REG_02_DTMF_5TONE_FOUND) {
g_200003AA = 1;
gDTMF_RequestPending = true;
g_20000442 = 5;
if (15 < gDTMF_WriteIndex) {
if (gDTMF_WriteIndex > 15) {
uint8_t i;
for (i = 0; i < sizeof(gDTMF_Received) - 1; i++) {
gDTMF_Received[i] = gDTMF_Received[i + 1];
@ -651,7 +545,7 @@ void APP_CheckRadioInterrupts(void)
}
gDTMF_Received[gDTMF_WriteIndex++] = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code());
if (gCurrentFunction == FUNCTION_RECEIVE) {
APP_CheckDTMFStuff();
DTMF_HandleRequest();
}
}
if (Mask & BK4819_REG_02_CxCSS_TAIL) {
@ -1211,7 +1105,7 @@ void APP_TimeSlice500ms(void)
}
}
if (gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || (1 < gScanState))) {
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown && g_200003BA == 0) {
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown && !gDTMF_InputMode) {
gKeyLockCountdown--;
if (gKeyLockCountdown == 0) {
gEeprom.KEY_LOCK = true;
@ -1221,7 +1115,7 @@ void APP_TimeSlice500ms(void)
if (g_20000393) {
g_20000393--;
if (g_20000393 == 0) {
if (gInputBoxIndex || g_200003BA == 1 || gScreenToDisplay == DISPLAY_MENU) {
if (gInputBoxIndex || gDTMF_InputMode || gScreenToDisplay == DISPLAY_MENU) {
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
}
if (gScreenToDisplay == DISPLAY_SCANNER) {
@ -1233,8 +1127,8 @@ void APP_TimeSlice500ms(void)
gWasFKeyPressed = false;
gUpdateStatus = true;
gInputBoxIndex = 0;
g_200003BA = 0;
g_200003BB = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;
gAskToSave = false;
gAskToDelete = false;
if (gFmRadioMode && gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) {
@ -1350,17 +1244,6 @@ void FUN_00001150(void)
gRequestDisplayScreen = DISPLAY_MAIN;
}
void XXX_Append(uint8_t Data)
{
if (g_200003BB == 0) {
memset(g_20000D1C, '-', sizeof(g_20000D1C));
g_20000D1C[14] = 0;
} else if (g_200003BB >= sizeof(g_20000D1C)) {
return;
}
g_20000D1C[g_200003BB++] = Data;
}
void FUN_000075b0(void)
{
uint8_t StepSetting;
@ -1398,7 +1281,7 @@ void FUN_000075b0(void)
g_CxCSS_Type = 0xFF;
g_2000045F = 0;
g_2000045C = 0;
g_200003AA = 0;
gDTMF_RequestPending = false;
g_CxCSS_TAIL_Found = false;
g_CDCSS_Lost = false;
gCDCSSCodeType = 0;
@ -1578,13 +1461,13 @@ void FUN_00004404(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
uint8_t Short;
uint8_t Long;
if (gScreenToDisplay == DISPLAY_MAIN && g_200003BA) {
if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode) {
if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed) {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (g_200003BB) {
g_200003BB--;
g_20000D1C[g_200003BB] = 0x2d;
if (g_200003BB) {
if (gDTMF_InputIndex) {
gDTMF_InputIndex--;
gDTMF_InputBox[gDTMF_InputIndex] = '-';
if (gDTMF_InputIndex) {
g_20000394 = true;
gRequestDisplayScreen = DISPLAY_MAIN;
return;
@ -1592,7 +1475,7 @@ void FUN_00004404(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
gAnotherVoiceID = VOICE_ID_CANCEL;
gRequestDisplayScreen = DISPLAY_MAIN;
g_200003BA = 0;
gDTMF_InputMode = false;
}
g_20000394 = true;
return;
@ -1654,11 +1537,11 @@ static void APP_ProcessKey_MAIN(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
return;
}
if (g_200003BA && !bKeyHeld && bKeyPressed) {
if (gDTMF_InputMode && !bKeyHeld && bKeyPressed) {
char Character = DTMF_GetCharacter(Key);
if (Character != 0xFF) {
g_20000396 = 1;
XXX_Append(Character);
DTMF_Append(Character);
gRequestDisplayScreen = DISPLAY_MAIN;
g_20000394 = true;
return;

270
app/dtmf.c Normal file
View File

@ -0,0 +1,270 @@
/* Copyright 2023 Dual Tachyon
* https://github.com/DualTachyon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include "app/fm.h"
#include "driver/eeprom.h"
#include "dtmf.h"
#include "external/printf/printf.h"
#include "misc.h"
#include "settings.h"
#include "ui/ui.h"
char gDTMF_String[15];
char gDTMF_InputBox[15];
char gDTMF_Received[16];
bool gIsDtmfContactValid;
char gDTMF_ID[4];
char gDTMF_Contact0[4];
char gDTMF_Contact1[4];
uint8_t gDTMF_State;
bool gDTMF_DecodeRing;
uint8_t gDTMF_DecodeRingCountdown;
uint8_t gDTMFChosenContact;
uint8_t gDTMF_WriteIndex;
uint8_t gDTMF_AUTO_RESET_TIME;
uint8_t gDTMF_InputIndex;
bool gDTMF_InputMode;
bool DTMF_ValidateCodes(char *pCode, uint8_t Size)
{
uint8_t i;
if (pCode[0] == 0xFF || pCode[0] == 0) {
return false;
}
for (i = 0; i < Size; i++) {
if (pCode[i] == 0xFF || pCode[i] == 0) {
pCode[i] = 0;
break;
}
if ((pCode[i] < '0' || pCode[i] > '9') && (pCode[i] < 'A' || pCode[i] > 'D') && pCode[i] != '*' && pCode[i] != '#') {
return false;
}
}
return true;
}
bool DTMF_GetContact(uint8_t Index, char *pContact)
{
EEPROM_ReadBuffer(0x1C00 + (Index * 0x10), pContact, 16);
if ((pContact[0] - ' ') >= 0x5F) {
return false;
}
return true;
}
bool DTMF_FindContact(const char *pContact, char *pResult)
{
char Contact [16];
uint8_t i, j;
for (i = 0; i < 16; i++) {
if (!DTMF_GetContact(i, Contact)) {
return false;
}
for (j = 0; j < 3; j++) {
if (pContact[j] != Contact[j + 8]) {
break;
}
}
if (j == 3) {
memcpy(pResult, Contact, 8);
pResult[8] = 0;
return true;
}
}
return false;
}
char DTMF_GetCharacter(uint8_t Code)
{
switch(Code) {
case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7:
case 8: case 9:
return '0' + (char)Code;
case 10:
return 'A';
case 11:
return 'B';
case 12:
return 'C';
case 13:
return 'D';
case 14:
return '*';
case 15:
return '#';
}
return 0xFF;
}
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, uint8_t Size, bool bFlag)
{
uint8_t i;
for (i = 0; i < Size; i++) {
if (pDTMF[i] != pTemplate[i]) {
if (!bFlag || pDTMF[i] != gEeprom.DTMF_GROUP_CALL_CODE) {
return false;
}
g_20000439 = true;
}
}
return true;
}
bool DTMF_IsGroupCall(const char *pDTMF, uint32_t Size)
{
uint32_t i;
for (i = 0; i < Size; i++) {
if (pDTMF[i] == gEeprom.DTMF_GROUP_CALL_CODE) {
break;
}
}
if (i != Size) {
return true;
}
return false;
}
void DTMF_Append(char Code)
{
if (gDTMF_InputIndex == 0) {
memset(gDTMF_InputBox, '-', sizeof(gDTMF_InputBox));
gDTMF_InputBox[14] = 0;
} else if (gDTMF_InputIndex >= sizeof(gDTMF_InputBox)) {
return;
}
gDTMF_InputBox[gDTMF_InputIndex++] = Code;
}
void DTMF_HandleRequest(void)
{
char String[20];
uint8_t Offset;
if (!gDTMF_RequestPending) {
return;
}
gDTMF_RequestPending = false;
if (gStepDirection || g_20000381) {
return;
}
if (!gRxInfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) {
return;
}
if (gDTMF_WriteIndex >= 9) {
Offset = gDTMF_WriteIndex - 9;
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.KILL_CODE);
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true)) {
if (gEeprom.PERMIT_REMOTE_KILL) {
gSetting_KILLED = true;
SETTINGS_SaveSettings();
g_200003BE = 2;
if (gFmRadioMode) {
FM_TurnOff();
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
} else {
g_200003BE = 0;
}
} else {
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.REVIVE_CODE);
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true)) {
gSetting_KILLED = false;
SETTINGS_SaveSettings();
g_200003BE = 2;
}
}
g_200003BC = 0;
gUpdateDisplay = true;
gUpdateStatus = true;
return;
}
if (gDTMF_WriteIndex >= 2) {
if (DTMF_CompareMessage(gDTMF_Received + gDTMF_WriteIndex - 2, "AB", 2, true)) {
gDTMF_State = 1;
gUpdateDisplay = true;
return;
}
}
if (g_200003BC == 1 && g_20000438 == 0 && gDTMF_WriteIndex >= 9) {
Offset = gDTMF_WriteIndex - 9;
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, "AAAAA");
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, false)) {
gDTMF_State = 2;
gUpdateDisplay = true;
}
}
if (gSetting_KILLED) {
return;
}
if (g_200003BC) {
return;
}
if (gDTMF_WriteIndex < 7) {
return;
}
Offset = gDTMF_WriteIndex - 7;
sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE);
g_20000439 = false;
if (!DTMF_CompareMessage(gDTMF_Received + Offset, String, 4, true)) {
return;
}
g_200003BC = 2;
memcpy(gDTMF_Contact1, gDTMF_Received + Offset, 3);
memcpy(gDTMF_Contact0, gDTMF_Received + Offset + 4, 3);
gUpdateDisplay = true;
switch (gEeprom.DTMF_DECODE_RESPONSE) {
case 3:
gDTMF_DecodeRing = true;
gDTMF_DecodeRingCountdown = 20;
// Fallthrough
case 2:
g_200003BE = 3;
break;
case 1:
gDTMF_DecodeRing = true;
gDTMF_DecodeRingCountdown = 20;
break;
default:
gDTMF_DecodeRing = false;
g_200003BE = 0;
break;
}
if (g_20000439) {
g_200003BE = 0;
}
}

View File

@ -21,6 +21,20 @@
#include <stdint.h>
extern char gDTMF_String[15];
extern char gDTMF_InputBox[15];
extern char gDTMF_Received[16];
extern bool gIsDtmfContactValid;
extern char gDTMF_ID[4];
extern char gDTMF_Contact0[4];
extern char gDTMF_Contact1[4];
extern uint8_t gDTMF_State;
extern bool gDTMF_DecodeRing;
extern uint8_t gDTMF_DecodeRingCountdown;
extern uint8_t gDTMFChosenContact;
extern uint8_t gDTMF_WriteIndex;
extern uint8_t gDTMF_AUTO_RESET_TIME;
extern uint8_t gDTMF_InputIndex;
extern bool gDTMF_InputMode;
bool DTMF_ValidateCodes(char *pCode, uint8_t Size);
bool DTMF_GetContact(uint8_t Index, char *pContact);
@ -28,6 +42,8 @@ bool DTMF_FindContact(const char *pContact, char *pResult);
char DTMF_GetCharacter(uint8_t Code);
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, uint8_t Size, bool bFlag);
bool DTMF_IsGroupCall(const char *pDTMF, uint32_t Size);
void DTMF_Append(char Code);
void DTMF_HandleRequest(void);
#endif

View File

@ -127,25 +127,25 @@ void GENERIC_Key_PTT(bool bKeyPressed)
return;
}
g_200003A0 = 1;
if (g_200003BA == 1) {
if (g_200003BB || g_200003C0) {
if (g_200003BB == 0) {
g_200003BB = g_200003C0;
if (gDTMF_InputMode) {
if (gDTMF_InputIndex || g_200003C0) {
if (gDTMF_InputIndex == 0) {
gDTMF_InputIndex = g_200003C0;
}
g_20000D1C[g_200003BB] = 0;
if (g_200003BB == 3) {
g_20000438 = DTMF_IsGroupCall(g_20000D1C, 3);
gDTMF_InputBox[gDTMF_InputIndex] = 0;
if (gDTMF_InputIndex == 3) {
g_20000438 = DTMF_IsGroupCall(gDTMF_InputBox, 3);
} else {
g_20000438 = 2;
}
sprintf(gDTMF_String, "%s", g_20000D1C);
g_200003C0 = g_200003BB;
sprintf(gDTMF_String, "%s", gDTMF_InputBox);
g_200003C0 = gDTMF_InputIndex;
g_200003BE = 1;
g_CalloutAndDTMF_State = 0;
gDTMF_State = 0;
}
gRequestDisplayScreen = DISPLAY_MAIN;
g_200003BA = 0;
g_200003BB = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;
return;
}
gRequestDisplayScreen = DISPLAY_MAIN;

View File

@ -327,9 +327,9 @@ void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
return;
}
if (gStepDirection == 0 && IS_NOT_NOAA_CHANNEL(gTxInfo->CHANNEL_SAVE)) {
g_200003BA = 1;
memcpy(g_20000D1C, gDTMF_String, 15);
g_200003BB = 0;
gDTMF_InputMode = true;
memcpy(gDTMF_InputBox, gDTMF_String, 15);
gDTMF_InputIndex = 0;
gRequestDisplayScreen = DISPLAY_MAIN;
return;
}

View File

@ -15,6 +15,7 @@
*/
#include <string.h>
#include "app/dtmf.h"
#include "app/menu.h"
#include "audio.h"
#include "board.h"
@ -437,9 +438,9 @@ void MENU_AcceptSetting(void)
gDTMFChosenContact = gSubMenuSelection - 1;
if (gIsDtmfContactValid) {
GUI_SelectNextDisplay(DISPLAY_MAIN);
g_200003BA = 1;
g_200003BB = 3;
memcpy(g_20000D1C, gDTMF_ID, 4);
gDTMF_InputMode = true;
gDTMF_InputIndex = 3;
memcpy(gDTMF_InputBox, gDTMF_ID, 4);
gRequestDisplayScreen = DISPLAY_INVALID;
}
return;

View File

@ -16,6 +16,7 @@
*/
#include <string.h>
#include "app/dtmf.h"
#include "app/fm.h"
#include "board.h"
#include "bsp/dp32g030/gpio.h"
@ -31,7 +32,6 @@
#include "driver/gpio.h"
#include "driver/system.h"
#include "driver/st7565.h"
#include "dtmf.h"
#include "frequencies.h"
#include "helper/battery.h"
#include "misc.h"

135
dtmf.c
View File

@ -1,135 +0,0 @@
/* Copyright 2023 Dual Tachyon
* https://github.com/DualTachyon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include "driver/eeprom.h"
#include "dtmf.h"
#include "misc.h"
#include "settings.h"
char gDTMF_String[15];
bool DTMF_ValidateCodes(char *pCode, uint8_t Size)
{
uint8_t i;
if (pCode[0] == 0xFF || pCode[0] == 0) {
return false;
}
for (i = 0; i < Size; i++) {
if (pCode[i] == 0xFF || pCode[i] == 0) {
pCode[i] = 0;
break;
}
if ((pCode[i] < '0' || pCode[i] > '9') && (pCode[i] < 'A' || pCode[i] > 'D') && pCode[i] != '*' && pCode[i] != '#') {
return false;
}
}
return true;
}
bool DTMF_GetContact(uint8_t Index, char *pContact)
{
EEPROM_ReadBuffer(0x1C00 + (Index * 0x10), pContact, 16);
if ((pContact[0] - ' ') >= 0x5F) {
return false;
}
return true;
}
bool DTMF_FindContact(const char *pContact, char *pResult)
{
char Contact [16];
uint8_t i, j;
for (i = 0; i < 16; i++) {
if (!DTMF_GetContact(i, Contact)) {
return false;
}
for (j = 0; j < 3; j++) {
if (pContact[j] != Contact[j + 8]) {
break;
}
}
if (j == 3) {
memcpy(pResult, Contact, 8);
pResult[8] = 0;
return true;
}
}
return false;
}
char DTMF_GetCharacter(uint8_t Code)
{
switch(Code) {
case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7:
case 8: case 9:
return '0' + (char)Code;
case 10:
return 'A';
case 11:
return 'B';
case 12:
return 'C';
case 13:
return 'D';
case 14:
return '*';
case 15:
return '#';
}
return 0xFF;
}
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, uint8_t Size, bool bFlag)
{
uint8_t i;
for (i = 0; i < Size; i++) {
if (pDTMF[i] != pTemplate[i]) {
if (!bFlag || pDTMF[i] != gEeprom.DTMF_GROUP_CALL_CODE) {
return false;
}
g_20000439 = true;
}
}
return true;
}
bool DTMF_IsGroupCall(const char *pDTMF, uint32_t Size)
{
uint32_t i;
for (i = 0; i < Size; i++) {
if (pDTMF[i] == gEeprom.DTMF_GROUP_CALL_CODE) {
break;
}
}
if (i != Size) {
return true;
}
return false;
}

View File

@ -15,6 +15,7 @@
*/
#include <string.h>
#include "app/dtmf.h"
#include "app/fm.h"
#include "bsp/dp32g030/gpio.h"
#include "dcs.h"
@ -22,7 +23,6 @@
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/system.h"
#include "dtmf.h"
#include "external/printf/printf.h"
#include "functions.h"
#include "helper/battery.h"
@ -48,7 +48,7 @@ void FUNCTION_Init(void)
} else {
gCopyOfCodeType = CODE_TYPE_CONTINUOUS_TONE;
}
g_200003AA = 0;
gDTMF_RequestPending = false;
gDTMF_WriteIndex = 0;
memset(gDTMF_Received, 0, sizeof(gDTMF_Received));
g_CxCSS_TAIL_Found = false;

2
main.c
View File

@ -19,6 +19,7 @@
#include "ARMCM0.h"
#include "app/app.h"
#include "app/dtmf.h"
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#include "bsp/dp32g030/portcon.h"
@ -36,7 +37,6 @@
#include "driver/system.h"
#include "driver/systick.h"
#include "driver/uart.h"
#include "dtmf.h"
#include "external/printf/printf.h"
#include "functions.h"
#include "helper/battery.h"

16
misc.c
View File

@ -94,7 +94,7 @@ bool gFlagSaveVfo;
bool gFlagSaveSettings;
uint8_t gFlagSaveChannel;
bool gFlagSaveFM;
uint8_t g_200003AA;
uint8_t gDTMF_RequestPending;
bool g_CDCSS_Lost;
uint8_t gCDCSSCodeType;
bool g_CTCSS_Lost;
@ -105,16 +105,11 @@ uint8_t gFlashLightState;
uint8_t g_200003B4;
uint16_t g_200003B6;
uint16_t g_200003B8;
uint8_t g_200003BA;
uint8_t g_200003BB;
uint8_t g_200003BC;
uint8_t g_200003BD;
uint8_t g_200003BE;
uint8_t g_200003C0;
bool gDTMF_DecodeRing;
uint8_t g_200003C3;
uint8_t gDTMF_DecodeRingCountdown;
uint8_t gDTMFChosenContact;
uint16_t g_200003E2;
volatile uint16_t gFlashLightBlinkCounter;
uint8_t g_200003FD;
@ -133,7 +128,6 @@ uint8_t g_20000427;
bool gKeyBeingHeld;
bool gPttIsPressed;
uint8_t gPttDebounceCounter;
uint8_t gDTMF_WriteIndex;
uint8_t g_20000438;
bool g_20000439;
uint8_t gMenuListCount;
@ -150,13 +144,6 @@ uint8_t g_20000464;
uint8_t gAircopySendCountdown;
uint8_t gFSKWriteIndex;
uint8_t g_20000474;
char g_20000D1C[15];
char gDTMF_Received[16];
bool gIsDtmfContactValid;
char gDTMF_ID[4];
char gDTMF_Contact0[4];
char gDTMF_Contact1[4];
uint8_t g_CalloutAndDTMF_State;
bool gFM_AutoScan;
bool gIsNoaaMode;
@ -165,7 +152,6 @@ uint8_t gNoaaChannel;
bool gUpdateDisplay;
uint8_t gFmRadioCountdown;
uint8_t gFM_ChannelPosition;
uint8_t gDTMF_AUTO_RESET_TIME;
bool gF_LOCK;
uint8_t gScanChannel;
uint32_t gScanFrequency;

16
misc.h
View File

@ -124,7 +124,7 @@ extern bool gFlagSaveVfo;
extern bool gFlagSaveSettings;
extern uint8_t gFlagSaveChannel;
extern bool gFlagSaveFM;
extern uint8_t g_200003AA;
extern uint8_t gDTMF_RequestPending;
extern bool g_CDCSS_Lost;
extern uint8_t gCDCSSCodeType;
extern bool g_CTCSS_Lost;
@ -135,16 +135,11 @@ extern uint8_t gFlashLightState;
extern uint8_t g_200003B4;
extern uint16_t g_200003B6;
extern uint16_t g_200003B8;
extern uint8_t g_200003BA;
extern uint8_t g_200003BB;
extern uint8_t g_200003BC;
extern uint8_t g_200003BD;
extern uint8_t g_200003BE;
extern uint8_t g_200003C0;
extern bool gDTMF_DecodeRing;
extern uint8_t g_200003C3;
extern uint8_t gDTMF_DecodeRingCountdown;
extern uint8_t gDTMFChosenContact;
extern uint16_t g_200003E2;
extern volatile uint16_t gFlashLightBlinkCounter;
extern uint8_t g_200003FD;
@ -163,7 +158,6 @@ extern uint8_t g_20000427;
extern bool gKeyBeingHeld;
extern bool gPttIsPressed;
extern uint8_t gPttDebounceCounter;
extern uint8_t gDTMF_WriteIndex;
extern uint8_t g_20000438;
extern bool g_20000439;
extern uint8_t gMenuListCount;
@ -180,13 +174,6 @@ extern uint8_t g_20000464;
extern uint8_t gAircopySendCountdown;
extern uint8_t gFSKWriteIndex;
extern uint8_t g_20000474;
extern char g_20000D1C[15];
extern char gDTMF_Received[16];
extern bool gIsDtmfContactValid;
extern char gDTMF_ID[4];
extern char gDTMF_Contact0[4];
extern char gDTMF_Contact1[4];
extern uint8_t g_CalloutAndDTMF_State;
extern bool gFM_AutoScan;
extern bool gIsNoaaMode;
@ -195,7 +182,6 @@ extern uint8_t gNoaaChannel;
extern bool gUpdateDisplay;
extern uint8_t gFmRadioCountdown;
extern uint8_t gFM_ChannelPosition;
extern uint8_t gDTMF_AUTO_RESET_TIME;
extern bool gF_LOCK;
extern uint8_t gScanChannel;
extern uint32_t gScanFrequency;

View File

@ -745,8 +745,7 @@ LAB_00007c20:
g_200003BD = 1;
g_200003BC = 0;
g_200003C3 = 6;
}
else {
} else {
g_200003BC = 1;
g_200003BD = 0;
}

View File

@ -15,9 +15,9 @@
*/
#include <string.h>
#include "app/dtmf.h"
#include "bitmaps.h"
#include "driver/st7565.h"
#include "dtmf.h"
#include "external/printf/printf.h"
#include "functions.h"
#include "misc.h"
@ -65,10 +65,10 @@ void UI_DisplayMain(void)
}
if (Channel != i) {
if (g_200003BC || g_200003BD || g_200003BA) {
if (g_200003BA == 0) {
if (g_200003BC || g_200003BD || gDTMF_InputMode) {
if (!gDTMF_InputMode) {
if (g_200003BC == 1) {
if (g_CalloutAndDTMF_State == 2) {
if (gDTMF_State == 2) {
strcpy(String, "CALL OUT(RSP)");
} else {
strcpy(String, "CALL OUT");
@ -80,21 +80,21 @@ void UI_DisplayMain(void)
sprintf(String, "CALL:%s", gDTMF_Contact0);
}
} else if (g_200003BD == 1) {
if (g_CalloutAndDTMF_State == 1) {
if (gDTMF_State == 1) {
strcpy(String, "DTMF TX(SUCC)");
} else {
strcpy(String, "DTMF TX");
}
}
} else {
sprintf(String, ">%s", g_20000D1C);
sprintf(String, ">%s", gDTMF_InputBox);
}
UI_PrintString(String, 2, 127, i * 3, 8, false);
memset(String, 0, sizeof(String));
memset(String2, 0, sizeof(String2));
if (g_200003BA == 0) {
if (!gDTMF_InputMode) {
if (g_200003BC == 1) {
if (DTMF_FindContact(gDTMF_String, String2)) {
sprintf(String, ">%s", String2);

View File

@ -15,10 +15,10 @@
*/
#include <string.h>
#include "app/dtmf.h"
#include "bitmaps.h"
#include "dcs.h"
#include "driver/st7565.h"
#include "dtmf.h"
#include "external/printf/printf.h"
#include "helper/battery.h"
#include "misc.h"
@ -258,7 +258,7 @@ void UI_DisplayMenu(void)
String[i + 1] = gInputBox[i] + '0';
}
}
String[7] = 0x2d;
String[7] = '-';
String[8] = '-';
String[9] = 0;
String[10] = 0;

View File

@ -15,6 +15,7 @@
*/
#include <string.h>
#include "app/dtmf.h"
#include "driver/keyboard.h"
#include "misc.h"
#include "ui/aircopy.h"
@ -65,8 +66,8 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
gStepDirection = 0;
gFM_Step = 0;
gAskForConfirmation = 0;
g_200003BA = 0;
g_200003BB = 0;
gDTMF_InputMode = false;
gDTMF_InputIndex = 0;
gF_LOCK = false;
gAskToSave = false;
gAskToDelete = false;