diff --git a/openrtx/include/core/state.h b/openrtx/include/core/state.h index 871ed9b6..7767b552 100644 --- a/openrtx/include/core/state.h +++ b/openrtx/include/core/state.h @@ -50,6 +50,7 @@ typedef struct bool bank_enabled; uint16_t bank; uint8_t rtxStatus; + bool tone_enabled; bool emergency; settings_t settings; diff --git a/openrtx/include/rtx/rtx.h b/openrtx/include/rtx/rtx.h index 20ada43b..1bd8a943 100644 --- a/openrtx/include/rtx/rtx.h +++ b/openrtx/include/rtx/rtx.h @@ -52,6 +52,8 @@ typedef struct uint16_t txToneEn : 1, /**< TX CTC/DCS tone enable */ txTone : 15; /**< TX CTC/DCS tone */ + bool toneEn; + uint8_t can : 4, /**< M17 Channel Access Number */ canRxEn : 1, /**< M17 Check CAN on RX */ _unused : 3; diff --git a/openrtx/src/core/threads.c b/openrtx/src/core/threads.c index 2ea2c363..5c0931ab 100644 --- a/openrtx/src/core/threads.c +++ b/openrtx/src/core/threads.c @@ -98,6 +98,7 @@ void *ui_threadFunc(void *arg) rtx_cfg.rxTone = ctcss_tone[state.channel.fm.rxTone]; rtx_cfg.txToneEn = state.channel.fm.txToneEn; rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone]; + rtx_cfg.toneEn = state.tone_enabled; // Enable Tx if channel allows it and we are in UI main screen rtx_cfg.txDisable = state.channel.rx_only || state.txDisable; diff --git a/openrtx/src/ui/default/ui.c b/openrtx/src/ui/default/ui.c index cda5541b..5861f2d1 100644 --- a/openrtx/src/ui/default/ui.c +++ b/openrtx/src/ui/default/ui.c @@ -1319,6 +1319,12 @@ void ui_updateFSM(bool *sync_rtx) } #endif // PLA%FORM_TTWRPLUS + if(state.tone_enabled && !(msg.keys & KEY_HASH)) + { + state.tone_enabled = false; + *sync_rtx = true; + } + int priorUIScreen = state.ui_screen; switch(state.ui_screen) { @@ -1403,6 +1409,14 @@ void ui_updateFSM(bool *sync_rtx) vp_announceM17Info(NULL, ui_state.edit_mode, queueFlags); } + else + { + if(!state.tone_enabled) + { + state.tone_enabled = true; + *sync_rtx = true; + } + } } else if(msg.keys & KEY_UP || msg.keys & KNOB_RIGHT) { @@ -1585,6 +1599,14 @@ void ui_updateFSM(bool *sync_rtx) // Reset text input variables _ui_textInputReset(ui_state.new_callsign); } + else + { + if(!state.tone_enabled) + { + state.tone_enabled = true; + *sync_rtx = true; + } + } } else if(msg.keys & KEY_F1) { diff --git a/platform/drivers/baseband/AT1846S.h b/platform/drivers/baseband/AT1846S.h index d7dfcab0..8709457b 100644 --- a/platform/drivers/baseband/AT1846S.h +++ b/platform/drivers/baseband/AT1846S.h @@ -142,6 +142,25 @@ public: maskSetRegister(0x30, 0x0060, value); } + /** + * Setup and enable tone output + * @param freq frequency in 1/10 Hz + */ + void enableTone(const tone_t freq) + { + i2c_writeReg16(0x35, freq); // Set tone 1 freq + maskSetRegister(0x3A, 0x7000, 0x1000); // Use tone 1 + maskSetRegister(0x79, 0xF000, 0xC000); // Enable tone output + } + + /** + * Change output back to microphone + */ + void disableTone() + { + maskSetRegister(0x3A, 0x7000, 0x4000); // Use microphone + } + /** * Enable the CTCSS tone for transmission. * diff --git a/platform/drivers/baseband/radio_UV3x0.cpp b/platform/drivers/baseband/radio_UV3x0.cpp index 0d580ac6..f6302ea4 100644 --- a/platform/drivers/baseband/radio_UV3x0.cpp +++ b/platform/drivers/baseband/radio_UV3x0.cpp @@ -262,6 +262,11 @@ void radio_enableTx() at1846s.enableTxCtcss(config->txTone); } + if (config->toneEn) + { + at1846s.enableTone(17500); + } + radioStatus = TX; } @@ -279,6 +284,7 @@ void radio_disableRtx() C6000.stopAnalogTx(); } + at1846s.disableTone(); at1846s.disableCtcss(); at1846s.setFuncMode(AT1846S_FuncMode::OFF); radioStatus = OFF;