From 5416c3a041cc7b4e2c70913db232252cbfb5adf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Wed, 5 Nov 2025 22:07:44 +0100 Subject: [PATCH] Update --- Makefile | 4 - README.md | 1 - app/action.c | 3 - app/app.c | 102 ----------------- app/dtmf.c | 301 ------------------------------------------------- app/dtmf.h | 29 ----- app/fskmodem.c | 230 +++++++++++++++++++++++++------------ app/fskmodem.h | 2 +- app/generic.c | 10 -- app/main.c | 9 +- app/menu.c | 73 +----------- app/messages.c | 77 +++++++++---- app/messages.h | 5 +- app/scanner.c | 3 - app/uart.c | 3 - audio.c | 5 +- audio.h | 4 - functions.c | 18 --- misc.c | 5 - misc.h | 5 - radio.c | 25 ---- radio.h | 3 - settings.c | 54 +-------- settings.h | 17 +-- ui/main.c | 54 +-------- ui/menu.c | 67 +---------- ui/menu.h | 16 +-- ui/messages.c | 111 ++++++------------ 28 files changed, 273 insertions(+), 963 deletions(-) diff --git a/Makefile b/Makefile index 3e084eb..ebf8c08 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ ENABLE_VOX ?= 0 ENABLE_ALARM ?= 0 ENABLE_TX1750 ?= 0 ENABLE_PWRON_PASSWORD ?= 0 -ENABLE_DTMF_CALLING ?= 0 ENABLE_FLASHLIGHT ?= 1 # ---- CUSTOM MODS ---- @@ -404,9 +403,6 @@ endif ifeq ($(ENABLE_SCAN_RANGES),1) CFLAGS += -DENABLE_SCAN_RANGES endif -ifeq ($(ENABLE_DTMF_CALLING),1) - CFLAGS += -DENABLE_DTMF_CALLING -endif ifeq ($(ENABLE_REGA),1) CFLAGS += -DENABLE_REGA endif diff --git a/README.md b/README.md index b2426d5..490e552 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,6 @@ Special thanks to Jean-Cyrille F6IWW (2 times), Fabrice 14RC123, David F4BPP, Ol * no more PWM noise, * and more... * enabled AIR COPY -* disabled ENABLE_DTMF_CALLING, * disabled SCRAMBLER, * remove 200Tx, 350Tx and 500Tx, * unlock TX on all bands needs only to be repeat 3 times, diff --git a/app/action.c b/app/action.c index 74fb7b1..1dcd65b 100644 --- a/app/action.c +++ b/app/action.c @@ -206,9 +206,6 @@ void ACTION_Scan(bool bRestart) // not scanning gMonitor = false; -#ifdef ENABLE_DTMF_CALLING - DTMF_clear_RX(); -#endif gDTMF_RX_live_timeout = 0; memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); diff --git a/app/app.c b/app/app.c index ccde46e..47d30ed 100644 --- a/app/app.c +++ b/app/app.c @@ -186,10 +186,6 @@ static void CheckForIncoming(void) { static void HandleIncoming(void) { if (!g_SquelchLost) { // squelch is closed -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_RX_index > 0) - DTMF_clear_RX(); -#endif if (gCurrentFunction != FUNCTION_FOREGROUND) { FUNCTION_Select(FUNCTION_FOREGROUND); gUpdateDisplay = true; @@ -217,30 +213,6 @@ static void HandleIncoming(void) { } else if (!bFlag) return; -#ifdef ENABLE_DTMF_CALLING - if (gScanStateDir == SCAN_OFF && (gRxVfo->DTMF_DECODING_ENABLE)) { - - // DTMF DCD is enabled - DTMF_HandleRequest(); - if (gDTMF_CallState == DTMF_CALL_STATE_NONE) { - if (gRxReceptionMode != RX_MODE_DETECTED) { - return; - } - gDualWatchCountdown_10ms = dual_watch_count_after_1_10ms; - gScheduleDualWatch = false; - - gRxReceptionMode = RX_MODE_LISTENING; - - // let the user see DW is not active - gDualWatchActive = false; - gUpdateStatus = true; - - gUpdateDisplay = true; - return; - } - } -#endif - APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE); } @@ -670,21 +642,6 @@ static void CheckRadioInterrupts(void) { gUpdateDisplay = true; } -#ifdef ENABLE_DTMF_CALLING - if (gRxVfo->DTMF_DECODING_ENABLE) { - if (gDTMF_RX_index >= sizeof(gDTMF_RX) - 1) { // make room - memmove(&gDTMF_RX[0], &gDTMF_RX[1], sizeof(gDTMF_RX) - 1); - gDTMF_RX_index--; - } - gDTMF_RX[gDTMF_RX_index++] = c; - gDTMF_RX[gDTMF_RX_index] = 0; - gDTMF_RX_timeout = DTMF_RX_timeout_500ms; // time till we delete it - gDTMF_RX_pending = true; - - SYSTEM_DelayMs(3);//fix DTMF not reply@Yurisu - DTMF_HandleRequest(); - } -#endif } } } @@ -834,9 +791,6 @@ static void HandleVox(void) { FUNCTION_Select(FUNCTION_FOREGROUND); if (gCurrentFunction != FUNCTION_TRANSMIT && !SerialConfigInProgress()) { -#ifdef ENABLE_DTMF_CALLING - gDTMF_ReplyState = DTMF_REPLY_NONE; -#endif RADIO_PrepareTX(); gUpdateDisplay = true; } @@ -941,9 +895,6 @@ void APP_Update(void) { #endif #ifdef ENABLE_FMRADIO && !gFmRadioMode -#endif -#ifdef ENABLE_DTMF_CALLING - && gDTMF_CallState == DTMF_CALL_STATE_NONE #endif ) { DualwatchAlternate(); // toggle between the two VFO's @@ -981,9 +932,6 @@ void APP_Update(void) { #ifdef ENABLE_FMRADIO || gFmRadioMode #endif -#ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE -#endif #ifdef ENABLE_NOAA || (gIsNoaaMode && (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))) #endif @@ -1434,11 +1382,6 @@ void APP_TimeSlice500ms(void) { if (--gMenuCountdown == 0) exit_menu = (gScreenToDisplay == DISPLAY_MENU); // exit menu mode -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_RX_timeout > 0) - if (--gDTMF_RX_timeout == 0) - DTMF_clear_RX(); -#endif // Skipped authentic device check @@ -1625,33 +1568,6 @@ void APP_TimeSlice500ms(void) { FSKModem_TimeSlice500ms(); UI_MAIN_TimeSlice500ms(); -#ifdef ENABLE_DTMF_CALLING - if (gCurrentFunction != FUNCTION_TRANSMIT) { - if (gDTMF_DecodeRingCountdown_500ms > 0) { - // make "ring-ring" sound - gDTMF_DecodeRingCountdown_500ms--; - AUDIO_PlayBeep(BEEP_880HZ_200MS); - } - } else { - gDTMF_DecodeRingCountdown_500ms = 0; - } - - if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT - && gCurrentFunction != FUNCTION_RECEIVE && gDTMF_auto_reset_time_500ms > 0 - && --gDTMF_auto_reset_time_500ms == 0) { - gUpdateDisplay = true; - if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED && gEeprom.DTMF_auto_reset_time >= DTMF_HOLD_MAX) { - gDTMF_CallState = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed - } else { - gDTMF_CallState = DTMF_CALL_STATE_NONE; - } - } - - if (gDTMF_IsTx && gDTMF_TxStopCountdown_500ms > 0 && --gDTMF_TxStopCountdown_500ms == 0) { - gDTMF_IsTx = false; - gUpdateDisplay = true; - } -#endif } #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) @@ -1767,18 +1683,6 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { if (gScreenToDisplay == DISPLAY_MENU) // 1of11 gMenuCountdown = menu_timeout_500ms; -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_DecodeRingCountdown_500ms > 0) { // cancel the ringing - gDTMF_DecodeRingCountdown_500ms = 0; - - AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL); - - if (Key != KEY_PTT) { - gPttWasReleased = true; - return; - } - } -#endif } bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN; @@ -2030,12 +1934,6 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { RADIO_SetupRegisters(true); -#ifdef ENABLE_DTMF_CALLING - gDTMF_auto_reset_time_500ms = 0; - gDTMF_CallState = DTMF_CALL_STATE_NONE; - gDTMF_TxStopCountdown_500ms = 0; - gDTMF_IsTx = false; -#endif gVFO_RSSI_bar_level[0] = 0; gVFO_RSSI_bar_level[1] = 0; diff --git a/app/dtmf.c b/app/dtmf.c index 15ef6c8..18e9291 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -44,40 +44,8 @@ uint8_t gDTMF_PreviousIndex = 0; char gDTMF_RX_live[20]; uint8_t gDTMF_RX_live_timeout = 0; -#ifdef ENABLE_DTMF_CALLING -char gDTMF_RX[17]; -uint8_t gDTMF_RX_index = 0; -uint8_t gDTMF_RX_timeout = 0; -bool gDTMF_RX_pending = false; -bool gIsDtmfContactValid; -char gDTMF_ID[4]; -char gDTMF_Caller[4]; -char gDTMF_Callee[4]; -DTMF_State_t gDTMF_State; -uint8_t gDTMF_DecodeRingCountdown_500ms; -uint8_t gDTMF_chosen_contact; -uint8_t gDTMF_auto_reset_time_500ms; -DTMF_CallState_t gDTMF_CallState; -DTMF_CallMode_t gDTMF_CallMode; - -bool gDTMF_IsTx; - -uint8_t gDTMF_TxStopCountdown_500ms; -bool gDTMF_IsGroupCall; -#endif DTMF_ReplyState_t gDTMF_ReplyState; - -#ifdef ENABLE_DTMF_CALLING -void DTMF_clear_RX(void) -{ - gDTMF_RX_timeout = 0; - gDTMF_RX_index = 0; - gDTMF_RX_pending = false; - memset(gDTMF_RX, 0, sizeof(gDTMF_RX)); -} -#endif - void DTMF_SendEndOfTransmission(void) { if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) { @@ -85,9 +53,6 @@ void DTMF_SendEndOfTransmission(void) } if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH) -#ifdef ENABLE_DTMF_CALLING - && gDTMF_CallState == DTMF_CALL_STATE_NONE -#endif ) { // end-of-tx if (gEeprom.DTMF_SIDE_TONE) { AUDIO_AudioPathOn(); @@ -134,41 +99,6 @@ bool DTMF_ValidateCodes(char *pCode, const unsigned int size) return true; } -#ifdef ENABLE_DTMF_CALLING -bool DTMF_GetContact(const int Index, char *pContact) -{ - if (Index < 0 || Index >= MAX_DTMF_CONTACTS || pContact == NULL) { - return false; - } - - EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16); - - // check whether the first character is printable or not - return (pContact[0] >= ' ' && pContact[0] < 127); -} - -bool DTMF_FindContact(const char *pContact, char *pResult) -{ - pResult[0] = 0; - - for (unsigned int i = 0; i < MAX_DTMF_CONTACTS; i++) { - char Contact[16]; - if (!DTMF_GetContact(i, Contact)) { - return false; - } - - if (memcmp(pContact, Contact + 8, 3) == 0) { - memcpy(pResult, Contact, 8); - pResult[8] = 0; - return true; - } - } - - return false; -} - -#endif - char DTMF_GetCharacter(const unsigned int code) { if (code <= KEY_9) @@ -185,33 +115,6 @@ char DTMF_GetCharacter(const unsigned int code) default: return 0xff; } } -#ifdef ENABLE_DTMF_CALLING -static bool CompareMessage(const char *pMsg, const char *pTemplate, const unsigned int size, const bool bCheckGroup) -{ - unsigned int i; - for (i = 0; i < size; i++) - { - if (pMsg[i] != pTemplate[i]) - { - if (!bCheckGroup || pMsg[i] != gEeprom.DTMF_GROUP_CALL_CODE) - return false; - gDTMF_IsGroupCall = true; - } - } - - return true; -} - -DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size) -{ - for (unsigned int i = 0; i < size; i++) - if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE) { - return DTMF_CALL_MODE_GROUP; - } - - return DTMF_CALL_MODE_NOT_GROUP; -} -#endif void DTMF_clear_input_box(void) { @@ -232,227 +135,23 @@ void DTMF_Append(const char code) gDTMF_InputBox[gDTMF_InputBox_Index++] = code; } -#ifdef ENABLE_DTMF_CALLING -void DTMF_HandleRequest(void) -{ // proccess the RX'ed DTMF characters - - char String[21]; - unsigned int Offset; - - if (!gDTMF_RX_pending) - return; // nothing new received - - if (gScanStateDir != SCAN_OFF || gCssBackgroundScan) - { // we're busy scanning - DTMF_clear_RX(); - return; - } - - if (!gRxVfo->DTMF_DECODING_ENABLE) - { // D-DCD is disabled or we're alive - DTMF_clear_RX(); - return; - } - - gDTMF_RX_pending = false; - - if (gDTMF_RX_index >= 9) - { // look for the KILL code - - sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.KILL_CODE); - - Offset = gDTMF_RX_index - strlen(String); - - if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) - { // bugger - -// if (gEeprom.PERMIT_REMOTE_KILL) -// { -// gSetting_KILLED = true; // oooerr ! -// -// DTMF_clear_RX(); -// -// SETTINGS_SaveSettings(); -// -// gDTMF_ReplyState = DTMF_REPLY_AB; -// -// #ifdef ENABLE_FMRADIO -// if (gFmRadioMode) -// { -// FM_TurnOff(); -// GUI_SelectNextDisplay(DISPLAY_MAIN); -// } -// #endif -// } -// else -// { - gDTMF_ReplyState = DTMF_REPLY_NONE; -// } - - gDTMF_CallState = DTMF_CALL_STATE_NONE; - - gUpdateDisplay = true; - gUpdateStatus = true; - return; - } - } - -// if (gDTMF_RX_index >= 9) -// { // look for the REVIVE code -// -// sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.REVIVE_CODE); -// -// Offset = gDTMF_RX_index - strlen(String); -// -// if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) -// { // shit, we're back ! -// -// gSetting_KILLED = false; -// -// DTMF_clear_RX(); -// -// SETTINGS_SaveSettings(); -// -// gDTMF_ReplyState = DTMF_REPLY_AB; -// gDTMF_CallState = DTMF_CALL_STATE_NONE; -// -// gUpdateDisplay = true; -// gUpdateStatus = true; -// return; -// } -// } - - if (gDTMF_RX_index >= 2) - { // look for ACK reply - char *pPrintStr = "AB"; - - Offset = gDTMF_RX_index - strlen(pPrintStr); - - if (CompareMessage(gDTMF_RX + Offset, pPrintStr, strlen(pPrintStr), true)) { - // ends with "AB" - - if (gDTMF_ReplyState != DTMF_REPLY_NONE) // 1of11 -// if (gDTMF_CallState != DTMF_CALL_STATE_NONE) // 1of11 -// if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) // 1of11 - { - gDTMF_State = DTMF_STATE_TX_SUCC; - DTMF_clear_RX(); - gUpdateDisplay = true; - return; - } - } - } - - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT && - gDTMF_CallMode == DTMF_CALL_MODE_NOT_GROUP && - gDTMF_RX_index >= 9) - { // waiting for a reply - - sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, "AAAAA"); - - Offset = gDTMF_RX_index - strlen(String); - - if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), false)) - { // we got a response - gDTMF_State = DTMF_STATE_CALL_OUT_RSP; - DTMF_clear_RX(); - gUpdateDisplay = true; - } - } - - if (gDTMF_CallState != DTMF_CALL_STATE_NONE) - { // we've been killed or expecting a reply - return; - } - - if (gDTMF_RX_index >= 7) - { // see if we're being called - - gDTMF_IsGroupCall = false; - - sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE); - - Offset = gDTMF_RX_index - strlen(String) - 3; - - if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) - { // it's for us ! - - gDTMF_CallState = DTMF_CALL_STATE_RECEIVED; - - memset(gDTMF_Callee, 0, sizeof(gDTMF_Callee)); - memset(gDTMF_Caller, 0, sizeof(gDTMF_Caller)); - memcpy(gDTMF_Callee, gDTMF_RX + Offset + 0, 3); - memcpy(gDTMF_Caller, gDTMF_RX + Offset + 4, 3); - - DTMF_clear_RX(); - - gUpdateDisplay = true; - - switch (gEeprom.DTMF_DECODE_RESPONSE) - { - case DTMF_DEC_RESPONSE_BOTH: - gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms; - [[fallthrough]]; - case DTMF_DEC_RESPONSE_REPLY: - gDTMF_ReplyState = DTMF_REPLY_AAAAA; - break; - case DTMF_DEC_RESPONSE_RING: - gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms; - break; - default: - case DTMF_DEC_RESPONSE_NONE: - gDTMF_DecodeRingCountdown_500ms = 0; - gDTMF_ReplyState = DTMF_REPLY_NONE; - break; - } - - if (gDTMF_IsGroupCall) - gDTMF_ReplyState = DTMF_REPLY_NONE; - } - } -} -#endif void DTMF_Reply(void) { uint16_t Delay; -#ifdef ENABLE_DTMF_CALLING - char String[23]; -#endif const char *pString = NULL; switch (gDTMF_ReplyState) { case DTMF_REPLY_ANI: -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_CallMode != DTMF_CALL_MODE_DTMF) - { // append our ID code onto the end of the DTMF code to send - sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, gEeprom.ANI_DTMF_ID); - pString = String; - } - else -#endif { pString = gDTMF_String; } break; -#ifdef ENABLE_DTMF_CALLING - case DTMF_REPLY_AB: - pString = "AB"; - break; - - case DTMF_REPLY_AAAAA: - sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, "AAAAA"); - pString = String; - break; -#endif default: case DTMF_REPLY_NONE: if ( -#ifdef ENABLE_DTMF_CALLING - gDTMF_CallState != DTMF_CALL_STATE_NONE || -#endif gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_OFF || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN) diff --git a/app/dtmf.h b/app/dtmf.h index 0e51383..eadabd5 100644 --- a/app/dtmf.h +++ b/app/dtmf.h @@ -87,33 +87,4 @@ void DTMF_Append(const char code); void DTMF_Reply(void); void DTMF_SendEndOfTransmission(void); -#ifdef ENABLE_DTMF_CALLING - -extern char gDTMF_RX[17]; -extern uint8_t gDTMF_RX_index; -extern uint8_t gDTMF_RX_timeout; -extern bool gDTMF_RX_pending; - -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 uint8_t gDTMF_DecodeRingCountdown_500ms; -extern uint8_t gDTMF_chosen_contact; -extern uint8_t gDTMF_auto_reset_time_500ms; -extern DTMF_CallState_t gDTMF_CallState; - -extern DTMF_CallMode_t gDTMF_CallMode; -extern bool gDTMF_IsTx; -extern uint8_t gDTMF_TxStopCountdown_500ms; - -void DTMF_clear_RX(void); -DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size); -bool DTMF_GetContact(const int Index, char *pContact); -bool DTMF_FindContact(const char *pContact, char *pResult); -void DTMF_HandleRequest(void); - -#endif - #endif diff --git a/app/fskmodem.c b/app/fskmodem.c index dad58cc..6e2e7b7 100644 --- a/app/fskmodem.c +++ b/app/fskmodem.c @@ -6,6 +6,7 @@ //#include "messages.h" #include "driver/uart.h" #include "../ui/messages.h" +#include "ui/ui.h" uint16_t TONE2_FREQ; @@ -63,42 +64,68 @@ void FSKModem_TimeSlice500ms(void) { } void MSG_ConfigureFSK(bool rx) { - BK4819_WriteRegister(BK4819_REG_70, TONE2_ENABLE_BIT | (96U << 0)); - // Compute tone frequency control word (for 26 MHz XTAL) + // quick helper + bool isAFSK = (gEeprom.FSKMode == MOD_AFSK_1200 || + gEeprom.FSKMode == MOD_AFSK_2400 || + gEeprom.FSKMode == MOD_NOAA_SAME); + + + // Base tone config + uint16_t tone1 = 0, tone2 = 0; #define BK4819_FREQ_WORD(freq_hz) ((uint16_t)((freq_hz) * 10.32444f)) - // Tone word macro for 26MHz XTAL (app note: freq * 10.32444) -#undef BK4819_FREQ_WORD -#define BK4819_FREQ_WORD(freq_hz) ((uint16_t)((freq_hz) * 10.32444f)) + if (isAFSK) { + // Bell-202 style tones for AFSK/NOAA + switch (gEeprom.FSKMode) { + case MOD_AFSK_1200: + tone1 = BK4819_FREQ_WORD(1200.0f); // mark + tone2 = BK4819_FREQ_WORD(2200.0f); // space + break; + case MOD_AFSK_2400: + tone1 = BK4819_FREQ_WORD(1200.0f); + tone2 = BK4819_FREQ_WORD(2400.0f); + break; + case MOD_NOAA_SAME: + tone1 = BK4819_FREQ_WORD(1562.5f); // typical mark + tone2 = BK4819_FREQ_WORD(2083.3f); // typical space + break; + default: + tone1 = BK4819_FREQ_WORD(1200.0f); + tone2 = BK4819_FREQ_WORD(2200.0f); + break; + } - switch (gEeprom.FSKMode) { - case MOD_AFSK_2400: - TONE2_FREQ = BK4819_FREQ_WORD(2400.0f); - break; - case MOD_AFSK_1200: - TONE2_FREQ = BK4819_FREQ_WORD(1200.0f); - break; - case MOD_FSK_700: - TONE2_FREQ = BK4819_FREQ_WORD(700.0f); - break; - case MOD_FSK_450: - TONE2_FREQ = BK4819_FREQ_WORD(450.0f); - break; - case MOD_FSK_1200_2400: - TONE2_FREQ = BK4819_FREQ_WORD(1200.0f); - break; - case MOD_NOAA_SAME: - TONE2_FREQ = BK4819_FREQ_WORD(2083.3f); - break; - default: - TONE2_FREQ = BK4819_FREQ_WORD(1200.0f); - break; + BK4819_WriteRegister(BK4819_REG_71, tone1); + BK4819_WriteRegister(BK4819_REG_72, tone2); + // enable both tones + BK4819_WriteRegister(BK4819_REG_70, + TONE1_ENABLE_BIT | TONE2_ENABLE_BIT | + (96U << 8) | (96U << 0)); + } else { + // plain FSK path: only TONE2 used (frequency for binary shift display/debug) + switch (gEeprom.FSKMode) { + case MOD_FSK_450: + tone2 = BK4819_FREQ_WORD(450.0f); + break; + case MOD_FSK_700: + tone2 = BK4819_FREQ_WORD(700.0f); + break; + case MOD_FSK_1200: + tone2 = BK4819_FREQ_WORD(1200.0f); + break; + case MOD_FSK_2400: + tone2 = BK4819_FREQ_WORD(2400.0f); + break; + default: + tone2 = BK4819_FREQ_WORD(1200.0f); + break; + } + BK4819_WriteRegister(BK4819_REG_72, tone2); + BK4819_WriteRegister(BK4819_REG_70, TONE2_ENABLE_BIT | (96U << 0)); } - BK4819_WriteRegister(BK4819_REG_72, TONE2_FREQ); - - // Base config (enable + preamble type AA) + // Base FSK config uint16_t fskConfig = FSK_ENABLE_BIT | FSK_PREAMBLE_TYPE_AA; // Compose the correct fields into REG_58: @@ -108,30 +135,37 @@ void MSG_ConfigureFSK(bool rx) { switch (gEeprom.FSKMode) { case MOD_AFSK_1200: fskConfig |= FSK_TX_MODE_FFSK_1200_1800 /*<<13 in macro*/ - | FSK_RX_MODE_FFSK_1200_1800 /*<<10 in macro*/ - | FSK_RX_BW_FFSK_1200_1800; /*<<1 in macro*/ + | FSK_RX_MODE_FFSK_1200_1800 /*<<10 in macro*/ + | FSK_RX_BW_FFSK_1200_1800; /*<<1 in macro*/ break; case MOD_AFSK_2400: fskConfig |= FSK_TX_MODE_FFSK_1200_2400 - | FSK_RX_MODE_FFSK_1200_2400 - | FSK_RX_BW_2_4K_FFSK_1200_2400; + | FSK_RX_MODE_FFSK_1200_2400 + | FSK_RX_BW_2_4K_FFSK_1200_2400; break; case MOD_NOAA_SAME: fskConfig |= FSK_TX_MODE_NOAA_SAME - | FSK_RX_MODE_FSK_1_2K_2_4K_NOAA - | FSK_RX_BW_NOAA_SAME; + | FSK_RX_MODE_FSK_1_2K_2_4K_NOAA + | FSK_RX_BW_NOAA_SAME; + break; + + case MOD_FSK_2400: + // binary FSK 1.2k/2.4k - use default FSK TX/RX modes and 1.2k BW + fskConfig |= FSK_TX_MODE_FSK_1_2K_2_4K + | FSK_RX_MODE_FSK_1_2K_2_4K_NOAA + | FSK_RX_BW_2_4K_FFSK_1200_2400; break; case MOD_FSK_700: case MOD_FSK_450: - case MOD_FSK_1200_2400: + case MOD_FSK_1200: default: // binary FSK 1.2k/2.4k - use default FSK TX/RX modes and 1.2k BW fskConfig |= FSK_TX_MODE_FSK_1_2K_2_4K - | FSK_RX_MODE_FSK_1_2K_2_4K_NOAA - | FSK_RX_BW_1_2K; + | FSK_RX_MODE_FSK_1_2K_2_4K_NOAA + | FSK_RX_BW_1_2K; break; } @@ -143,9 +177,23 @@ void MSG_ConfigureFSK(bool rx) { BK4819_WriteRegister(BK4819_REG_5C, FSK_CRC_ON); if (rx) { - BK4819_WriteRegister(BK4819_REG_5E, (64U << 3) | (1U << 0)); + uint8_t threshold; + switch (gEeprom.FSKMode) { + case MOD_AFSK_1200: + case MOD_NOAA_SAME: + threshold = 1U; + break; + case MOD_AFSK_2400: + threshold = 2U; // Slightly higher; 2400 baud can fill FIFO faster + break; + default: + threshold = 4U; // FSK modes + break; + } + BK4819_WriteRegister(BK4819_REG_5E, (64U << 3) | threshold); } + // Data length (REG_5D<15:8>) size_t size = sizeof(dataPacket); if (rx) size = (((size + 1) / 2) * 2) + 2; @@ -154,12 +202,65 @@ void MSG_ConfigureFSK(bool rx) { BK4819_FskClearFifo(); // REG_59: clear flags, preamble len, sync len etc. - uint16_t fskParams = FSK_SYNC_LEN_BIT | ((rx ? 0U : 15U) << 4); + //uint16_t fskParams = FSK_SYNC_LEN_BIT | ((rx ? 0U : 15U) << 4); + uint16_t preamble_len = (gEeprom.FSKMode == MOD_AFSK_1200 || gEeprom.FSKMode == MOD_AFSK_2400 || gEeprom.FSKMode == MOD_NOAA_SAME) ? 10U : (rx ? 0U + : 15U); + uint16_t fskParams = FSK_SYNC_LEN_BIT | (preamble_len << 4); if (gCurrentVfo->SCRAMBLING_TYPE > 0) fskParams |= FSK_SCRAMBLE_ENABLE; BK4819_WriteRegister(BK4819_REG_59, fskParams); + // Clear interrupt flags BK4819_WriteRegister(BK4819_REG_02, 0); + + // Enable AF path filters for tone demodulation in AFSK/NOAA modes + if (gEeprom.FSKMode == MOD_AFSK_1200 || + gEeprom.FSKMode == MOD_AFSK_2400 || + gEeprom.FSKMode == MOD_NOAA_SAME) { + + // Keep DC cancel, disable only deemphasis + BK4819_WriteRegister(BK4819_REG_2B, + (1U << 15) | (1U << 14) | (1U << 8)); + } else { + + BK4819_WriteRegister(BK4819_REG_2B, (1u << 2) | (1u << 0)); + } + + // set the FM deviation level + const uint16_t dev_val = BK4819_ReadRegister(BK4819_REG_40); + + uint16_t deviation; + switch (gEeprom.FSKMode) { + case MOD_AFSK_1200: + case MOD_AFSK_2400: + case MOD_NOAA_SAME: + deviation = 650; // 0.65 kHz for audio-based tones (linear region) + break; + + case MOD_FSK_450: + deviation = 225; // ≈ half of 450 Hz separation + break; + + case MOD_FSK_700: + deviation = 350; // ≈ half of 700 Hz separation + break; + + case MOD_FSK_1200: + deviation = 600; // halfway between 1200 and 2400 = 1.8 kHz spacing → ±900 Hz dev + break; + + case MOD_FSK_2400: + deviation = 1200; // halfway between 1200 and 2400 = 1.8 kHz spacing → ±900 Hz dev + break; + + default: + deviation = 750; // safe fallback + break; + } + BK4819_WriteRegister(BK4819_REG_40, (dev_val & 0xf000) | (deviation & 0x0fff)); + // restore FM deviation level + //BK4819_WriteRegister(BK4819_REG_40, dev_val); + } @@ -210,6 +311,9 @@ void processReceivedPacket(DataPacket *packet) { itoa(packet->src, numBuf); // Convert number to string strcat(String, numBuf); MESSAGES_SAVE(); + gRequestDisplayScreen = DISPLAY_MESSAGES; + GUI_SelectNextDisplay(gRequestDisplayScreen); + gActiveMessageBank = MESSAGES_COUNT / 3 - 1; UI_DisplayPopup(String); inBoundPacket.flags |= 0x40; inBoundPacket.dest = inBoundPacket.src; @@ -265,29 +369,7 @@ void MSG_FSKSendData(DataPacket *dataPacketIn) { const uint16_t css_val = BK4819_ReadRegister(BK4819_REG_51); BK4819_WriteRegister(BK4819_REG_51, 0); - // set the FM deviation level - const uint16_t dev_val = BK4819_ReadRegister(BK4819_REG_40); - { - uint16_t deviation; - switch (gEeprom.VfoInfo[gEeprom.TX_VFO].CHANNEL_BANDWIDTH) { - case BK4819_FILTER_BW_WIDE: - deviation = 1300; - break; // 20k // measurements by kamilsss655 - case BK4819_FILTER_BW_NARROW: - deviation = 1200; - break; // 10k - // case BK4819_FILTER_BW_NARROWAVIATION: deviation = 850; break; // 5k - // case BK4819_FILTER_BW_NARROWER: deviation = 850; break; // 5k - // case BK4819_FILTER_BW_NARROWEST: deviation = 850; break; // 5k - default: - deviation = 850; - break; // 5k - } - - //BK4819_WriteRegister(0x40, (3u << 12) | (deviation & 0xfff)); - BK4819_WriteRegister(BK4819_REG_40, (dev_val & 0xf000) | (deviation & 0xfff)); - } // REG_2B 0 // @@ -302,8 +384,20 @@ void MSG_FSKSendData(DataPacket *dataPacketIn) { // // disable the 300Hz HPF and FM pre-emphasis filter // + const uint16_t filt_val = BK4819_ReadRegister(BK4819_REG_2B); - BK4819_WriteRegister(BK4819_REG_2B, (1u << 2) | (1u << 0)); + // Enable AF path filters for tone demodulation in AFSK/NOAA modes + if (gEeprom.FSKMode == MOD_AFSK_1200 || + gEeprom.FSKMode == MOD_AFSK_2400 || + gEeprom.FSKMode == MOD_NOAA_SAME) { + + // Keep DC cancel, disable only deemphasis + BK4819_WriteRegister(BK4819_REG_2B, + (1U << 15) | (1U << 14) | (1U << 8)); + } else { + + BK4819_WriteRegister(BK4819_REG_2B, (1u << 2) | (1u << 0)); + } MSG_ConfigureFSK(false); @@ -343,9 +437,6 @@ void MSG_FSKSendData(DataPacket *dataPacketIn) { // disable TX MSG_ConfigureFSK(true); - // restore FM deviation level - BK4819_WriteRegister(BK4819_REG_40, dev_val); - // restore TX/RX filtering BK4819_WriteRegister(BK4819_REG_2B, filt_val); @@ -365,7 +456,8 @@ void MSG_FSKSendData(DataPacket *dataPacketIn) { BK4819_ExitTxMute(); } - if (!(dataPacketIn->flags & 0x64)) { + //if (!(dataPacketIn->flags & 0x64)) { + if (!(dataPacketIn->flags & 0x40)) { gGotACK = false; } BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false); @@ -415,7 +507,7 @@ void FSK_HANDLE_IRQ(unsigned short irq) { UART_Send((const void *) &ptr[gFSKWriteIndex - 1], 2); } - SYSTEM_DelayMs(10); + SYSTEM_DelayMs(2); } if (rx_finished) { diff --git a/app/fskmodem.h b/app/fskmodem.h index a690a2d..07c883a 100644 --- a/app/fskmodem.h +++ b/app/fskmodem.h @@ -80,7 +80,7 @@ #define DataPacketDataSize (21) -#define SEQParameterEEPROM 0x1D00 +#define SEQParameterEEPROM 0x1C00 typedef struct { uint32_t dest; //4bytes diff --git a/app/generic.c b/app/generic.c index 39842de..6be96dc 100644 --- a/app/generic.c +++ b/app/generic.c @@ -198,16 +198,6 @@ void GENERIC_Key_PTT(bool bKeyPressed) if (gDTMF_InputBox_Index < sizeof(gDTMF_InputBox)) gDTMF_InputBox[gDTMF_InputBox_Index] = 0; // NULL term the string -#ifdef ENABLE_DTMF_CALLING - // append our DTMF ID to the inputted DTMF code - - // IF the user inputted code is exactly 3 digits long and D-DCD is enabled - if (gDTMF_InputBox_Index == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0) - gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3); - else - gDTMF_CallMode = DTMF_CALL_MODE_DTMF; - - gDTMF_State = DTMF_STATE_0; -#endif // remember the DTMF string gDTMF_PreviousIndex = gDTMF_InputBox_Index; strcpy(gDTMF_String, gDTMF_InputBox); diff --git a/app/main.c b/app/main.c index 58ddb4b..1289efa 100644 --- a/app/main.c +++ b/app/main.c @@ -578,14 +578,6 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { if (!bKeyHeld && bKeyPressed) { // exit key pressed gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT) - { // clear CALL mode being displayed - gDTMF_CallState = DTMF_CALL_STATE_NONE; - gUpdateDisplay = true; - return; - } -#endif #ifdef ENABLE_FMRADIO if (!gFmRadioMode) @@ -680,6 +672,7 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) { if (gWasFKeyPressed && bKeyPressed) { MESSAGES_GET(); gRequestDisplayScreen = DISPLAY_MESSAGES; + gActiveMessageBank = MESSAGES_COUNT / 3 - 1; return; } diff --git a/app/menu.c b/app/menu.c index dc304a6..0efdd4e 100644 --- a/app/menu.c +++ b/app/menu.c @@ -244,9 +244,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) { case MENU_S_ADD3: case MENU_STE: case MENU_D_ST: -#ifdef ENABLE_DTMF_CALLING - case MENU_D_DCD: -#endif + case MENU_D_LIVE_DEC: #ifdef ENABLE_NOAA case MENU_NOAA_S: @@ -315,12 +313,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) { *pMax = 5; break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_RSP: - //*pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_D_RSP) - 1; - break; -#endif + case MENU_PTT_ID: //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1; @@ -331,23 +324,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) { *pMax = ARRAY_SIZE(gSubMenu_BAT_TXT) - 1; break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_HOLD: - *pMin = 5; - *pMax = 60; - break; -#endif + case MENU_D_PRE: *pMin = 3; *pMax = 99; break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_LIST: - *pMin = 1; - *pMax = 16; - break; -#endif #ifdef ENABLE_F_CAL_MENU case MENU_F_CALI: *pMin = -50; @@ -671,15 +653,6 @@ void MENU_AcceptSetting(void) { gEeprom.DTMF_SIDE_TONE = gSubMenuSelection; break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_RSP: - gEeprom.DTMF_DECODE_RESPONSE = gSubMenuSelection; - break; - - case MENU_D_HOLD: - gEeprom.DTMF_auto_reset_time = gSubMenuSelection; - break; -#endif case MENU_D_PRE: gEeprom.DTMF_PRELOAD_TIME = gSubMenuSelection * 10; break; @@ -693,13 +666,6 @@ void MENU_AcceptSetting(void) { gSetting_battery_text = gSubMenuSelection; break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_DCD: - gTxVfo->DTMF_DECODING_ENABLE = gSubMenuSelection; - DTMF_clear_RX(); - gRequestSaveChannel = 1; - return; -#endif case MENU_D_LIVE_DEC: gSetting_live_DTMF_decoder = gSubMenuSelection; @@ -711,18 +677,6 @@ void MENU_AcceptSetting(void) { gUpdateStatus = true; break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_LIST: - gDTMF_chosen_contact = gSubMenuSelection - 1; - if (gIsDtmfContactValid) { - GUI_SelectNextDisplay(DISPLAY_MAIN); - gDTMF_InputMode = true; - gDTMF_InputBox_Index = 3; - memcpy(gDTMF_InputBox, gDTMF_ID, 4); - gRequestDisplayScreen = DISPLAY_INVALID; - } - return; -#endif case MENU_FSKMOD: gEeprom.FSKMode = gSubMenuSelection; break; @@ -1074,15 +1028,6 @@ void MENU_ShowCurrentSetting(void) { gSubMenuSelection = gEeprom.DTMF_SIDE_TONE; break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_RSP: - gSubMenuSelection = gEeprom.DTMF_DECODE_RESPONSE; - break; - - case MENU_D_HOLD: - gSubMenuSelection = gEeprom.DTMF_auto_reset_time; - break; -#endif case MENU_D_PRE: gSubMenuSelection = gEeprom.DTMF_PRELOAD_TIME / 10; break; @@ -1095,15 +1040,6 @@ void MENU_ShowCurrentSetting(void) { gSubMenuSelection = gSetting_battery_text; return; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_DCD: - gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE; - break; - - case MENU_D_LIST: - gSubMenuSelection = gDTMF_chosen_contact + 1; - break; -#endif case MENU_D_LIVE_DEC: gSubMenuSelection = gSetting_live_DTMF_decoder; break; @@ -1452,9 +1388,6 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) { #endif if (UI_MENU_GetCurrentMenuId() == MENU_UPCODE || UI_MENU_GetCurrentMenuId() == MENU_DWCODE - #ifdef ENABLE_DTMF_CALLING - || UI_MENU_GetCurrentMenuId() == MENU_ANI_ID -#endif ) return; #if 1 diff --git a/app/messages.c b/app/messages.c index efd6c93..73fc943 100644 --- a/app/messages.c +++ b/app/messages.c @@ -24,6 +24,7 @@ const char T9Table[10][T9Count] = { uint8_t gActiveMessage = 0; +uint8_t gActiveMessageBank = 0; StoredPacket loadedPacket; @@ -82,30 +83,41 @@ void MESSAGES_TimeSlice500ms(void) { void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { gKeyTimeout = 1; - if (gEnteringSMS != SMS_NOT_ENTERING && !bKeyHeld && Key <= KEY_9) { - if (!dataPTR || dataPTR < dataPacket.data) { - dataPTR = dataPacket.data; + if (gEnteringSMS != SMS_NOT_ENTERING && Key <= KEY_9) { + if (!bKeyHeld) { + if (!dataPTR || dataPTR < dataPacket.data) { + dataPTR = dataPacket.data; + } } if (gEnteringSMS == SMS_ENTERING_MESSAGE) { if (bKeyPressed) { if (prevKey != Key) { dataPTR++; - if (dataPTR - dataPacket.data >= DataPacketDataSize) { + //if (dataPTR - dataPacket.data >= DataPacketDataSize) { + if (dataPTR - dataPacket.data >= 19) { dataPTR = dataPacket.data; } prevLetter = 0; } - *(dataPTR - 1) = T9Table[Key][(prevLetter++) % T9Count]; + *(dataPTR - 1) = T9Table[Key][prevLetter]; + if (!bKeyHeld) { + prevLetter++; + } else { + prevLetter--; + } + prevLetter = (prevLetter) % T9Count; updatePrevChar(Key); } return; } else if (gEnteringSMS == SMS_ENTERING_DEST) { - if (bKeyPressed) { - dataPacket.dest *= 10; - dataPacket.dest += Key; - prevLetter = 0; + if (!bKeyHeld) { + if (bKeyPressed) { + dataPacket.dest *= 10; + dataPacket.dest += Key; + prevLetter = 0; + } + return; } - return; } } @@ -143,8 +155,7 @@ void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { // second copy with MSB flipped (btn ^ 0x8) in the high nibble out[4] = ((btn ^ 0x8) << 4); - } - else { + } else { out[0] = (dataPacket.dest >> 8) & 0xFF; out[1] = dataPacket.dest & 0xFF; } @@ -210,21 +221,43 @@ void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { } break; case KEY_UP: - if (bKeyPressed) { - gActiveMessage++; - if (gActiveMessage > MESSAGES_COUNT) { - gActiveMessage = 0; + if (gEnteringSMS != SMS_NOT_ENTERING) { + if (bKeyPressed) { + gActiveMessageBank++; + gActiveMessage = gActiveMessageBank * 3; + if (gActiveMessage > MESSAGES_COUNT) { + gActiveMessage = 0; + } + if (gActiveMessageBank >= MESSAGES_COUNT / 3) { + gActiveMessageBank = 0; + } + MESSAGES_GET(); + } + } else if (gEnteringSMS == SMS_ENTERING_MESSAGE) { + dataPTR++; + //if (dataPTR - dataPacket.data >= DataPacketDataSize) { + if (dataPTR - dataPacket.data >= 19) { + dataPTR = dataPacket.data; } - MESSAGES_GET(); } break; case KEY_DOWN: - if (bKeyPressed) { - gActiveMessage--; - if (gActiveMessage > MESSAGES_COUNT) { - gActiveMessage = MESSAGES_COUNT - 1; + if (gEnteringSMS != SMS_NOT_ENTERING) { + if (bKeyPressed) { + gActiveMessageBank--; + gActiveMessage = gActiveMessageBank * 3; + if (gActiveMessage >= MESSAGES_COUNT) { + gActiveMessage = MESSAGES_COUNT - 1; + } + if (gActiveMessageBank > MESSAGES_COUNT / 3) { + gActiveMessageBank = MESSAGES_COUNT / 3 - 1; + } + MESSAGES_GET(); + } + } else if (gEnteringSMS == SMS_ENTERING_MESSAGE) { + if (dataPacket.data < dataPTR) { + dataPTR--; } - MESSAGES_GET(); } break; case KEY_EXIT: diff --git a/app/messages.h b/app/messages.h index 6f56158..00a685f 100644 --- a/app/messages.h +++ b/app/messages.h @@ -8,8 +8,8 @@ #include "../driver/keyboard.h" #include "../driver/eeprom.h" -#define MESSAGES_START (0x1D08) -#define MESSAGES_COUNT (6) +#define MESSAGES_START (0x1C08) +#define MESSAGES_COUNT (12) typedef struct { uint32_t src; @@ -20,6 +20,7 @@ typedef struct { } StoredPacket; extern uint8_t gActiveMessage; +extern uint8_t gActiveMessageBank; extern StoredPacket loadedPacket; diff --git a/app/scanner.c b/app/scanner.c index f7a0b7b..95aeb06 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -347,9 +347,6 @@ void SCANNER_Start(bool singleFreq) gUpdateStatus = true; } -#ifdef ENABLE_DTMF_CALLING - DTMF_clear_RX(); -#endif gScanDelay_10ms = scan_delay_10ms; gScanCssResultCode = 0xFF; diff --git a/app/uart.c b/app/uart.c index 87aba88..75a7f06 100644 --- a/app/uart.c +++ b/app/uart.c @@ -418,9 +418,6 @@ static void CMD_052F(const uint8_t *pBuffer) gEeprom.VfoInfo[0].pTX = &gEeprom.VfoInfo[0].freq_config_TX; gEeprom.VfoInfo[0].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF; gEeprom.VfoInfo[0].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF; -#ifdef ENABLE_DTMF_CALLING - gEeprom.VfoInfo[0].DTMF_DECODING_ENABLE = false; -#endif #ifdef ENABLE_NOAA gIsNoaaMode = false; diff --git a/audio.c b/audio.c index 8392c08..d767d2b 100644 --- a/audio.c +++ b/audio.c @@ -40,10 +40,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) if (Beep != BEEP_880HZ_60MS_DOUBLE_BEEP && Beep != BEEP_500HZ_60MS_DOUBLE_BEEP && Beep != BEEP_440HZ_500MS && -#ifdef ENABLE_DTMF_CALLING - Beep != BEEP_880HZ_200MS && - Beep != BEEP_880HZ_500MS && -#endif + #ifdef ENABLE_FEAT_F4HWN Beep != BEEP_400HZ_30MS && Beep != BEEP_500HZ_30MS && diff --git a/audio.h b/audio.h index 26ed0b6..cf9730e 100644 --- a/audio.h +++ b/audio.h @@ -29,10 +29,6 @@ enum BEEP_Type_t BEEP_1KHZ_60MS_OPTIONAL, BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL, BEEP_440HZ_500MS, -#ifdef ENABLE_DTMF_CALLING - BEEP_880HZ_200MS, - BEEP_880HZ_500MS, -#endif BEEP_500HZ_60MS_DOUBLE_BEEP, #ifdef ENABLE_FEAT_F4HWN BEEP_400HZ_30MS, diff --git a/functions.c b/functions.c index 7e75a2e..cd5ad11 100644 --- a/functions.c +++ b/functions.c @@ -80,9 +80,6 @@ void FUNCTION_Init(void) { g_VOX_Lost = false; #endif -#ifdef ENABLE_DTMF_CALLING - DTMF_clear_RX(); -#endif #ifdef ENABLE_NOAA gNOAACountdown_10ms = 0; @@ -96,10 +93,6 @@ void FUNCTION_Init(void) { } void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction) { -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_ReplyState != DTMF_REPLY_NONE) - RADIO_PrepareCssTX(); -#endif if (PreviousFunction == FUNCTION_TRANSMIT) { ST7565_FixInterfGlitch(); @@ -114,13 +107,6 @@ void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction) { gFM_RestoreCountdown_10ms = fm_restore_countdown_10ms; #endif -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || - gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || - gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) { - gDTMF_auto_reset_time_500ms = gEeprom.DTMF_auto_reset_time * 2; - } -#endif gUpdateStatus = true; } @@ -158,10 +144,6 @@ void FUNCTION_Transmit() { BK4819_DisableDTMF(); -#ifdef ENABLE_DTMF_CALLING - // clear the DTMF RX buffer - DTMF_clear_RX(); -#endif // clear the DTMF RX live decoder buffer gDTMF_RX_live_timeout = 0; diff --git a/misc.c b/misc.c index 999714a..b2c5b00 100644 --- a/misc.c +++ b/misc.c @@ -30,11 +30,6 @@ const uint8_t menu_timeout_500ms = 20000 / 500; // 20 second const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes const uint8_t DTMF_RX_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen -#ifdef ENABLE_DTMF_CALLING -const uint8_t DTMF_RX_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver -const uint8_t DTMF_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for -const uint8_t DTMF_txstop_countdown_500ms = 3000 / 500; // 6 seconds -#endif const uint8_t key_input_timeout_500ms = 8000 / 500; // 8 seconds diff --git a/misc.h b/misc.h index 661153b..59e0160 100644 --- a/misc.h +++ b/misc.h @@ -90,11 +90,6 @@ extern const uint8_t menu_timeout_500ms; extern const uint16_t menu_timeout_long_500ms; extern const uint8_t DTMF_RX_live_timeout_500ms; -#ifdef ENABLE_DTMF_CALLING -extern const uint8_t DTMF_RX_timeout_500ms; -extern const uint8_t DTMF_decode_ring_countdown_500ms; -extern const uint8_t DTMF_txstop_countdown_500ms; -#endif extern const uint8_t key_input_timeout_500ms; diff --git a/radio.c b/radio.c index 60089b6..805ef02 100644 --- a/radio.c +++ b/radio.c @@ -315,14 +315,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure } if (data[5] == 0xFF) { -#ifdef ENABLE_DTMF_CALLING - pVfo->DTMF_DECODING_ENABLE = false; -#endif pVfo->DTMF_PTT_ID_TX_MODE = PTT_ID_OFF; } else { -#ifdef ENABLE_DTMF_CALLING - pVfo->DTMF_DECODING_ENABLE = ((data[5] >> 0) & 1u) ? true : false; -#endif uint8_t pttId = ((data[5] >> 1) & 7u); pVfo->DTMF_PTT_ID_TX_MODE = pttId < ARRAY_SIZE(gSubMenu_PTT_ID) ? pttId : PTT_ID_OFF; } @@ -991,28 +985,12 @@ void RADIO_PrepareTX(void) { gAlarmState = ALARM_STATE_OFF; #endif -#ifdef ENABLE_DTMF_CALLING - gDTMF_ReplyState = DTMF_REPLY_NONE; -#endif AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); return; } // TX is allowed -#ifdef ENABLE_DTMF_CALLING - if (gDTMF_ReplyState == DTMF_REPLY_ANI) - { - gDTMF_IsTx = gDTMF_CallMode == DTMF_CALL_MODE_DTMF; - - if (gDTMF_IsTx) { - gDTMF_CallState = DTMF_CALL_STATE_NONE; - gDTMF_TxStopCountdown_500ms = DTMF_txstop_countdown_500ms; - } else { - gDTMF_CallState = DTMF_CALL_STATE_CALL_OUT; - } - } -#endif FUNCTION_Select(FUNCTION_TRANSMIT); @@ -1039,9 +1017,6 @@ void RADIO_PrepareTX(void) { gFlagEndTransmission = false; gRTTECountdown_10ms = 0; -#ifdef ENABLE_DTMF_CALLING - gDTMF_ReplyState = DTMF_REPLY_NONE; -#endif } void RADIO_SendCssTail(void) { diff --git a/radio.h b/radio.h index 7fcf489..29a12cf 100644 --- a/radio.h +++ b/radio.h @@ -116,9 +116,6 @@ typedef struct VFO_Info_t { uint8_t SCANLIST3_PARTICIPATION; uint8_t Band; -#ifdef ENABLE_DTMF_CALLING - uint8_t DTMF_DECODING_ENABLE; -#endif PTT_ID_t DTMF_PTT_ID_TX_MODE; uint8_t BUSY_CHANNEL_LOCK; diff --git a/settings.c b/settings.c index 2ef9f40..1790b03 100644 --- a/settings.c +++ b/settings.c @@ -173,12 +173,6 @@ void SETTINGS_InitEEPROM(void) { EEPROM_ReadBuffer(0x0ED0, Data, 8); gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true; -#ifdef ENABLE_DTMF_CALLING - gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*'; - gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#'; - gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0; - gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 5) ? Data[4] : 10; -#endif gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300; gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100; gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100; @@ -187,35 +181,6 @@ void SETTINGS_InitEEPROM(void) { EEPROM_ReadBuffer(0x0ED8, Data, 8); gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 100; gEeprom.DTMF_CODE_INTERVAL_TIME = (Data[1] < 101) ? Data[1] * 10 : 100; -#ifdef ENABLE_DTMF_CALLING - gEeprom.PERMIT_REMOTE_KILL = (Data[2] < 2) ? Data[2] : true; - - // 0EE0..0EE7 - - EEPROM_ReadBuffer(0x0EE0, Data, sizeof(gEeprom.ANI_DTMF_ID)); - if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.ANI_DTMF_ID))) { - memcpy(gEeprom.ANI_DTMF_ID, Data, sizeof(gEeprom.ANI_DTMF_ID)); - } else { - strcpy(gEeprom.ANI_DTMF_ID, "123"); - } - - - // 0EE8..0EEF - EEPROM_ReadBuffer(0x0EE8, Data, sizeof(gEeprom.KILL_CODE)); - if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.KILL_CODE))) { - memcpy(gEeprom.KILL_CODE, Data, sizeof(gEeprom.KILL_CODE)); - } else { - strcpy(gEeprom.KILL_CODE, "ABCD9"); - } - - // 0EF0..0EF7 - EEPROM_ReadBuffer(0x0EF0, Data, sizeof(gEeprom.REVIVE_CODE)); - if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.REVIVE_CODE))) { - memcpy(gEeprom.REVIVE_CODE, Data, sizeof(gEeprom.REVIVE_CODE)); - } else { - strcpy(gEeprom.REVIVE_CODE, "9DCBA"); - } -#endif // 0EF8..0F07 EEPROM_ReadBuffer(0x0EF8, Data, sizeof(gEeprom.DTMF_UP_CODE)); @@ -461,8 +426,6 @@ void SETTINGS_FactoryReset(bool bIsAll) { if ( !(i >= 0x0EE0 && i < 0x0F18) && // ANI ID + DTMF codes !(i >= 0x0F30 && i < 0x0F50) && // AES KEY + F LOCK + Scramble Enable - !(i >= 0x1C00 && i < 0x1E00) && // DTMF contacts - !(i >= 0x0EB0 && i < 0x0ED0) && // Welcome strings !(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt (bIsAll || ( @@ -644,12 +607,6 @@ void SETTINGS_SaveSettings(void) { EEPROM_WriteBuffer(0x0EA8, State); State[0] = gEeprom.DTMF_SIDE_TONE; -#ifdef ENABLE_DTMF_CALLING - State[1] = gEeprom.DTMF_SEPARATE_CODE; - State[2] = gEeprom.DTMF_GROUP_CALL_CODE; - State[3] = gEeprom.DTMF_DECODE_RESPONSE; - State[4] = gEeprom.DTMF_auto_reset_time; -#endif State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U; State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U; State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U; @@ -658,9 +615,6 @@ void SETTINGS_SaveSettings(void) { memset(State, 0xFF, sizeof(State)); State[0] = gEeprom.DTMF_CODE_PERSIST_TIME / 10U; State[1] = gEeprom.DTMF_CODE_INTERVAL_TIME / 10U; -#ifdef ENABLE_DTMF_CALLING - State[2] = gEeprom.PERMIT_REMOTE_KILL; -#endif EEPROM_WriteBuffer(0x0ED8, State); State[0] = gEeprom.SCAN_LIST_DEFAULT; @@ -754,6 +708,8 @@ void SETTINGS_SaveSettings(void) { EEPROM_WriteBuffer(0x1FF0, State); #endif + MSG_EnableRX(true); + #ifdef ENABLE_FEAT_F4HWN_VOL SETTINGS_WriteCurrentVol(); #endif @@ -793,9 +749,6 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, | (pVFO->CHANNEL_BANDWIDTH << 1) | (pVFO->FrequencyReverse << 0); State._8[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1) -#ifdef ENABLE_DTMF_CALLING - | ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0) -#endif ; State._8[6] = pVFO->STEP_SETTING; EEPROM_WriteBuffer(OffsetVFO + sizeof (State._32), State._8); @@ -913,9 +866,6 @@ void SETTINGS_WriteBuildOptions(void) { #endif #ifdef ENABLE_PWRON_PASSWORD | (1 << 6) -#endif -#ifdef ENABLE_DTMF_CALLING - | (1 << 7) #endif ; diff --git a/settings.h b/settings.h index c546abb..5b4a06c 100644 --- a/settings.h +++ b/settings.h @@ -31,9 +31,10 @@ typedef enum ModemModulation { MOD_FSK_450, // for bad conditions MOD_FSK_700, // for medium conditions + MOD_FSK_1200, + MOD_FSK_2400, MOD_AFSK_1200, // for good conditions MOD_AFSK_2400, - MOD_FSK_1200_2400, MOD_NOAA_SAME } ModemModulation; @@ -261,11 +262,6 @@ typedef struct { uint8_t MIC_SENSITIVITY; uint8_t MIC_SENSITIVITY_TUNING; uint8_t CHAN_1_CALL; -#ifdef ENABLE_DTMF_CALLING - char ANI_DTMF_ID[8]; - char KILL_CODE[8]; - char REVIVE_CODE[8]; -#endif char DTMF_UP_CODE[16]; uint8_t field57_0x6c; @@ -276,21 +272,12 @@ typedef struct { uint8_t field60_0x7e; uint8_t field61_0x7f; -#ifdef ENABLE_DTMF_CALLING - char DTMF_SEPARATE_CODE; - char DTMF_GROUP_CALL_CODE; - uint8_t DTMF_DECODE_RESPONSE; - uint8_t DTMF_auto_reset_time; -#endif uint16_t DTMF_PRELOAD_TIME; uint16_t DTMF_FIRST_CODE_PERSIST_TIME; uint16_t DTMF_HASH_CODE_PERSIST_TIME; uint16_t DTMF_CODE_PERSIST_TIME; uint16_t DTMF_CODE_INTERVAL_TIME; bool DTMF_SIDE_TONE; -#ifdef ENABLE_DTMF_CALLING - bool PERMIT_REMOTE_KILL; -#endif int16_t BK4819_XTAL_FREQ_LOW; #ifdef ENABLE_NOAA bool NOAA_AUTO_SCAN; diff --git a/ui/main.c b/ui/main.c index 831f151..df6f163 100644 --- a/ui/main.c +++ b/ui/main.c @@ -167,9 +167,7 @@ void UI_DisplayAudioBar(void) { if (gCurrentFunction != FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE -#endif + ) { return; // screen is in use } @@ -269,9 +267,6 @@ void DisplayRSSIBar(const bool now) { if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE -#endif ) return; // display is in use @@ -433,6 +428,7 @@ void UI_DisplayMain(void) { // clear the screen UI_DisplayClear(); + if (gLowBattery && !gLowBatteryConfirmed) { UI_DisplayPopup("LOW BAT"); ST7565_BlitFullScreen(); @@ -550,41 +546,9 @@ void UI_DisplayMain(void) { #endif if (gDTMF_InputMode -#ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx -#endif ) { char *pPrintStr = ""; // show DTMF stuff -#ifdef ENABLE_DTMF_CALLING - char Contact[16]; - if (!gDTMF_InputMode) { - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) { - pPrintStr = DTMF_FindContact(gDTMF_String, Contact) ? Contact : gDTMF_String; - } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || - gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) { - pPrintStr = DTMF_FindContact(gDTMF_Callee, Contact) ? Contact : gDTMF_Callee; - } else if (gDTMF_IsTx) { - pPrintStr = gDTMF_String; - } - } - - UI_PrintString(pPrintStr, 2, 0, 2 + (vfo_num * 3) /*, 8 */); - - pPrintStr = ""; - if (!gDTMF_InputMode) { - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) { - pPrintStr = (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT"; - } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || - gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) { - sprintf(String, "CALL FRM:%s", - (DTMF_FindContact(gDTMF_Caller, Contact)) ? Contact : gDTMF_Caller); - pPrintStr = String; - } else if (gDTMF_IsTx) { - pPrintStr = (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX"; - } - } else -#endif { sprintf(String, ">%s", gDTMF_InputBox); pPrintStr = String; @@ -1032,11 +996,6 @@ void UI_DisplayMain(void) { UI_PrintStringSmallNormal("N", LCD_WIDTH + 70, 0, line + 1); #endif -#ifdef ENABLE_DTMF_CALLING - // show the DTMF decoding symbol - if (vfoInfo->DTMF_DECODING_ENABLE) - UI_PrintStringSmallNormal("DTMF", LCD_WIDTH + 78, 0, line + 1); -#endif // show the audio scramble symbol if (vfoInfo->SCRAMBLING_TYPE > 0) { @@ -1077,9 +1036,6 @@ void UI_DisplayMain(void) { if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].Modulation == MODULATION_AM && gSetting_AM_fix) { if (gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE -#endif ) return; @@ -1103,9 +1059,6 @@ void UI_DisplayMain(void) { const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars if (gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE -#endif ) return; @@ -1144,9 +1097,6 @@ void UI_DisplayMain(void) { else if (gChargingWithTypeC) { // charging .. show the battery state if (gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE -#endif ) return; diff --git a/ui/menu.c b/ui/menu.c index 554eb05..39660c1 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -101,23 +101,13 @@ const t_menu_item MenuList[] = {"1 Call", MENU_1_CALL}, #ifdef ENABLE_ALARM {"AlarmT", MENU_AL_MOD}, -#endif -#ifdef ENABLE_DTMF_CALLING - {"ANI ID", MENU_ANI_ID }, #endif {"UPCode", MENU_UPCODE}, {"DNCode", MENU_DWCODE}, {"PTT ID", MENU_PTT_ID}, {"L DTMF", MENU_D_ST}, -#ifdef ENABLE_DTMF_CALLING - {"D Resp", MENU_D_RSP }, - {"D Hold", MENU_D_HOLD }, -#endif {"D Prel", MENU_D_PRE}, -#ifdef ENABLE_DTMF_CALLING - {"D Decd", MENU_D_DCD }, - {"D List", MENU_D_LIST }, -#endif + {"D Live", MENU_D_LIVE_DEC}, // live DTMF decoder #ifndef ENABLE_FEAT_F4HWN #ifdef ENABLE_AM_FIX @@ -225,16 +215,6 @@ const char gSubMenu_AL_MOD[][5] = }; #endif -#ifdef ENABLE_DTMF_CALLING -const char gSubMenu_D_RSP[][11] = -{ - "DO\nNOTHING", - "RING", - "REPLY", - "BOTH" -}; -#endif - const char *const gSubMenu_PTT_ID[] = { "OFF", @@ -244,13 +224,14 @@ const char *const gSubMenu_PTT_ID[] = "APOLLO" }; -const char gSubMenu_FSKMod[][8] = +const char gSubMenu_FSKMod[][6] = { "450", "700", + "1200", + "2400", "A1200", "A2400", - "2400", "NOAA" }; @@ -394,9 +375,6 @@ void UI_DisplayMenu(void) { unsigned int i; char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char) -#ifdef ENABLE_DTMF_CALLING - char Contact[16]; -#endif UI_DisplayClear(); @@ -657,9 +635,6 @@ UI_PrintStringSmallNormal(String, 2, 0, 6); case MENU_S_ADD3: case MENU_STE: case MENU_D_ST: -#ifdef ENABLE_DTMF_CALLING - case MENU_D_DCD: -#endif case MENU_D_LIVE_DEC: #ifdef ENABLE_NOAA case MENU_NOAA_S: @@ -781,11 +756,6 @@ UI_PrintStringSmallNormal(String, 2, 0, 6); break; #endif -#ifdef ENABLE_DTMF_CALLING - case MENU_ANI_ID: - strcpy(String, gEeprom.ANI_DTMF_ID); - break; -#endif case MENU_UPCODE: sprintf(String, "%.8s\n%.8s", gEeprom.DTMF_UP_CODE, gEeprom.DTMF_UP_CODE + 8); break; @@ -794,15 +764,6 @@ UI_PrintStringSmallNormal(String, 2, 0, 6); sprintf(String, "%.8s\n%.8s", gEeprom.DTMF_DOWN_CODE, gEeprom.DTMF_DOWN_CODE + 8); break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_RSP: - strcpy(String, gSubMenu_D_RSP[gSubMenuSelection]); - break; - - case MENU_D_HOLD: - sprintf(String, "%lds", gSubMenuSelection); - break; -#endif case MENU_D_PRE: sprintf(String, "%ld*10ms", gSubMenuSelection); break; @@ -815,15 +776,6 @@ UI_PrintStringSmallNormal(String, 2, 0, 6); strcpy(String, gSubMenu_BAT_TXT[gSubMenuSelection]); break; -#ifdef ENABLE_DTMF_CALLING - case MENU_D_LIST: - gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact); - if (!gIsDtmfContactValid) - strcpy(String, "NULL"); - else - memcpy(String, Contact, 8); - break; -#endif case MENU_FSKMOD: strcpy(String, gSubMenu_FSKMod[gSubMenuSelection]); @@ -1030,22 +982,11 @@ UI_PrintStringSmallNormal(String, 2, 0, 6); if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && gCssBackgroundScan) UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4 /*, 8 */); -#ifdef ENABLE_DTMF_CALLING - if (UI_MENU_GetCurrentMenuId() == MENU_D_LIST && gIsDtmfContactValid) { - Contact[11] = 0; - memcpy(&gDTMF_ID, Contact + 8, 4); - sprintf(String, "ID:%4s", gDTMF_ID); - UI_PrintString(String, menu_item_x1, menu_item_x2, 4 /*, 8 */); - } -#endif if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_T_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS || UI_MENU_GetCurrentMenuId() == MENU_T_DCS -#ifdef ENABLE_DTMF_CALLING - || UI_MENU_GetCurrentMenuId() == MENU_D_LIST -#endif ) { sprintf(String, "%2ld", gSubMenuSelection); UI_PrintStringSmallNormal(String, 105, 0, 0); diff --git a/ui/menu.h b/ui/menu.h index c65fa0e..84c4c8e 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -74,23 +74,12 @@ enum { MENU_SLIST3, #ifdef ENABLE_ALARM MENU_AL_MOD, -#endif -#ifdef ENABLE_DTMF_CALLING - MENU_ANI_ID, #endif MENU_UPCODE, MENU_DWCODE, MENU_PTT_ID, MENU_D_ST, -#ifdef ENABLE_DTMF_CALLING - MENU_D_RSP, - MENU_D_HOLD, -#endif MENU_D_PRE, -#ifdef ENABLE_DTMF_CALLING - MENU_D_DCD, - MENU_D_LIST, -#endif MENU_D_LIVE_DEC, MENU_FSKSRC, MENU_FSKMOD, @@ -149,16 +138,13 @@ extern const char *const gSubMenu_MDF[4]; #ifdef ENABLE_ALARM extern const char gSubMenu_AL_MOD[2][5]; #endif -#ifdef ENABLE_DTMF_CALLING -extern const char gSubMenu_D_RSP[4][11]; -#endif #ifdef ENABLE_FEAT_F4HWN extern const char gSubMenu_SET_PTT[2][4]; #endif extern const char *const gSubMenu_PTT_ID[5]; -extern const char gSubMenu_FSKMod[6][8]; +extern const char gSubMenu_FSKMod[7][6]; extern const char gSubMenu_ROGER[3][6]; extern const char gSubMenu_RESET[2][4]; extern const char *const gSubMenu_F_LOCK[F_LOCK_LEN]; diff --git a/ui/messages.c b/ui/messages.c index 796d97d..a3eb6cd 100644 --- a/ui/messages.c +++ b/ui/messages.c @@ -38,84 +38,47 @@ void UI_DisplayMessages(void) { 6); } } else { + uint8_t Data[8]; + EEPROM_ReadBuffer(SEQParameterEEPROM, Data, 8); + uint8_t msgIndex = Data[1]; // index of latest written message + // Determine oldest message index (next to be overwritten) + uint8_t startIndex = (msgIndex + 1) % MESSAGES_COUNT; - String[0] = 'M'; - String[1] = 'S'; - String[2] = 'G'; - String[3] = ' '; + // Each bank shows 3 messages + uint8_t messagesPerPage = 3; - for (size_t i = 8; i < 14; i++) { - String[i] = ' '; + // Compute offset for scrolling (0 = newest, higher = older) + uint8_t pageOffset = gActiveMessageBank * messagesPerPage; + + for (uint8_t ixa = 0; ixa < messagesPerPage; ixa++) { + // Logical order from oldest to newest + uint8_t logicalIndex = (startIndex + pageOffset + ixa) % MESSAGES_COUNT; + + // If out of stored range, stop + if (pageOffset + ixa >= MESSAGES_COUNT) + break; + + gActiveMessage = logicalIndex; + MESSAGES_GET(); + + // Build the display string + u32_to_str(gActiveMessage == MESSAGES_COUNT ? dataPacket.dest : loadedPacket.src, &String[0]); + String[10] = '-'; + u8_to_str(loadedPacket.seq, &String[11]); + String[14] = '-'; + + // Display a visual index (0,1,2,3... not EEPROM slot) + uint8_t visualIndex = ixa + (gActiveMessageBank * 3); + String[15] = (visualIndex < 10) ? ('0' + visualIndex) : ('A' + visualIndex - 10); + String[16] = '-'; + String[17] = (gActiveMessage < 10) ? ('0' + gActiveMessage) : ('A' + gActiveMessage - 10); + String[18] = 0; + + // Print both metadata and message + UI_PrintString(String, 2, 0, ixa * 2); + UI_PrintString((const char *) loadedPacket.data, 2, 0, ixa * 2 + 1); } - - String[4] = 'F'; - String[5] = 'l'; - String[6] = 'g'; - String[7] = 's'; - String[8] = ':'; - String[9] = ' '; - u8_to_str(loadedPacket.flags, &String[10]); // Write at offset 7 - - String[13] = ' '; - if (gActiveMessage == MESSAGES_COUNT) { - String[14] = 'T'; - } else { - String[14] = '0' + gActiveMessage; - } - String[15] = '/'; - String[16] = '0' + MESSAGES_COUNT; - String[17] = 0; - - UI_PrintString(String, 2, 0, 0 /*, 8 */); - - String[5] = ' '; - if (gActiveMessage == MESSAGES_COUNT) { - String[0] = 'T'; - String[1] = 'o'; - String[2] = ':'; - String[3] = ' '; - String[4] = ' '; - } else { - String[0] = 'F'; - String[1] = 'r'; - String[2] = 'o'; - String[3] = 'm'; - String[4] = ':'; - } - u32_to_str(gActiveMessage == MESSAGES_COUNT ? dataPacket.dest : loadedPacket.src, - &String[6]); // Write at offset 6 - UI_PrintString(String, 2, 0, 1 /*, 8 */); - - String[0] = 'S'; - String[1] = 'E'; - String[2] = 'Q'; - String[3] = ':'; - String[4] = ' '; - u8_to_str(loadedPacket.seq, &String[5]); // Write at offset 5 - String[8] = ' '; - String[9] = 'T'; - String[10] = 'T'; - String[11] = 'L'; - String[12] = ':'; - String[13] = ' '; - String[14] = 0; - u8_to_str(loadedPacket.ttl, &String[14]); // Write at new offset - UI_PrintString(String, 2, 0, 2 /*, 8 */); - - - char String2[13] = "Data: "; - if (gGotACK) { - String2[6] = 'G'; - String2[7] = 'o'; - String2[8] = 't'; - String2[9] = 'A'; - String2[10] = 'C'; - String2[11] = 'K'; - } - String2[12] = 0; - UI_PrintString(String2, 0, 0, 3 /*, 8 */); - UI_PrintString((const char *) loadedPacket.data, 2, 0, 4 /*, 8 */); } ST7565_BlitFullScreen(); } \ No newline at end of file