0
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:
OneOfEleven 2023-09-16 22:29:02 +01:00
parent 7bd011b057
commit 3c1a70a11f
14 changed files with 207 additions and 253 deletions

View File

@ -18,6 +18,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_MAIN_KEY_HOLD := 1 ENABLE_MAIN_KEY_HOLD := 1
ENABLE_BOOT_BEEPS := 1 ENABLE_BOOT_BEEPS := 1
ENABLE_COMPANDER := 1 ENABLE_COMPANDER := 1
ENABLE_DTMF_DECODER := 1
#ENABLE_SINGLE_VFO_CHAN := 1 #ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_BAND_SCOPE := 1 #ENABLE_BAND_SCOPE := 1
@ -188,6 +189,9 @@ endif
ifeq ($(ENABLE_COMPANDER),1) ifeq ($(ENABLE_COMPANDER),1)
CFLAGS += -DENABLE_COMPANDER CFLAGS += -DENABLE_COMPANDER
endif endif
ifeq ($(ENABLE_DTMF_DECODER),1)
CFLAGS += -DENABLE_DTMF_DECODER
endif
ifeq ($(ENABLE_SINGLE_VFO_CHAN),1) ifeq ($(ENABLE_SINGLE_VFO_CHAN),1)
CFLAGS += -DENABLE_SINGLE_VFO_CHAN CFLAGS += -DENABLE_SINGLE_VFO_CHAN
endif endif

View File

@ -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_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_BOOT_BEEPS := 1 give user audio feedback on volume knob position at boot-up
ENABLE_COMPANDER := 1 compander option - setting not yet saved 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_SINGLE_VFO_CHAN := 1 not yet implemented - single VFO on display when possible
#ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter #ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter
``` ```

View File

