mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
Live DTMF decoder option + possibly fixed AM demodulation
This commit is contained in:
parent
7bd011b057
commit
3c1a70a11f
4
Makefile
4
Makefile
@ -18,6 +18,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
|
||||
ENABLE_MAIN_KEY_HOLD := 1
|
||||
ENABLE_BOOT_BEEPS := 1
|
||||
ENABLE_COMPANDER := 1
|
||||
ENABLE_DTMF_DECODER := 1
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1
|
||||
#ENABLE_BAND_SCOPE := 1
|
||||
|
||||
@ -188,6 +189,9 @@ endif
|
||||
ifeq ($(ENABLE_COMPANDER),1)
|
||||
CFLAGS += -DENABLE_COMPANDER
|
||||
endif
|
||||
ifeq ($(ENABLE_DTMF_DECODER),1)
|
||||
CFLAGS += -DENABLE_DTMF_DECODER
|
||||
endif
|
||||
ifeq ($(ENABLE_SINGLE_VFO_CHAN),1)
|
||||
CFLAGS += -DENABLE_SINGLE_VFO_CHAN
|
||||
endif
|
||||
|
@ -29,6 +29,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather
|
||||
ENABLE_MAIN_KEY_HOLD := 1 initial F-key press not needed, instead hold down keys 0-9
|
||||
ENABLE_BOOT_BEEPS := 1 give user audio feedback on volume knob position at boot-up
|
||||
ENABLE_COMPANDER := 1 compander option - setting not yet saved
|
||||
ENABLE_DTMF_DECODER := 1 enable real time on-screen DTMF decoder
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented - single VFO on display when possible
|
||||
#ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter
|
||||
```
|
||||
|
26
app/app.c
26
app/app.c
@ -441,7 +441,6 @@ 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_10ms;
|
||||
gScheduleDualWatch = false;
|
||||
}
|
||||
@ -449,11 +448,20 @@ void APP_StartListening(FUNCTION_Type_t Function)
|
||||
if (gRxVfo->IsAM)
|
||||
{
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8);
|
||||
|
||||
// PGA + MIXER + LNA + LNA_SHORT
|
||||
BK4819_WriteRegister(BK4819_REG_13, 3u | (3u << 3) | (2u << 5) | (3u << 8));
|
||||
|
||||
gNeverUsed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0xB000 | (gEeprom.VOLUME_GAIN << 4) | (gEeprom.DAC_GAIN << 0));
|
||||
|
||||
// PGA + MIXER + LNA + LNA_SHORT
|
||||
BK4819_WriteRegister(BK4819_REG_13, 0x03BE);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (gVoiceWriteIndex == 0)
|
||||
#endif
|
||||
@ -640,20 +648,24 @@ void APP_CheckRadioInterrupts(void)
|
||||
if (interrupt_status_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
|
||||
{
|
||||
gDTMF_RequestPending = true;
|
||||
gDTMF_RecvTimeout = 5;
|
||||
gDTMF_RecvTimeout = DTMF_RX_timeout_500ms;
|
||||
|
||||
if (gDTMF_WriteIndex > 15)
|
||||
{
|
||||
if (gDTMF_WriteIndex >= ARRAY_SIZE(gDTMF_Received))
|
||||
{ // shift the RX buffer down one
|
||||
unsigned int i;
|
||||
for (i = 0; i < (sizeof(gDTMF_Received) - 1); i++)
|
||||
for (i = 0; i < (ARRAY_SIZE(gDTMF_Received) - 1); i++)
|
||||
gDTMF_Received[i] = gDTMF_Received[i + 1];
|
||||
gDTMF_WriteIndex = 15;
|
||||
gDTMF_WriteIndex--;
|
||||
}
|
||||
|
||||
// save new RX'ed character
|
||||
gDTMF_Received[gDTMF_WriteIndex++] = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code());
|
||||
|
||||
if (gCurrentFunction == FUNCTION_RECEIVE)
|
||||
{
|
||||
DTMF_HandleRequest();
|
||||
gUpdateDisplay = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (interrupt_status_bits & BK4819_REG_02_CxCSS_TAIL)
|
||||
@ -1792,7 +1804,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
else
|
||||
{
|
||||
if (Key != KEY_PTT)
|
||||
gVoltageMenuCountdown = menu_timeout_10ms;
|
||||
gVoltageMenuCountdown = menu_timeout_500ms;
|
||||
|
||||
BACKLIGHT_TurnOn();
|
||||
|
||||
|
31
app/dtmf.c
31
app/dtmf.c
@ -115,35 +115,10 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
|
||||
return false;
|
||||
}
|
||||
|
||||
char DTMF_GetCharacter(uint8_t Code)
|
||||
char DTMF_GetCharacter(const 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;
|
||||
const char list[] = "0123456789ABCD*#";
|
||||
return (code < ARRAY_SIZE(list)) ? list[code] : 0xFF;
|
||||
}
|
||||
|
||||
bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size, bool bCheckGroup)
|
||||
|
@ -79,7 +79,7 @@ extern uint8_t gDTMF_TxStopCountdown;
|
||||
bool DTMF_ValidateCodes(char *pCode, uint8_t Size);
|
||||
bool DTMF_GetContact(const int Index, char *pContact);
|
||||
bool DTMF_FindContact(const char *pContact, char *pResult);
|
||||
char DTMF_GetCharacter(uint8_t Code);
|
||||
char DTMF_GetCharacter(const uint8_t code);
|
||||
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, uint8_t Size, bool bFlag);
|
||||
bool DTMF_CheckGroupCall(const char *pDTMF, uint32_t Size);
|
||||
void DTMF_Append(char Code);
|
||||
|
@ -1444,5 +1444,5 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
|
||||
if (gScreenToDisplay == DISPLAY_MENU && gMenuCursor == MENU_VOL)
|
||||
gVoltageMenuCountdown = menu_timeout_10ms;
|
||||
gVoltageMenuCountdown = menu_timeout_500ms;
|
||||
}
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
@ -55,21 +55,23 @@ void FUNCTION_Init(void)
|
||||
|
||||
gDTMF_RequestPending = false;
|
||||
gDTMF_WriteIndex = 0;
|
||||
|
||||
memset(gDTMF_Received, 0, sizeof(gDTMF_Received));
|
||||
|
||||
g_CxCSS_TAIL_Found = false;
|
||||
g_CDCSS_Lost = false;
|
||||
g_CTCSS_Lost = false;
|
||||
|
||||
g_VOX_Lost = false;
|
||||
g_SquelchLost = false;
|
||||
gTailNoteEliminationCountdown = 0;
|
||||
gFlagTteComplete = false;
|
||||
|
||||
gTailNoteEliminationCountdown = 0;
|
||||
gFoundCTCSS = false;
|
||||
gFoundCDCSS = false;
|
||||
gFoundCTCSSCountdown = 0;
|
||||
gFoundCDCSSCountdown = 0;
|
||||
gEndOfRxDetectedMaybe = false;
|
||||
|
||||
gSystickCountdown2 = 0;
|
||||
}
|
||||
|
||||
|
6
misc.c
6
misc.c
@ -18,9 +18,11 @@
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
const uint8_t menu_timeout_10ms = 20 * 2; // 20 seconds
|
||||
const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds
|
||||
|
||||
const uint8_t key_input_timeout_500ms = 8 * 2; // 8 seconds
|
||||
const uint8_t DTMF_RX_timeout_500ms = 2500 / 500; // 2.5 seconds
|
||||
|
||||
const uint8_t key_input_timeout_500ms = 8000 / 500; // 8 seconds
|
||||
|
||||
const uint16_t key_repeat_delay_10ms = 400 / 10; // 400ms
|
||||
const uint16_t key_repeat_10ms = 80 / 10; // 80ms .. MUST be less than 'key_repeat_delay'
|
||||
|
10
misc.h
10
misc.h
@ -27,6 +27,10 @@
|
||||
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
|
||||
#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
#endif
|
||||
|
||||
enum {
|
||||
MR_CHANNEL_FIRST = 0,
|
||||
MR_CHANNEL_LAST = 199u,
|
||||
@ -74,6 +78,10 @@ enum CssScanMode_t
|
||||
|
||||
typedef enum CssScanMode_t CssScanMode_t;
|
||||
|
||||
extern const uint8_t menu_timeout_500ms;
|
||||
|
||||
extern const uint8_t DTMF_RX_timeout_500ms;
|
||||
|
||||
extern const uint8_t key_input_timeout_500ms;
|
||||
|
||||
extern const uint16_t key_repeat_delay_10ms;
|
||||
@ -82,8 +90,6 @@ extern const uint16_t key_debounce_10ms;
|
||||
|
||||
extern const uint8_t scan_delay_10ms;
|
||||
|
||||
extern const uint8_t menu_timeout_10ms;
|
||||
|
||||
extern const uint16_t battery_save_count_10ms;
|
||||
|
||||
extern const uint16_t dual_watch_count_after_tx_10ms;
|
||||
|
1
radio.c
1
radio.c
@ -931,6 +931,7 @@ void RADIO_EnableCxCSS(void)
|
||||
{
|
||||
switch (gCurrentVfo->pTX->CodeType)
|
||||
{
|
||||
default:
|
||||
case CODE_TYPE_OFF:
|
||||
break;
|
||||
|
||||
|
141
ui/main.c
141
ui/main.c
@ -28,9 +28,9 @@
|
||||
#include "ui/inputbox.h"
|
||||
#include "ui/main.h"
|
||||
|
||||
//#ifndef ARRAY_SIZE
|
||||
// #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
//#endif
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
#endif
|
||||
|
||||
void UI_DisplayMain(void)
|
||||
{
|
||||
@ -162,42 +162,37 @@ void UI_DisplayMain(void)
|
||||
|
||||
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
||||
{ // channel mode
|
||||
|
||||
const unsigned int x = 2;
|
||||
|
||||
// show the memory channel symbol
|
||||
UI_PrintStringSmall("M", x, 0, Line + 1);
|
||||
|
||||
if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num)
|
||||
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num) ? false : true;
|
||||
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
|
||||
UI_DisplaySmallDigits(3, String + 5, x + 7, Line + 1, false);
|
||||
UI_PrintStringSmall("M", x, 0, Line + 1);
|
||||
UI_DisplaySmallDigits(3, String + 5, x + 7, Line + 1, inputting);
|
||||
}
|
||||
else
|
||||
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
|
||||
{
|
||||
const unsigned int x = 2; // was 14
|
||||
{ // frequency mode
|
||||
// show the frequency band number
|
||||
const unsigned int x = 2; // was 14
|
||||
sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST);
|
||||
UI_PrintStringSmall(String, x, 0, Line + 1);
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
{
|
||||
// show the 'N' narrow band symbol - why do we do that here ?
|
||||
//memcpy(pLine1 + 7, BITMAP_NarrowBand, sizeof(BITMAP_NarrowBand));
|
||||
|
||||
if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num)
|
||||
{
|
||||
NUMBER_ToDigits((gEeprom.ScreenChannel[vfo_num] - NOAA_CHANNEL_FIRST) + 1, String);
|
||||
{ // channel number
|
||||
sprintf(String, "N%u", 1 + gEeprom.ScreenChannel[vfo_num] - NOAA_CHANNEL_FIRST);
|
||||
}
|
||||
else
|
||||
{
|
||||
String[6] = gInputBox[0];
|
||||
String[7] = gInputBox[1];
|
||||
{ // user entering channel number
|
||||
sprintf(String, "N%u%u", '0' + gInputBox[0], '0' + gInputBox[1]);
|
||||
}
|
||||
UI_DisplaySmallDigits(2, String + 6, 15, Line + 1, true);
|
||||
UI_PrintStringSmall(String, 7, 0, Line + 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ************
|
||||
|
||||
@ -214,47 +209,13 @@ void UI_DisplayMain(void)
|
||||
|
||||
if (State != VFO_STATE_NORMAL)
|
||||
{
|
||||
//uint8_t Width = 10;
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
|
||||
switch (State)
|
||||
{
|
||||
//case VFO_STATE_NORMAL:
|
||||
// break;
|
||||
case VFO_STATE_BUSY:
|
||||
strcpy(String, "BUSY");
|
||||
//Width = 15;
|
||||
break;
|
||||
case VFO_STATE_BAT_LOW:
|
||||
strcpy(String, "BAT LOW");
|
||||
break;
|
||||
case VFO_STATE_TX_DISABLE:
|
||||
strcpy(String, "TX DISABLE");
|
||||
break;
|
||||
case VFO_STATE_TIMEOUT:
|
||||
strcpy(String, "TIMEOUT");
|
||||
break;
|
||||
case VFO_STATE_ALARM:
|
||||
strcpy(String, "ALARM");
|
||||
break;
|
||||
case VFO_STATE_VOLTAGE_HIGH:
|
||||
strcpy(String, "VOLT HIGH");
|
||||
//Width = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
UI_PrintString(String, 31, 111, Line, Width); // centered text
|
||||
#else
|
||||
UI_PrintString(String, 34, 0, Line, 8); // left aligned text
|
||||
#endif
|
||||
const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"};
|
||||
if (State >= 0 && State < ARRAY_SIZE(state_list))
|
||||
UI_PrintString(state_list[State], 31, 0, Line, 8);
|
||||
}
|
||||
else
|
||||
{ // normal state
|
||||
|
||||
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num)
|
||||
{ // user is entering a new frequency
|
||||
{ // user entering a frequency
|
||||
UI_DisplayFrequency(gInputBox, 31, Line, true, false);
|
||||
}
|
||||
else
|
||||
@ -304,12 +265,12 @@ void UI_DisplayMain(void)
|
||||
if (gEeprom.VfoInfo[vfo_num].Name[0] == 0 || gEeprom.VfoInfo[vfo_num].Name[0] == 0xFF)
|
||||
{ // no channel name, show the channel number instead
|
||||
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
|
||||
UI_PrintString(String, 31, 112, Line, 8);
|
||||
}
|
||||
else
|
||||
{ // channel name
|
||||
UI_PrintString(gEeprom.VfoInfo[vfo_num].Name, 31, 112, Line, 8);
|
||||
strcpy(String, gEeprom.VfoInfo[vfo_num].Name);
|
||||
}
|
||||
UI_PrintString(String, 31, 112, Line, 8);
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_CHAN_NAME_FREQ
|
||||
@ -336,7 +297,6 @@ void UI_DisplayMain(void)
|
||||
}
|
||||
else
|
||||
{ // frequency mode
|
||||
|
||||
#ifdef ENABLE_BIG_FREQ
|
||||
NUMBER_ToDigits(frequency_Hz, String); // 8 digits
|
||||
// show the main large frequency digits
|
||||
@ -350,27 +310,19 @@ void UI_DisplayMain(void)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ************
|
||||
|
||||
{ // show the TX/RX level
|
||||
|
||||
uint8_t Level = 0;
|
||||
|
||||
if (SomeValue == 1)
|
||||
{ // TX power level
|
||||
switch (gRxVfo->OUTPUT_POWER)
|
||||
{
|
||||
case OUTPUT_POWER_LOW:
|
||||
Level = 2;
|
||||
break;
|
||||
case OUTPUT_POWER_MID:
|
||||
Level = 4;
|
||||
break;
|
||||
case OUTPUT_POWER_HIGH:
|
||||
Level = 6;
|
||||
break;
|
||||
case OUTPUT_POWER_LOW: Level = 2; break;
|
||||
case OUTPUT_POWER_MID: Level = 4; break;
|
||||
case OUTPUT_POWER_HIGH: Level = 6; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -404,32 +356,21 @@ void UI_DisplayMain(void)
|
||||
UI_PrintStringSmall("AM", display_width + 27, 0, Line + 1);
|
||||
}
|
||||
else
|
||||
{ // show the CTCSS or DCS symbol
|
||||
{ // show the CTCSS/DCS symbol
|
||||
const FREQ_Config_t *pConfig = (SomeValue == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX;
|
||||
switch (pConfig->CodeType)
|
||||
{
|
||||
default:
|
||||
case CODE_TYPE_OFF:
|
||||
break;
|
||||
case CODE_TYPE_CONTINUOUS_TONE: // CTCSS
|
||||
UI_PrintStringSmall("CT", display_width + 24, 0, Line + 1);
|
||||
break;
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL: // DCS
|
||||
UI_PrintStringSmall("DCS", display_width + 24, 0, Line + 1);
|
||||
break;
|
||||
}
|
||||
const unsigned int code_type = pConfig->CodeType;
|
||||
const char *code_list[] = {"", "CT", "DCS", "DCR"};
|
||||
if (code_type >= 0 && code_type < ARRAY_SIZE(code_list))
|
||||
UI_PrintStringSmall(code_list[code_type], display_width + 24, 0, Line + 1);
|
||||
}
|
||||
|
||||
String[0] = '?';
|
||||
switch (gEeprom.VfoInfo[vfo_num].OUTPUT_POWER)
|
||||
{ // show the TX power level symbol
|
||||
case OUTPUT_POWER_LOW: String[0] = 'L'; break;
|
||||
case OUTPUT_POWER_MID: String[0] = 'M'; break;
|
||||
case OUTPUT_POWER_HIGH: String[0] = 'H'; break;
|
||||
}
|
||||
{ // show the TX power
|
||||
const char pwr_list[] = "LMH";
|
||||
const unsigned int i = gEeprom.VfoInfo[vfo_num].OUTPUT_POWER;
|
||||
String[0] = (i >= 0 && i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0';
|
||||
String[1] = '\0';
|
||||
UI_PrintStringSmall(String, display_width + 46, 0, Line + 1);
|
||||
}
|
||||
|
||||
if (gEeprom.VfoInfo[vfo_num].ConfigRX.Frequency != gEeprom.VfoInfo[vfo_num].ConfigTX.Frequency)
|
||||
{ // show the TX offset symbol
|
||||
@ -460,6 +401,16 @@ void UI_DisplayMain(void)
|
||||
UI_PrintStringSmall("SCR", display_width + 106, 0, Line + 1);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DTMF_DECODER
|
||||
if (gCurrentFunction == FUNCTION_RECEIVE && gDTMF_WriteIndex > 0)
|
||||
{ // show the incoming DTMF live on-screen
|
||||
const unsigned int len = (gDTMF_WriteIndex < (ARRAY_SIZE(String) - 1)) ? gDTMF_WriteIndex : ARRAY_SIZE(String) - 1;
|
||||
memset(String, 0, sizeof(String));
|
||||
memcpy(String, gDTMF_Received, len);
|
||||
UI_PrintStringSmall("D:", 2, 0, 3);
|
||||
UI_PrintStringSmall(String, 2 + (7 * 2), 0, 3);
|
||||
}
|
||||
#endif
|
||||
|
||||
ST7565_BlitFullScreen();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user