From 21895ae3042248481e83aaa8e65f58feff5d3a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Sun, 10 Sep 2023 22:57:04 +0200 Subject: [PATCH] ttwrplus: disable Tx in menus As T-TWR Plus reuses the PTT as a back button, thus we need to disable PTT in menus. Also enforce rx_only logic from CPS. TG-553 --- openrtx/include/core/state.h | 1 + openrtx/src/core/cps.c | 1 + openrtx/src/core/state.c | 1 + openrtx/src/core/threads.c | 5 ++++- openrtx/src/ui/default/ui.c | 20 ++++++++++++++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/openrtx/include/core/state.h b/openrtx/include/core/state.h index 404c3b2c..871ed9b6 100644 --- a/openrtx/include/core/state.h +++ b/openrtx/include/core/state.h @@ -59,6 +59,7 @@ typedef struct bool backup_eflash; bool restore_eflash; char m17_dest[10]; + bool txDisable; } state_t; diff --git a/openrtx/src/core/cps.c b/openrtx/src/core/cps.c index d0f2124b..724fffaa 100644 --- a/openrtx/src/core/cps.c +++ b/openrtx/src/core/cps.c @@ -32,6 +32,7 @@ channel_t cps_getDefaultChannel() #endif channel.bandwidth = BW_25; channel.power = 100; // 1W, P = 10dBm + n*0.2dBm, we store n + channel.rx_only = false; // Enable tx by default // Set initial frequency based on supported bands const hwInfo_t* hwinfo = platform_getHwInfo(); diff --git a/openrtx/src/core/state.c b/openrtx/src/core/state.c index 37e2ca3c..99e90af0 100644 --- a/openrtx/src/core/state.c +++ b/openrtx/src/core/state.c @@ -71,6 +71,7 @@ void state_init() state.bank_enabled = false; state.rtxStatus = RTX_OFF; state.emergency = false; + state.txDisable = false; // Force brightness field to be in range 0 - 100 if(state.settings.brightness > 100) diff --git a/openrtx/src/core/threads.c b/openrtx/src/core/threads.c index f9e0b68e..349202ec 100644 --- a/openrtx/src/core/threads.c +++ b/openrtx/src/core/threads.c @@ -100,7 +100,10 @@ void *ui_threadFunc(void *arg) rtx_cfg.txToneEn = state.channel.fm.txToneEn; rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone]; - // Copy new M17 CAN, M17 CAN RX check,source and destination addresses + // Enable Tx if channel allows it and we are in UI main screen + rtx_cfg.txDisable = state.channel.rx_only || state.txDisable; + + // Copy new M17 CAN, source and destination addresses rtx_cfg.can = state.settings.m17_can; rtx_cfg.canRxEn = state.settings.m17_can_rx; strncpy(rtx_cfg.source_address, state.settings.callsign, 10); diff --git a/openrtx/src/ui/default/ui.c b/openrtx/src/ui/default/ui.c index 3f415620..cda5541b 100644 --- a/openrtx/src/ui/default/ui.c +++ b/openrtx/src/ui/default/ui.c @@ -1324,6 +1324,12 @@ void ui_updateFSM(bool *sync_rtx) { // VFO screen case MAIN_VFO: + // Enable Tx in MAIN_VFO mode + if (state.txDisable) + { + state.txDisable = false; + *sync_rtx = true; + } // M17 Destination callsign input if(ui_state.edit_mode) { @@ -1494,6 +1500,12 @@ void ui_updateFSM(bool *sync_rtx) break; // MEM screen case MAIN_MEM: + // Enable Tx in MAIN_MEM mode + if (state.txDisable) + { + state.txDisable = false; + *sync_rtx = true; + } // M17 Destination callsign input if(ui_state.edit_mode) { @@ -2141,6 +2153,14 @@ void ui_updateFSM(bool *sync_rtx) } break; } + + // Enable Tx only if in MAIN_VFO or MAIN_MEM states + bool inMemOrVfo = (state.ui_screen == MAIN_VFO) || (state.ui_screen == MAIN_MEM); + if ((macro_menu == true) || ((inMemOrVfo == false) && (state.txDisable == false))) + { + state.txDisable = true; + *sync_rtx = true; + } if (!f1Handled && (msg.keys & KEY_F1) && (state.settings.vpLevel > vpBeep)) { vp_replayLastPrompt();