@ -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) if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{ {
gRxVfoIsActive = true; gRxVfoIsActive = true;
gDualWatchCountdown = dual_watch_count_after_2_10ms; gDualWatchCountdown = dual_watch_count_after_2_10ms;
gScheduleDualWatch = false; gScheduleDualWatch = false;
} }
@ -449,11 +448,20 @@ void APP_StartListening(FUNCTION_Type_t Function)
if (gRxVfo->IsAM) if (gRxVfo->IsAM)
{ {
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8); 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; gNeverUsed = 0;
} }
else else
{
BK4819_WriteRegister(BK4819_REG_48, 0xB000 | (gEeprom.VOLUME_GAIN << 4) | (gEeprom.DAC_GAIN << 0)); 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 #ifdef ENABLE_VOICE
if (gVoiceWriteIndex == 0) if (gVoiceWriteIndex == 0)
#endif #endif
@ -640,20 +648,24 @@ void APP_CheckRadioInterrupts(void)
if (interrupt_status_bits & BK4819_REG_02_DTMF_5TONE_FOUND) if (interrupt_status_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
{ {
gDTMF_RequestPending = true; 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; 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_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()); gDTMF_Received[gDTMF_WriteIndex++] = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code());
if (gCurrentFunction == FUNCTION_RECEIVE) if (gCurrentFunction == FUNCTION_RECEIVE)
{
DTMF_HandleRequest(); DTMF_HandleRequest();
gUpdateDisplay = true;
}
} }
if (interrupt_status_bits & BK4819_REG_02_CxCSS_TAIL) 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 else
{ {
if (Key != KEY_PTT) if (Key != KEY_PTT)
gVoltageMenuCountdown = menu_timeout_10ms; gVoltageMenuCountdown = menu_timeout_500ms;
BACKLIGHT_TurnOn(); BACKLIGHT_TurnOn();

View File

@ -115,35 +115,10 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
return false; return false;
} }
char DTMF_GetCharacter(uint8_t Code) char DTMF_GetCharacter(const uint8_t code)
{ {
switch (Code) const char list[] = "0123456789ABCD*#";
{ return (code < ARRAY_SIZE(list)) ? list[code] : 0xFF;
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 *pMsg, const char *pTemplate, uint8_t Size, bool bCheckGroup) bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size, bool bCheckGroup)
@ -190,7 +165,7 @@ void DTMF_Append(char Code)
void DTMF_HandleRequest(void) void DTMF_HandleRequest(void)
{ {
char String[20]; char String[20];
uint8_t Offset; uint8_t Offset;
if (!gDTMF_RequestPending) if (!gDTMF_RequestPending)

View File

@ -53,33 +53,33 @@ enum DTMF_CallMode_t {
typedef enum DTMF_CallMode_t DTMF_CallMode_t; typedef enum DTMF_CallMode_t DTMF_CallMode_t;
extern char gDTMF_String[15]; extern char gDTMF_String[15];
extern char gDTMF_InputBox[15]; extern char gDTMF_InputBox[15];
extern char gDTMF_Received[16]; extern char gDTMF_Received[16];
extern bool gIsDtmfContactValid; extern bool gIsDtmfContactValid;
extern char gDTMF_ID[4]; extern char gDTMF_ID[4];
extern char gDTMF_Caller[4]; extern char gDTMF_Caller[4];
extern char gDTMF_Callee[4]; extern char gDTMF_Callee[4];
extern DTMF_State_t gDTMF_State; extern DTMF_State_t gDTMF_State;
extern bool gDTMF_DecodeRing; extern bool gDTMF_DecodeRing;
extern uint8_t gDTMF_DecodeRingCountdown; extern uint8_t gDTMF_DecodeRingCountdown;
extern uint8_t gDTMFChosenContact; extern uint8_t gDTMFChosenContact;
extern uint8_t gDTMF_WriteIndex; extern uint8_t gDTMF_WriteIndex;
extern uint8_t gDTMF_PreviousIndex; extern uint8_t gDTMF_PreviousIndex;
extern uint8_t gDTMF_AUTO_RESET_TIME; extern uint8_t gDTMF_AUTO_RESET_TIME;
extern uint8_t gDTMF_InputIndex; extern uint8_t gDTMF_InputIndex;
extern bool gDTMF_InputMode; extern bool gDTMF_InputMode;
extern uint8_t gDTMF_RecvTimeout; extern uint8_t gDTMF_RecvTimeout;
extern DTMF_CallState_t gDTMF_CallState; extern DTMF_CallState_t gDTMF_CallState;
extern DTMF_ReplyState_t gDTMF_ReplyState; extern DTMF_ReplyState_t gDTMF_ReplyState;
extern DTMF_CallMode_t gDTMF_CallMode; extern DTMF_CallMode_t gDTMF_CallMode;
extern bool gDTMF_IsTx; extern bool gDTMF_IsTx;
extern uint8_t gDTMF_TxStopCountdown; extern uint8_t gDTMF_TxStopCountdown;
bool DTMF_ValidateCodes(char *pCode, uint8_t Size); bool DTMF_ValidateCodes(char *pCode, uint8_t Size);
bool DTMF_GetContact(const int Index, char *pContact); bool DTMF_GetContact(const int Index, char *pContact);
bool DTMF_FindContact(const char *pContact, char *pResult); 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_CompareMessage(const char *pDTMF, const char *pTemplate, uint8_t Size, bool bFlag);
bool DTMF_CheckGroupCall(const char *pDTMF, uint32_t Size); bool DTMF_CheckGroupCall(const char *pDTMF, uint32_t Size);
void DTMF_Append(char Code); void DTMF_Append(char Code);

View File

@ -1444,5 +1444,5 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
if (gScreenToDisplay == DISPLAY_MENU && gMenuCursor == MENU_VOL) if (gScreenToDisplay == DISPLAY_MENU && gMenuCursor == MENU_VOL)
gVoltageMenuCountdown = menu_timeout_10ms; gVoltageMenuCountdown = menu_timeout_500ms;
} }

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -53,23 +53,25 @@ void FUNCTION_Init(void)
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE; gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE;
#endif #endif
gDTMF_RequestPending = false; gDTMF_RequestPending = false;
gDTMF_WriteIndex = 0; gDTMF_WriteIndex = 0;
memset(gDTMF_Received, 0, sizeof(gDTMF_Received)); memset(gDTMF_Received, 0, sizeof(gDTMF_Received));
g_CxCSS_TAIL_Found = false; g_CxCSS_TAIL_Found = false;
g_CDCSS_Lost = false; g_CDCSS_Lost = false;
g_CTCSS_Lost = false; g_CTCSS_Lost = false;
g_VOX_Lost = false; g_VOX_Lost = false;
g_SquelchLost = false; g_SquelchLost = false;
gTailNoteEliminationCountdown = 0;
gFlagTteComplete = false; gFlagTteComplete = false;
gTailNoteEliminationCountdown = 0;
gFoundCTCSS = false; gFoundCTCSS = false;
gFoundCDCSS = false; gFoundCDCSS = false;
gFoundCTCSSCountdown = 0; gFoundCTCSSCountdown = 0;
gFoundCDCSSCountdown = 0; gFoundCDCSSCountdown = 0;
gEndOfRxDetectedMaybe = false; gEndOfRxDetectedMaybe = false;
gSystickCountdown2 = 0; gSystickCountdown2 = 0;
} }

