From 7928e5bc207e27bb38ddfdeec37b2e7fabaedc34 Mon Sep 17 00:00:00 2001 From: eshifri <46511024+eshifri@users.noreply.github.com> Date: Tue, 12 Oct 2021 22:45:52 -0700 Subject: [PATCH] [NV14] Add range check button and power level choice (#857) * add range and high power to MV14 * remove spaces * fix compilation * compilation fix 2 * Whitespace cleanup and placate git Co-authored-by: Peter Feerick --- radio/src/gui/colorlcd/model_setup.cpp | 23 +++++++++++++++++++++++ radio/src/pulses/flysky.cpp | 2 +- radio/src/pulses/modules_helpers.h | 24 +++++++++++++++++++++--- radio/src/translations.cpp | 4 ++++ radio/src/translations/untranslated.h | 4 ++++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 89ce81681..f01864ff5 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -1300,6 +1300,11 @@ class ModuleWindow : public FormGroup { return 0; } else { moduleState[moduleIdx].mode = MODULE_MODE_RANGECHECK; +#if defined(AFHDS2) + if (isModuleFlySky(moduleIdx)) { + resetPulsesAFHDS2(); + } +#endif auto rssiDialog = new DynamicMessageDialog( this, "Range Test", [=]() { @@ -1312,6 +1317,11 @@ class ModuleWindow : public FormGroup { rssiDialog->setCloseHandler([this]() { rangeButton->check(false); moduleState[moduleIdx].mode = MODULE_MODE_NORMAL; +#if defined(AFHDS2) + if (isModuleFlySky(moduleIdx)) { + resetPulsesAFHDS2(); + } +#endif }); return 1; } @@ -1322,6 +1332,19 @@ class ModuleWindow : public FormGroup { grid.nextLine(); } +#if defined(AFHDS2) && defined(PCBNV14) + if (isModuleAFHDS2A(moduleIdx) && getNV14RfFwVersion() >= 0x1000E) { + new StaticText(this, grid.getLabelSlot(true), STR_MULTI_RFPOWER); + new Choice(this, grid.getFieldSlot(), "\007""Default""High", 0, 1, + GET_DEFAULT(g_model.moduleData[moduleIdx].flysky.rfPower), + [=](int32_t newValue) -> void { + g_model.moduleData[moduleIdx].flysky.rfPower = newValue; + resetPulsesAFHDS2(); + }); + grid.nextLine(); + } +#endif + // Failsafe if (isModuleFailsafeAvailable(moduleIdx)) { hasFailsafe = true; diff --git a/radio/src/pulses/flysky.cpp b/radio/src/pulses/flysky.cpp index 64b2cfd41..4c4a7252b 100644 --- a/radio/src/pulses/flysky.cpp +++ b/radio/src/pulses/flysky.cpp @@ -113,7 +113,7 @@ static uint32_t rfRxCount = 0; static uint8_t lastState = STATE_IDLE; static uint32_t set_loop_cnt = 0; -uint32_t NV14internalModuleFwVersion; +uint32_t NV14internalModuleFwVersion = 0; static rf_info_t rf_info = { .bind_power = BIND_LOW_POWER, diff --git a/radio/src/pulses/modules_helpers.h b/radio/src/pulses/modules_helpers.h index fed3f1830..c34a104c9 100644 --- a/radio/src/pulses/modules_helpers.h +++ b/radio/src/pulses/modules_helpers.h @@ -32,6 +32,10 @@ #include "telemetry/multi.h" #endif +#if defined(PCBNV14) +extern uint32_t NV14internalModuleFwVersion; +#endif + #define CROSSFIRE_CHANNELS_COUNT 16 #define GHOST_CHANNELS_COUNT 16 @@ -612,11 +616,25 @@ inline bool isModuleBindRangeAvailable(uint8_t moduleIdx) isModuleFlySky(moduleIdx); } +inline uint32_t getNV14RfFwVersion() +{ +#if defined(PCBNV14) + return NV14internalModuleFwVersion; +#else + return 0; +#endif +} + inline bool isModuleRangeAvailable(uint8_t moduleIdx) { - return isModuleBindRangeAvailable(moduleIdx) - && !IS_RX_MULTI(moduleIdx) - && !isModuleFlySky(moduleIdx); + bool ret = isModuleBindRangeAvailable(moduleIdx) && !IS_RX_MULTI(moduleIdx); +#if defined(PCBNV14) + ret = ret && + (!isModuleFlySky(moduleIdx) || NV14internalModuleFwVersion >= 0x1000E); +#else + ret = ret && (!isModuleFlySky(moduleIdx)); +#endif + return ret; } constexpr uint8_t MAX_RXNUM = 63; diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 033623ae7..5ecc6660e 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -936,3 +936,7 @@ const char STR_ABOUTUS[] = TR_ABOUTUS; const char STR_AUTH_FAILURE[] = TR_AUTH_FAILURE; const char STR_PROTOCOL[] = TR_PROTOCOL; const char STR_RACING_MODE[] = TR_RACING_MODE; + +#if defined(PCBNV14) +const char STR_RFPOWER_AFHDS2[] = TR_RFPOWER_AFHDS2; +#endif diff --git a/radio/src/translations/untranslated.h b/radio/src/translations/untranslated.h index 81ed42773..65a399f96 100644 --- a/radio/src/translations/untranslated.h +++ b/radio/src/translations/untranslated.h @@ -190,6 +190,10 @@ #define LEN_PWR_OFF_DELAYS "\002" #define TR_PWR_OFF_DELAYS "0s""1s""2s""4s" +#if defined(PCBNV14) +#define TR_RFPOWER_AFHDS2 "\007" "Default\0""High\0" +#endif + #define TR_SENSOR_RSSI "RSSI" #define TR_SENSOR_R9PW "R9PW" #define TR_SENSOR_RAS "SWR"