diff --git a/Makefile b/Makefile index d022d7d..4935f5e 100644 --- a/Makefile +++ b/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 diff --git a/README.md b/README.md index 7da9519..67be230 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/app/app.c b/app/app.c index 104fb9c..bda133e 100644 --- a/app/app.c +++ b/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(); diff --git a/app/dtmf.c b/app/dtmf.c index 8aba4f4..0008d76 100644 --- a/app/dtmf.c +++ b/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) @@ -190,7 +165,7 @@ void DTMF_Append(char Code) void DTMF_HandleRequest(void) { - char String[20]; + char String[20]; uint8_t Offset; if (!gDTMF_RequestPending) diff --git a/app/dtmf.h b/app/dtmf.h index 02c1a6c..4b2f6a2 100644 --- a/app/dtmf.h +++ b/app/dtmf.h @@ -53,33 +53,33 @@ enum DTMF_CallMode_t { typedef enum DTMF_CallMode_t DTMF_CallMode_t; -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_Caller[4]; -extern char gDTMF_Callee[4]; -extern DTMF_State_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_PreviousIndex; -extern uint8_t gDTMF_AUTO_RESET_TIME; -extern uint8_t gDTMF_InputIndex; -extern bool gDTMF_InputMode; -extern uint8_t gDTMF_RecvTimeout; -extern DTMF_CallState_t gDTMF_CallState; +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_Caller[4]; +extern char gDTMF_Callee[4]; +extern DTMF_State_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_PreviousIndex; +extern uint8_t gDTMF_AUTO_RESET_TIME; +extern uint8_t gDTMF_InputIndex; +extern bool gDTMF_InputMode; +extern uint8_t gDTMF_RecvTimeout; +extern DTMF_CallState_t gDTMF_CallState; extern DTMF_ReplyState_t gDTMF_ReplyState; -extern DTMF_CallMode_t gDTMF_CallMode; -extern bool gDTMF_IsTx; -extern uint8_t gDTMF_TxStopCountdown; +extern DTMF_CallMode_t gDTMF_CallMode; +extern bool gDTMF_IsTx; +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); diff --git a/app/menu.c b/app/menu.c index ee53fd3..08febd9 100644 --- a/app/menu.c +++ b/app/menu.c @@ -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; } diff --git a/firmware b/firmware index 8f81a49..84b14a1 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index 0b7228f..fbf2673 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index a43b82f..0b0b575 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 64ae626..bb0a77d 100644 --- a/functions.c +++ b/functions.c @@ -53,23 +53,25 @@ void FUNCTION_Init(void) gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE; #endif - gDTMF_RequestPending = false; - gDTMF_WriteIndex = 0; - + 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; } diff --git a/misc.c b/misc.c index a7bacb9..1816943 100644 --- a/misc.c +++ b/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' diff --git a/misc.h b/misc.h index 2ab92ee..be7081e 100644 --- a/misc.h +++ b/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; diff --git a/radio.c b/radio.c index 3104f91..3118a3a 100644 --- a/radio.c +++ b/radio.c @@ -931,6 +931,7 @@ void RADIO_EnableCxCSS(void) { switch (gCurrentVfo->pTX->CodeType) { + default: case CODE_TYPE_OFF: break; diff --git a/ui/main.c b/ui/main.c index 272c016..1889d59 100644 --- a/ui/main.c +++ b/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) { @@ -53,7 +53,7 @@ void UI_DisplayMain(void) // #else const bool single_vfo = false; // #endif - + for (vfo_num = 0; vfo_num < 2; vfo_num++) { uint8_t Channel = gEeprom.TX_CHANNEL; @@ -61,7 +61,7 @@ void UI_DisplayMain(void) uint8_t Line = (vfo_num == 0) ? 0 : 4; uint8_t *pLine0 = gFrameBuffer[Line + 0]; uint8_t *pLine1 = gFrameBuffer[Line + 1]; - + if (single_vfo) { // we're in single VFO mode - screen is dedicated to just one VFO @@ -70,7 +70,7 @@ void UI_DisplayMain(void) } - + if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) Channel = gEeprom.RX_CHANNEL; @@ -78,7 +78,7 @@ void UI_DisplayMain(void) { if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode) { // show DTMF stuff - + char Contact[16]; if (!gDTMF_InputMode) @@ -136,7 +136,7 @@ void UI_DisplayMain(void) if (gCurrentFunction == FUNCTION_TRANSMIT) { // transmitting - + #ifdef ENABLE_ALARM if (gAlarmState == ALARM_STATE_ALARM) { @@ -162,45 +162,40 @@ 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); } - 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); - } + #ifdef ENABLE_NOAA else { - String[6] = gInputBox[0]; - String[7] = gInputBox[1]; + if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num) + { // 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 // ************ - + uint8_t State = VfoState[vfo_num]; #ifdef ENABLE_ALARM @@ -214,163 +209,120 @@ 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 - UI_DisplayFrequency(gInputBox, 31, Line, true, false); + if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num) + { // user entering a 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 - { - 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; + + if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) + { // channel mode + + { // show the scanlist symbols + const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; + if (Attributes & MR_CH_SCANLIST1) + 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])) - { // channel mode - - { // show the scanlist symbols - const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; - if (Attributes & MR_CH_SCANLIST1) - memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - if (Attributes & MR_CH_SCANLIST2) - memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - } - - switch (gEeprom.CHANNEL_DISPLAY_MODE) - { - 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); + switch (gEeprom.CHANNEL_DISPLAY_MODE) + { + 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); - frequency_Hz = 0; - break; + #endif + 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) - { // no channel name, show the channel number instead + { // no channel name, show channel number instead 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 { // 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; - - #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 } } + 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 - 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 @@ -379,7 +331,7 @@ void UI_DisplayMain(void) if (gVFO_RSSI_Level[vfo_num]) Level = gVFO_RSSI_Level[vfo_num]; } - + if (Level >= 1) { memcpy(pLine1 + display_width + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); @@ -396,7 +348,7 @@ void UI_DisplayMain(void) memcpy(pLine1 + display_width + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); } } - + // ************ if (gEeprom.VfoInfo[vfo_num].IsAM) @@ -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); } - 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(); } -