6
misc.c
View File

@ -18,9 +18,11 @@
#include "misc.h" #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_delay_10ms = 400 / 10; // 400ms
const uint16_t key_repeat_10ms = 80 / 10; // 80ms .. MUST be less than 'key_repeat_delay' const uint16_t key_repeat_10ms = 80 / 10; // 80ms .. MUST be less than 'key_repeat_delay'

10
misc.h
View File

@ -27,6 +27,10 @@
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST) #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) #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 { enum {
MR_CHANNEL_FIRST = 0, MR_CHANNEL_FIRST = 0,
MR_CHANNEL_LAST = 199u, MR_CHANNEL_LAST = 199u,
@ -74,6 +78,10 @@ enum CssScanMode_t
typedef enum CssScanMode_t 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 uint8_t key_input_timeout_500ms;
extern const uint16_t key_repeat_delay_10ms; 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 scan_delay_10ms;
extern const uint8_t menu_timeout_10ms;
extern const uint16_t battery_save_count_10ms; extern const uint16_t battery_save_count_10ms;
extern const uint16_t dual_watch_count_after_tx_10ms; extern const uint16_t dual_watch_count_after_tx_10ms;

View File

@ -931,6 +931,7 @@ void RADIO_EnableCxCSS(void)
{ {
switch (gCurrentVfo->pTX->CodeType) switch (gCurrentVfo->pTX->CodeType)
{ {
default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
break; break;

305
ui/main.c
View File

@ -28,9 +28,9 @@
#include "ui/inputbox.h" #include "ui/inputbox.h"
#include "ui/main.h" #include "ui/main.h"
//#ifndef ARRAY_SIZE #ifndef ARRAY_SIZE
// #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
//#endif #endif
void UI_DisplayMain(void) void UI_DisplayMain(void)
{ {
@ -162,42 +162,37 @@ void UI_DisplayMain(void)
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ // channel mode { // channel mode
const unsigned int x = 2; const unsigned int x = 2;
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num) ? false : true;
// show the memory channel symbol if (!inputting)
UI_PrintStringSmall("M", x, 0, Line + 1);
if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num)
NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); // show the memory channel number NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); // show the memory channel number
else else
memcpy(String + 5, gInputBox, 3); // show the input text 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 else
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num])) if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ { // frequency mode
const unsigned int x = 2; // was 14
// show the frequency band number // show the frequency band number
const unsigned int x = 2; // was 14
sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST); sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST);
UI_PrintStringSmall(String, x, 0, Line + 1); UI_PrintStringSmall(String, x, 0, Line + 1);
} }
else #ifdef ENABLE_NOAA
{
// 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);
}
else else
{ {
String[6] = gInputBox[0]; if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num)
String[7] = gInputBox[1]; { // channel number
sprintf(String, "N%u", 1 + gEeprom.ScreenChannel[vfo_num] - NOAA_CHANNEL_FIRST);
}
else
{ // user entering channel number
sprintf(String, "N%u%u", '0' + gInputBox[0], '0' + gInputBox[1]);
}
UI_PrintStringSmall(String, 7, 0, Line + 1);
} }
UI_DisplaySmallDigits(2, String + 6, 15, Line + 1, true); #endif
}
// ************ // ************
@ -214,163 +209,120 @@ void UI_DisplayMain(void)
if (State != VFO_STATE_NORMAL) if (State != VFO_STATE_NORMAL)
{ {
//uint8_t Width = 10; const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"};
if (State >= 0 && State < ARRAY_SIZE(state_list))
memset(String, 0, sizeof(String)); UI_PrintString(state_list[State], 31, 0, Line, 8);
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
} }
else else
{ // normal state if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num)
{ // user entering a frequency
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num) UI_DisplayFrequency(gInputBox, 31, Line, true, false);
{ // user is entering a new frequency }
UI_DisplayFrequency(gInputBox, 31, Line, true, false); else
{
uint32_t frequency_Hz = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting
Channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL;
if (Channel == vfo_num)
frequency_Hz = gEeprom.VfoInfo[vfo_num].pTX->Frequency;
} }
else
{ if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
uint32_t frequency_Hz = gEeprom.VfoInfo[vfo_num].pRX->Frequency; { // channel mode
if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // show the scanlist symbols
Channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
if (Channel == vfo_num) if (Attributes & MR_CH_SCANLIST1)
frequency_Hz = gEeprom.VfoInfo[vfo_num].pTX->Frequency; memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList));
if (Attributes & MR_CH_SCANLIST2)
memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList));
} }
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) switch (gEeprom.CHANNEL_DISPLAY_MODE)
{ // channel mode {
case MDF_FREQUENCY: // show the channel frequency
{ // show the scanlist symbols #ifdef ENABLE_BIG_FREQ
const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; NUMBER_ToDigits(frequency_Hz, String);
if (Attributes & MR_CH_SCANLIST1) // show the main large frequency digits
memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); UI_DisplayFrequency(String, 31, Line, false, false);
if (Attributes & MR_CH_SCANLIST2) // show the remaining 2 small frequency digits
memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); UI_DisplaySmallDigits(2, String + 6, 112, Line + 1, true);
} #else
// show the frequency in the main font
switch (gEeprom.CHANNEL_DISPLAY_MODE) sprintf(String, "%03u.%05u", frequency_Hz / 100000, frequency_Hz % 100000);
{
case MDF_FREQUENCY: // show the channel frequency
#ifdef ENABLE_BIG_FREQ
NUMBER_ToDigits(frequency_Hz, String);
// show the main large frequency digits
UI_DisplayFrequency(String, 31, Line, false, false);
// show the remaining 2 small frequency digits
UI_DisplaySmallDigits(2, String + 6, 112, Line + 1, true);
#else
// show the frequency in the main font
sprintf(String, "%03u.%05u", frequency_Hz / 100000, frequency_Hz % 100000);
UI_PrintString(String, 31, 112, Line, 8);
#endif
break;
case MDF_CHANNEL: // show the channel number
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
UI_PrintString(String, 31, 112, Line, 8); UI_PrintString(String, 31, 112, Line, 8);
frequency_Hz = 0; #endif
break; break;
case MDF_NAME: // show the channel name case MDF_CHANNEL: // show the channel number
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
UI_PrintString(String, 31, 112, Line, 8);
frequency_Hz = 0;
break;
case MDF_NAME: // show the channel name
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);
}
else
{ // channel name
strcpy(String, gEeprom.VfoInfo[vfo_num].Name);
}
UI_PrintString(String, 31, 112, Line, 8);
break;
#ifdef ENABLE_CHAN_NAME_FREQ
case MDF_NAME_FREQ: // show the channel name and frequency
if (gEeprom.VfoInfo[vfo_num].Name[0] == 0 || gEeprom.VfoInfo[vfo_num].Name[0] == 0xFF) if (gEeprom.VfoInfo[vfo_num].Name[0] == 0 || gEeprom.VfoInfo[vfo_num].Name[0] == 0xFF)
{ // no channel name, show the channel number instead { // no channel name, show channel number instead
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
UI_PrintString(String, 31, 112, Line, 8); UI_PrintStringSmall(gEeprom.VfoInfo[vfo_num].Name, 31 + 8, 0, Line);
} }
else else
{ // channel name { // channel name
UI_PrintString(gEeprom.VfoInfo[vfo_num].Name, 31, 112, Line, 8); memset(String, 0, sizeof(String));
memcpy(String, gEeprom.VfoInfo[vfo_num].Name, 8);
UI_PrintStringSmall(gEeprom.VfoInfo[vfo_num].Name, 31 + 8, 0, Line);
} }
// show the channel frequency below the channel number/name
sprintf(String, "%03u.%05u", frequency_Hz / 100000, frequency_Hz % 100000);
UI_PrintStringSmall(String, 31 + 8, 0, Line + 1);
break; break;
#ifdef ENABLE_CHAN_NAME_FREQ
case MDF_NAME_FREQ: // show the channel name and frequency
if (gEeprom.VfoInfo[vfo_num].Name[0] == 0 || gEeprom.VfoInfo[vfo_num].Name[0] == 0xFF)
{ // no channel name, show channel number instead
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
UI_PrintStringSmall(gEeprom.VfoInfo[vfo_num].Name, 31 + 8, 0, Line);
}
else
{ // channel name
memset(String, 0, sizeof(String));
memcpy(String, gEeprom.VfoInfo[vfo_num].Name, 8);
UI_PrintStringSmall(gEeprom.VfoInfo[vfo_num].Name, 31 + 8, 0, Line);
}
// show the channel frequency below the channel number/name
sprintf(String, "%03u.%05u", frequency_Hz / 100000, frequency_Hz % 100000);
UI_PrintStringSmall(String, 31 + 8, 0, Line + 1);
break;
#endif
}
}
else
{ // frequency mode
#ifdef ENABLE_BIG_FREQ
NUMBER_ToDigits(frequency_Hz, String); // 8 digits
// show the main large frequency digits
UI_DisplayFrequency(String, 31, Line, false, false);
// show the remaining 2 small frequency digits
UI_DisplaySmallDigits(2, String + 6, 112, Line + 1, true);
#else
// show the frequency in the main font
sprintf(String, "%03u.%05u", frequency_Hz / 100000, frequency_Hz % 100000);
UI_PrintString(String, 38, 112, Line, 8);
#endif #endif
} }
} }
else
{ // frequency mode
#ifdef ENABLE_BIG_FREQ
NUMBER_ToDigits(frequency_Hz, String); // 8 digits
// show the main large frequency digits
UI_DisplayFrequency(String, 31, Line, false, false);
// show the remaining 2 small frequency digits
UI_DisplaySmallDigits(2, String + 6, 112, Line + 1, true);
#else
// show the frequency in the main font
sprintf(String, "%03u.%05u", frequency_Hz / 100000, frequency_Hz % 100000);
UI_PrintString(String, 38, 112, Line, 8);
#endif
}
} }
// ************ // ************
{ // show the TX/RX level { // show the TX/RX level
uint8_t Level = 0; uint8_t Level = 0;
if (SomeValue == 1) if (SomeValue == 1)
{ // TX power level { // TX power level
switch (gRxVfo->OUTPUT_POWER) switch (gRxVfo->OUTPUT_POWER)
{ {
case OUTPUT_POWER_LOW: case OUTPUT_POWER_LOW: Level = 2; break;
Level = 2; case OUTPUT_POWER_MID: Level = 4; break;
break; case OUTPUT_POWER_HIGH: Level = 6; break;
case OUTPUT_POWER_MID:
Level = 4;
break;
case OUTPUT_POWER_HIGH:
Level = 6;
break;
} }
} }
else else
@ -404,32 +356,21 @@ void UI_DisplayMain(void)
UI_PrintStringSmall("AM", display_width + 27, 0, Line + 1); UI_PrintStringSmall("AM", display_width + 27, 0, Line + 1);
} }
else 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; const FREQ_Config_t *pConfig = (SomeValue == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX;
switch (pConfig->CodeType) const unsigned int code_type = pConfig->CodeType;
{ const char *code_list[] = {"", "CT", "DCS", "DCR"};
default: if (code_type >= 0 && code_type < ARRAY_SIZE(code_list))
case CODE_TYPE_OFF: UI_PrintStringSmall(code_list[code_type], display_width + 24, 0, Line + 1);
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;
}
} }
String[0] = '?'; { // show the TX power
switch (gEeprom.VfoInfo[vfo_num].OUTPUT_POWER) const char pwr_list[] = "LMH";
{ // show the TX power level symbol const unsigned int i = gEeprom.VfoInfo[vfo_num].OUTPUT_POWER;
case OUTPUT_POWER_LOW: String[0] = 'L'; break; String[0] = (i >= 0 && i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0';
case OUTPUT_POWER_MID: String[0] = 'M'; break; String[1] = '\0';
case OUTPUT_POWER_HIGH: String[0] = 'H'; break; UI_PrintStringSmall(String, display_width + 46, 0, Line + 1);
} }
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) if (gEeprom.VfoInfo[vfo_num].ConfigRX.Frequency != gEeprom.VfoInfo[vfo_num].ConfigTX.Frequency)
{ // show the TX offset symbol { // show the TX offset symbol
@ -460,6 +401,16 @@ void UI_DisplayMain(void)
UI_PrintStringSmall("SCR", display_width + 106, 0, Line + 1); 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(); ST7565_BlitFullScreen();
} }