From d00c3a53069e0c69cc7db609f8eed15e0afade8d Mon Sep 17 00:00:00 2001 From: Jye <14170229+JyeSmith@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:59:27 +1000 Subject: [PATCH] Auto set True Diversity Rx into Diversity or Gemini mode based on Tx antenna mode (#2993) --- src/lib/LUA/rx_devLUA.cpp | 24 ------------------------ src/lib/OTA/OTA.h | 3 ++- src/src/rx_main.cpp | 5 +++++ src/src/tx_main.cpp | 3 ++- 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/lib/LUA/rx_devLUA.cpp b/src/lib/LUA/rx_devLUA.cpp index c6e0ee4b..d6eabc85 100644 --- a/src/lib/LUA/rx_devLUA.cpp +++ b/src/lib/LUA/rx_devLUA.cpp @@ -82,16 +82,6 @@ static struct luaItem_selection luaAntennaMode = { }; #endif -// Gemini Mode -#if defined(GPIO_PIN_NSS_2) -static struct luaItem_selection luaDiversityMode = { - {"Rx Mode", CRSF_TEXT_SELECTION}, - 0, // value - "Diversity;Gemini", - STR_EMPTYSPACE -}; -#endif - static struct luaItem_folder luaTeamraceFolder = { {"Team Race", CRSF_FOLDER}, }; @@ -552,14 +542,6 @@ static void registerLuaParameters() }); } - // Gemini Mode - if (isDualRadio()) - { - registerLUAParameter(&luaDiversityMode, [](struct luaPropertiesCommon* item, uint8_t arg){ - config.SetAntennaMode(arg); // Reusing SetAntennaMode since both GPIO_PIN_ANTENNA_SELECT and GPIO_PIN_NSS_2 will not be defined together. - }); - } - #if defined(POWER_OUTPUT_VALUES) luadevGeneratePowerOpts(&luaTlmPower); registerLUAParameter(&luaTlmPower, &luaparamSetPower); @@ -628,12 +610,6 @@ static int event() setLuaTextSelectionValue(&luaAntennaMode, config.GetAntennaMode()); } - // Gemini Mode - if (isDualRadio()) - { - setLuaTextSelectionValue(&luaDiversityMode, config.GetAntennaMode()); // Reusing SetAntennaMode since both GPIO_PIN_ANTENNA_SELECT and GPIO_PIN_NSS_2 will not be defined together. - } - #if defined(POWER_OUTPUT_VALUES) // The last item (for MatchTX) will be MaxPower - MinPower + 1 uint8_t luaPwrVal = (config.GetPower() == PWR_MATCH_TX) ? POWERMGNT::getMaxPower() + 1 : config.GetPower(); diff --git a/src/lib/OTA/OTA.h b/src/lib/OTA/OTA.h index 2d6f5109..8a62df84 100644 --- a/src/lib/OTA/OTA.h +++ b/src/lib/OTA/OTA.h @@ -29,7 +29,8 @@ typedef struct { uint8_t rfRateEnum; uint8_t switchEncMode:1, newTlmRatio:3, - free:4; + geminiMode:1, + free:3; uint8_t UID4; uint8_t UID5; } PACKED OTA_Sync_s; diff --git a/src/src/rx_main.cpp b/src/src/rx_main.cpp index 8cf9fd0b..13cef57e 100644 --- a/src/src/rx_main.cpp +++ b/src/src/rx_main.cpp @@ -1057,6 +1057,11 @@ static bool ICACHE_RAM_ATTR ProcessRfPacket_SYNC(uint32_t const now, OTA_Sync_s DBGW('s'); #endif + if (isDualRadio()) + { + config.SetAntennaMode(otaSync->geminiMode); + } + // Will change the packet air rate in loop() if this changes ExpressLRS_nextAirRateIndex = enumRatetoIndex((expresslrs_RFrates_e)otaSync->rfRateEnum); updateSwitchModePendingFromOta(otaSync->switchEncMode); diff --git a/src/src/tx_main.cpp b/src/src/tx_main.cpp index ac5c43c1..7563015a 100644 --- a/src/src/tx_main.cpp +++ b/src/src/tx_main.cpp @@ -304,8 +304,9 @@ void ICACHE_RAM_ATTR GenerateSyncPacketData(OTA_Sync_s * const syncPtr) syncPtr->fhssIndex = FHSSgetCurrIndex(); syncPtr->nonce = OtaNonce; syncPtr->rfRateEnum = get_elrs_airRateConfig(Index)->enum_rate; - syncPtr->newTlmRatio = newTlmRatio - TLM_RATIO_NO_TLM; syncPtr->switchEncMode = SwitchEncMode; + syncPtr->newTlmRatio = newTlmRatio - TLM_RATIO_NO_TLM; + syncPtr->geminiMode = isDualRadio() && config.GetAntennaMode() == TX_RADIO_MODE_GEMINI; syncPtr->UID4 = UID[4]; syncPtr->UID5 = UID[5]; -- 2.11.4.GIT