From 36cdd93a1aa55123f0c99040b777254a333f353f Mon Sep 17 00:00:00 2001 From: 3djc Date: Fri, 13 Dec 2024 03:41:38 +0100 Subject: [PATCH] feat: support for RadioMaster GX12 (#5703) Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: philmoz Co-authored-by: Peter Feerick --- .github/ISSUE_TEMPLATE/bug-report.yml | 1 + .github/workflows/actions.yml | 5 +- .github/workflows/nightly.yml | 3 +- companion/src/CMakeLists.txt | 2 + companion/src/firmwares/boards.cpp | 6 + companion/src/firmwares/boards.h | 7 + .../src/firmwares/opentx/opentxinterface.cpp | 7 + companion/src/simulation/simulatorwidget.cpp | 3 + fw.json | 3 +- radio/src/boards/generic_stm32/rgb_leds.cpp | 10 + radio/src/boards/generic_stm32/rgb_leds.h | 2 + radio/src/boards/generic_stm32/switches.cpp | 4 +- radio/src/cli.cpp | 245 +++-- radio/src/datastructs.h | 2 + radio/src/datastructs_private.h | 29 +- radio/src/edgetx.cpp | 2 - radio/src/gui/128x64/model_setup.cpp | 94 +- radio/src/gui/128x64/radio_diagkeys.cpp | 13 +- radio/src/gui/128x64/startup_shutdown.cpp | 19 +- .../gui/colorlcd/model/function_switches.cpp | 38 + .../colorlcd/radio/radio_diagcustswitches.cpp | 1 + radio/src/hal/CMakeLists.txt | 6 + radio/src/hal/abnormal_reboot.h | 3 + radio/src/hal/rgbleds.cpp | 52 + radio/src/hal/rgbleds.h | 30 + radio/src/model_init.cpp | 6 + radio/src/simu.cpp | 2 +- radio/src/storage/yaml/CMakeLists.txt | 2 + radio/src/storage/yaml/yaml_datastructs.cpp | 2 + .../storage/yaml/yaml_datastructs_128x64.cpp | 2 +- .../src/storage/yaml/yaml_datastructs_f16.cpp | 2 +- .../storage/yaml/yaml_datastructs_gx12.cpp | 898 ++++++++++++++++++ .../storage/yaml/yaml_datastructs_nv14.cpp | 2 +- .../storage/yaml/yaml_datastructs_pl18.cpp | 2 +- .../src/storage/yaml/yaml_datastructs_t15.cpp | 2 +- .../src/storage/yaml/yaml_datastructs_t20.cpp | 2 +- .../storage/yaml/yaml_datastructs_tpro.cpp | 2 +- .../src/storage/yaml/yaml_datastructs_x10.cpp | 2 +- .../src/storage/yaml/yaml_datastructs_x9d.cpp | 2 +- .../yaml/yaml_datastructs_x9dp2019.cpp | 2 +- .../src/storage/yaml/yaml_datastructs_x9e.cpp | 2 +- .../storage/yaml/yaml_datastructs_xlite.cpp | 2 +- .../storage/yaml/yaml_datastructs_xlites.cpp | 2 +- radio/src/switches.cpp | 7 +- radio/src/switches.h | 4 +- .../common/arm/stm32/flysky_gimbal_driver.cpp | 18 +- .../common/arm/stm32/flysky_gimbal_driver.h | 6 + .../src/targets/common/arm/stm32/stm32_gpio.h | 2 +- .../targets/common/arm/stm32/stm32_ws2812.cpp | 16 + .../targets/common/arm/stm32/stm32_ws2812.h | 2 + radio/src/targets/horus/board.cpp | 3 +- radio/src/targets/horus/led_driver.cpp | 25 +- radio/src/targets/simu/led_driver.cpp | 30 +- radio/src/targets/taranis/CMakeLists.txt | 50 +- radio/src/targets/taranis/board.cpp | 24 +- radio/src/targets/taranis/gx12/bsp_io.cpp | 227 +++++ radio/src/targets/taranis/gx12/bsp_io.h | 59 ++ radio/src/targets/taranis/hal.h | 478 +++------- radio/src/targets/taranis/lcd_driver_spi.cpp | 17 + radio/src/targets/taranis/led_driver.cpp | 36 +- radio/src/targets/taranis/usb_descriptor.h | 4 + radio/src/tasks/mixer_task.cpp | 12 + radio/src/translations.cpp | 3 + radio/src/translations.h | 3 + radio/src/translations/cn.h | 3 +- radio/src/translations/cz.h | 3 +- radio/src/translations/da.h | 13 +- radio/src/translations/de.h | 5 +- radio/src/translations/en.h | 3 + radio/src/translations/es.h | 3 +- radio/src/translations/fi.h | 3 +- radio/src/translations/fr.h | 1 + radio/src/translations/he.h | 3 +- radio/src/translations/it.h | 3 +- radio/src/translations/jp.h | 3 +- radio/src/translations/nl.h | 3 +- radio/src/translations/pl.h | 4 +- radio/src/translations/pt.h | 3 +- radio/src/translations/ru.h | 3 +- radio/src/translations/se.h | 1 + radio/src/translations/tw.h | 3 +- radio/src/translations/ua.h | 3 +- radio/util/build-firmware.py | 5 + radio/util/fwoptions.py | 12 + radio/util/hw_defs/hal_switches.py | 84 +- radio/util/hw_defs/json_index.py | 65 +- radio/util/hw_defs/legacy_names.py | 53 ++ radio/util/hw_defs/pot_config.py | 9 +- radio/util/hw_defs/stm32_switches.jinja | 12 +- radio/util/hw_defs/switch_config.py | 16 +- tools/build-common.sh | 3 + tools/build-companion.sh | 2 +- tools/generate-hw-defs.sh | 4 +- tools/generate-yaml.sh | 4 +- tools/msys2_fetch_and_build_all.sh | 5 +- 95 files changed, 2284 insertions(+), 602 deletions(-) create mode 100644 radio/src/hal/rgbleds.cpp create mode 100644 radio/src/hal/rgbleds.h create mode 100644 radio/src/storage/yaml/yaml_datastructs_gx12.cpp create mode 100644 radio/src/targets/taranis/gx12/bsp_io.cpp create mode 100644 radio/src/targets/taranis/gx12/bsp_io.h diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 8b925cb43af..661cdb10675 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -107,6 +107,7 @@ body: - Jumper T-Pro - Jumper T-Pro V2 - RadioMaster Boxer + - RadioMaster GX12 - RadioMaster MT12 - RadioMaster Pocket - RadioMaster T8 diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index d101050c1c1..1281f386e37 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -70,6 +70,7 @@ jobs: - xlite - xlites - mt12 + - gx12 container: image: ghcr.io/edgetx/edgetx-dev:latest volumes: @@ -103,7 +104,7 @@ jobs: - t8;zorro;pocket;mt12;commando8 - tlite;tpro;tprov2;tpros;bumblebee;lr3pro - t20;t20v2;t14 - - tx12;tx12mk2;boxer + - tx12;tx12mk2;boxer;gx12 - tx16s - f16 - v16 @@ -114,7 +115,7 @@ jobs: - x9e;x9e-hall - x9lite;x9lites - xlite;xlites - - mt12 + - mt12;gx12 container: image: ghcr.io/edgetx/edgetx-dev:latest volumes: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 22a237b88e4..2ed72398e7e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -23,7 +23,7 @@ jobs: - t8;zorro;pocket;mt12;commando8 - tlite;tpro;tprov2;tpros;bumblebee;lr3pro - t20;t20v2;t14 - - tx12;tx12mk2;boxer + - tx12;tx12mk2;boxer;gx12 - tx16s - f16 - v16 @@ -35,6 +35,7 @@ jobs: - x9lite;x9lites - xlite;xlites - mt12 + - gx12 container: image: ghcr.io/edgetx/edgetx-dev:latest volumes: diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 5a671294a93..fa5cc7ff31e 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -321,6 +321,8 @@ elseif(PCB STREQUAL X7 AND PCBREV STREQUAL ZORRO) set(FLAVOUR zorro) elseif(PCB STREQUAL X7 AND PCBREV STREQUAL BOXER) set(FLAVOUR boxer) +elseif(PCB STREQUAL X7 AND PCBREV STREQUAL GX12) + set(FLAVOUR gx12) elseif(PCB STREQUAL X7 AND PCBREV STREQUAL POCKET) set(FLAVOUR pocket) elseif(PCB STREQUAL X7 AND PCBREV STREQUAL LR3PRO) diff --git a/companion/src/firmwares/boards.cpp b/companion/src/firmwares/boards.cpp index eacfe141cae..7212287d8ab 100644 --- a/companion/src/firmwares/boards.cpp +++ b/companion/src/firmwares/boards.cpp @@ -201,6 +201,7 @@ int Boards::getEEpromSize(Board::Type board) case BOARD_RADIOMASTER_BOXER: case BOARD_RADIOMASTER_POCKET: case BOARD_RADIOMASTER_MT12: + case BOARD_RADIOMASTER_GX12: return EESIZE_TARANIS; case BOARD_UNKNOWN: return EESIZE_MAX; @@ -260,6 +261,7 @@ int Boards::getFlashSize(Type board) case BOARD_RADIOMASTER_T8: case BOARD_RADIOMASTER_POCKET: case BOARD_RADIOMASTER_MT12: + case BOARD_RADIOMASTER_GX12: return FSIZE_TARANIS; case BOARD_HORUS_X12S: case BOARD_X10: @@ -620,6 +622,8 @@ QString Boards::getBoardName(Board::Type board) return "Radiomaster TX16S"; case BOARD_RADIOMASTER_ZORRO: return "Radiomaster Zorro"; + case BOARD_RADIOMASTER_GX12: + return "Radiomaster GX12"; case BOARD_FLYSKY_NV14: return "FlySky NV14"; case BOARD_FLYSKY_EL18: @@ -744,6 +748,7 @@ int Boards::getDefaultInternalModules(Board::Type board) case BOARD_RADIOMASTER_BOXER: case BOARD_RADIOMASTER_MT12: case BOARD_RADIOMASTER_POCKET: + case BOARD_RADIOMASTER_GX12: case BOARD_RADIOMASTER_TX12_MK2: case BOARD_IFLIGHT_COMMANDO8: case BOARD_JUMPER_T12MAX: @@ -786,6 +791,7 @@ void Boards::getBattRange(Board::Type board, int& vmin, int& vmax, unsigned int& case BOARD_RADIOMASTER_POCKET: case BOARD_RADIOMASTER_ZORRO: case BOARD_RADIOMASTER_MT12: + case BOARD_RADIOMASTER_GX12: case BOARD_JUMPER_T12: case BOARD_JUMPER_T14: case BOARD_JUMPER_TPRO: diff --git a/companion/src/firmwares/boards.h b/companion/src/firmwares/boards.h index b2e8f1635b6..37340c0cbed 100644 --- a/companion/src/firmwares/boards.h +++ b/companion/src/firmwares/boards.h @@ -72,6 +72,7 @@ namespace Board { BOARD_RADIOMASTER_TX12, BOARD_RADIOMASTER_TX12_MK2, BOARD_RADIOMASTER_BOXER, + BOARD_RADIOMASTER_GX12, BOARD_RADIOMASTER_T8, BOARD_JUMPER_TLITE, BOARD_JUMPER_TLITE_F4, @@ -590,6 +591,11 @@ inline bool IS_RADIOMASTER_POCKET(Board::Type board) return board == Board::BOARD_RADIOMASTER_POCKET; } +inline bool IS_RADIOMASTER_GX12(Board::Type board) +{ + return board == Board::BOARD_RADIOMASTER_GX12; +} + inline bool IS_RADIOMASTER_T8(Board::Type board) { return board == Board::BOARD_RADIOMASTER_T8; @@ -629,6 +635,7 @@ inline bool IS_FAMILY_T12(Board::Type board) board == Board::BOARD_RADIOMASTER_BOXER || board == Board::BOARD_RADIOMASTER_MT12 || board == Board::BOARD_RADIOMASTER_POCKET || + board == Board::BOARD_RADIOMASTER_GX12 || board == Board::BOARD_RADIOMASTER_T8 || board == Board::BOARD_BETAFPV_LR3PRO || board == Board::BOARD_IFLIGHT_COMMANDO8; diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 8b16d4906a2..c857049cede 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -781,6 +781,13 @@ void registerOpenTxFirmwares() registerOpenTxFirmware(firmware); addOpenTxRfOptions(firmware, FLEX); + /* Radiomaster GX12 board */ + firmware = new OpenTxFirmware(FIRMWAREID("gx12"), QCoreApplication::translate("Firmware", "Radiomaster GX12"), BOARD_RADIOMASTER_GX12); + addOpenTxCommonOptions(firmware); + addOpenTxFontOptions(firmware); + registerOpenTxFirmware(firmware); + addOpenTxRfOptions(firmware, FLEX); + /* Radiomaster TX16S board */ firmware = new OpenTxFirmware(FIRMWAREID("tx16s"), Firmware::tr("Radiomaster TX16S / SE / Hall / Masterfire"), BOARD_RADIOMASTER_TX16S); addOpenTxFrskyOptions(firmware); diff --git a/companion/src/simulation/simulatorwidget.cpp b/companion/src/simulation/simulatorwidget.cpp index eab4676269b..673b53c55b0 100644 --- a/companion/src/simulation/simulatorwidget.cpp +++ b/companion/src/simulation/simulatorwidget.cpp @@ -144,6 +144,9 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface * simulato case Board::BOARD_RADIOMASTER_MT12: radioUiWidget = new SimulatedUIWidgetMT12(simulator, this); break; + case Board::BOARD_RADIOMASTER_GX12: + radioUiWidget = new SimulatedUIWidgetGeneric(simulator, this); + break; case Board::BOARD_RADIOMASTER_T8: radioUiWidget = new SimulatedUIWidgetT8(simulator, this); break; diff --git a/fw.json b/fw.json index f836ad03335..8300dc7cf79 100644 --- a/fw.json +++ b/fw.json @@ -44,7 +44,8 @@ ["RadioMaster TX12", "tx12-"], ["RadioMaster TX12MK2", "tx12mk2-"], ["RadioMaster TX16S", "tx16s-"], - ["RadioMaster Zorro","zorro-"] + ["RadioMaster Zorro","zorro-"], + ["RadioMaster GX12", "gx12-"] ], "changelog": "- Major initial bug fixes" } diff --git a/radio/src/boards/generic_stm32/rgb_leds.cpp b/radio/src/boards/generic_stm32/rgb_leds.cpp index cd060b192c8..f5a31a6e3ef 100644 --- a/radio/src/boards/generic_stm32/rgb_leds.cpp +++ b/radio/src/boards/generic_stm32/rgb_leds.cpp @@ -50,6 +50,16 @@ void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b) #endif } +uint32_t rgbGetLedColor(uint8_t led) +{ + return ws2812_get_color(led); +} + +bool rgbGetState(uint8_t led) +{ + return ws2812_get_state(led); +} + void rgbLedColorApply() { ws2812_update(&_led_timer);; diff --git a/radio/src/boards/generic_stm32/rgb_leds.h b/radio/src/boards/generic_stm32/rgb_leds.h index 7dc76ae1b7b..8f6f9fd607c 100644 --- a/radio/src/boards/generic_stm32/rgb_leds.h +++ b/radio/src/boards/generic_stm32/rgb_leds.h @@ -24,4 +24,6 @@ void rgbLedStart(); void rgbLedStop(); void rgbSetLedColor(unsigned char, unsigned char, unsigned char, unsigned char); +uint32_t rgbGetLedColor(uint8_t led); +bool rgbGetState(unsigned char); void rgbLedColorApply(); diff --git a/radio/src/boards/generic_stm32/switches.cpp b/radio/src/boards/generic_stm32/switches.cpp index 8479521a7e3..77468d0c927 100644 --- a/radio/src/boards/generic_stm32/switches.cpp +++ b/radio/src/boards/generic_stm32/switches.cpp @@ -31,12 +31,12 @@ #include -void boardInitSwitches() +__weak void boardInitSwitches() { _init_switches(); } -SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx) +__weak SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx) { return stm32_switch_get_position(&_switch_offsets[cat][idx]); } diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index f6d2f67f5f6..c8fda1761c2 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -22,6 +22,7 @@ #include #include +#include "hal/serial_driver.h" #include "edgetx.h" #include "timers_driver.h" #include "hal/watchdog_driver.h" @@ -1045,28 +1046,77 @@ int cliSet(const char **argv) } #if defined(ENABLE_SERIAL_PASSTHROUGH) -#if defined(HARDWARE_INTERNAL_MODULE) -static etx_module_state_t *spInternalModuleState = nullptr; -static void spInternalModuleTx(uint8_t* buf, uint32_t len) -{ - auto drv = modulePortGetSerialDrv(spInternalModuleState->tx); - auto ctx = modulePortGetCtx(spInternalModuleState->tx); +static const etx_serial_driver_t* _sp_drv = nullptr; +static void* _sp_ctx = nullptr; +static void _sp_Tx(uint8_t* buf, uint32_t len) +{ while (len > 0) { - drv->sendByte(ctx, *(buf++)); + _sp_drv->sendByte(_sp_ctx, *(buf++)); len--; } } -static const etx_serial_init spIntmoduleSerialInitParams = { - .baudrate = 0, - .encoding = ETX_Encoding_8N1, - .direction = ETX_Dir_TX_RX, - .polarity = ETX_Pol_Normal, -}; +#if defined(HARDWARE_INTERNAL_MODULE) || defined(HARDWARE_EXTERNAL_MODULE) +static etx_module_state_t *spModuleState = nullptr; + +static void spModuleInit(int port_n, int baudrate) +{ + etx_serial_init params = { + .baudrate = (uint32_t)baudrate, + .encoding = ETX_Encoding_8N1, + .direction = ETX_Dir_TX_RX, + .polarity = ETX_Pol_Normal, + }; + + spModuleState = + modulePortInitSerial(port_n, ETX_MOD_PORT_UART, ¶ms, false); + _sp_drv = modulePortGetSerialDrv(spModuleState->rx); + _sp_ctx = modulePortGetCtx(spModuleState->rx); +} + +static void spModuleDeInit(int port_n) +{ + // and stop module + modulePortDeInit(spModuleState); + spModuleState = nullptr; + + // power off the module and wait for a bit + modulePortSetPower(port_n, false); + delay_ms(200); +} #endif // HARDWARE_INTERNAL_MODULE + +#if defined(FLYSKY_GIMBAL) +#include "flysky_gimbal_driver.h" + +static void spGimbalInit(int port_n, int baudrate) +{ + etx_serial_init params = { + .baudrate = (uint32_t)baudrate, + .encoding = ETX_Encoding_8N1, + .direction = ETX_Dir_TX_RX, + .polarity = ETX_Pol_Normal, + }; + + (void)port_n; + flysky_gimbal_deinit(); + + auto port = flysky_gimbal_get_port(); + _sp_drv = port->uart; + _sp_ctx = _sp_drv->init(port->hw_def, ¶ms); +} + +static void spGimbalDeInit(int port_n) +{ + (void)port_n; + _sp_drv->deinit(_sp_ctx); + flysky_gimbal_init(); +} +#endif + // TODO: use proper method instead extern bool cdcConnected; extern uint32_t usbSerialBaudRate(void*); @@ -1074,121 +1124,116 @@ extern uint32_t usbSerialBaudRate(void*); int cliSerialPassthrough(const char **argv) { const char* port_type = argv[1]; - const char* port_num = argv[2]; - // 3rd argument (baudrate is optional) - if (!port_type || !port_num) { + if (!port_type) { cliSerialPrint("%s: missing argument", argv[0]); return -1; } - int port_n = 0; - int err = toInt(argv, 2, &port_n); - if (err == -1) return err; - if (err == 0) { - cliSerialPrint("%s: missing port #", argv[0]); - return -1; - } - int baudrate = 0; - err = toInt(argv, 3, &baudrate); - if (err <= 0) { - // use current baudrate - baudrate = cliGetBaudRate(); - if (!baudrate) { - // default to 115200 - baudrate = 115200; - cliSerialPrint("%s: baudrate is 0, default to 115200", argv[0]); - } - } + void (*initCB)(int, int) = nullptr; + void (*deinitCB)(int) = nullptr; + int port_n = 0; if (!strcmp("rfmod", port_type)) { - - if (port_n >= NUM_MODULES - // only internal module supported for now - && port_n != INTERNAL_MODULE) { - cliSerialPrint("%s: invalid port # '%s'", port_num); + // parse port number + if (toInt(argv, 2, &port_n) <= 0) { + cliSerialPrint("%s: invalid or missing port number", argv[0]); return -1; } - - // stop pulses - watchdogSuspend(200/*2s*/); - pulsesStop(); - - // suspend RTOS scheduler - vTaskSuspendAll(); + // 3rd argument (baudrate is optional) + if (toInt(argv, 3, &baudrate) <= 0) { + baudrate = 0; + } + switch(port_n) { #if defined(HARDWARE_INTERNAL_MODULE) - if (port_n == INTERNAL_MODULE) { - - // setup serial com + case INTERNAL_MODULE: + initCB = spModuleInit; + deinitCB = spModuleDeInit; + break; +#endif + // TODO: + // - external module (S.PORT?) + default: + cliSerialPrint("%s: invalid port # '%i'", port_n); + return -1; + } + } else if (!strcmp("gimbals", port_type)) { +#if defined(FLYSKY_GIMBAL) + // 2nd argument (baudrate is optional) + if (toInt(argv, 2, &baudrate) <= 0) { + baudrate = 0; + } - // TODO: '8n1' param - etx_serial_init params(spIntmoduleSerialInitParams); - params.baudrate = baudrate; + initCB = spGimbalInit; + deinitCB = spGimbalDeInit; +#else + cliSerialPrint("%s: serial gimbals not supported"); + return -1; +#endif + } else { + cliSerialPrint("%s: invalid port type '%s'", port_type); + return -1; + } - spInternalModuleState = modulePortInitSerial(port_n, ETX_MOD_PORT_UART, - ¶ms, false); + // stop pulses + watchdogSuspend(200/*2s*/); + pulsesStop(); - auto drv = modulePortGetSerialDrv(spInternalModuleState->rx); - auto ctx = modulePortGetCtx(spInternalModuleState->rx); + // suspend RTOS scheduler + vTaskSuspendAll(); - // backup and swap CLI input - auto backupCB = cliReceiveCallBack; - cliReceiveCallBack = spInternalModuleTx; + if (baudrate <= 0) { + // use current baudrate + baudrate = cliGetBaudRate(); + if (!baudrate) { + baudrate = 115200; + cliSerialPrint("%s: baudrate is 0, default to 115200", argv[0]); + } + } - // loop until cable disconnected - while (usbPlugged()) { + if (initCB) initCB(port_n, baudrate); - uint32_t cli_br = cliGetBaudRate(); - if (cli_br && (cli_br != (uint32_t)baudrate)) { - baudrate = cli_br; - drv->setBaudrate(ctx, baudrate); - } + if (_sp_drv != nullptr) { + auto backupCB = cliReceiveCallBack; + cliReceiveCallBack = _sp_Tx; - uint8_t data; - if (drv->getByte(ctx, &data) > 0) { + // loop until cable disconnected + while (usbPlugged()) { - uint8_t timeout = 10; // 10 ms - while(!usbSerialFreeSpace() && (timeout > 0)) { - delay_ms(1); - timeout--; - } + uint32_t cli_br = cliGetBaudRate(); + if (cli_br && (cli_br != (uint32_t)baudrate)) { + baudrate = cli_br; + _sp_drv->setBaudrate(_sp_ctx, baudrate); + } - cliSerialPutc(data); + uint8_t data; + if (_sp_drv->getByte(_sp_ctx, &data) > 0) { + uint8_t timeout = 10; // 10 ms + while(!usbSerialFreeSpace() && (timeout > 0)) { + delay_ms(1); + timeout--; } - // keep us up & running - WDG_RESET(); + cliSerialPutc(data); } - // restore callsbacks - cliReceiveCallBack = backupCB; - - // and stop module - modulePortDeInit(spInternalModuleState); - spInternalModuleState = nullptr; - - // power off the module and wait for a bit - modulePortSetPower(port_n, false); - delay_ms(200); + // keep us up & running + WDG_RESET(); } -#endif - // TODO: - // - external module (S.PORT?) + // restore callsbacks + cliReceiveCallBack = backupCB; + if (deinitCB != nullptr) deinitCB(port_n); + } - watchdogSuspend(200/*2s*/); - pulsesStart(); + watchdogSuspend(200/*2s*/); + pulsesStart(); + + // suspend RTOS scheduler + xTaskResumeAll(); - // suspend RTOS scheduler - xTaskResumeAll(); - - } else { - cliSerialPrint("%s: invalid port type '%s'", port_type); - return -1; - } - return 0; } #endif @@ -1626,7 +1671,7 @@ const CliCommand cliCommands[] = { { "reboot", cliReboot, "[wdt]" }, { "set", cliSet, " " }, #if defined(ENABLE_SERIAL_PASSTHROUGH) - { "serialpassthrough", cliSerialPassthrough, " "}, + { "serialpassthrough", cliSerialPassthrough, " [] []"}, #endif #if defined(DEBUG) { "print", cliDisplay, "
[] | " }, diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index f20d1f0318c..ef8fa03ea42 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -96,6 +96,8 @@ static inline void check_struct() CHKSIZE(ModelData, 6329); #elif defined(RADIO_FAMILY_T20) CHKSIZE(ModelData, 6390); +#elif defined(RADIO_GX12) + CHKSIZE(ModelData, 6390); #elif defined(PCBX9E) CHKSIZE(ModelData, 6771); #elif defined(PCBX9D) || defined(PCBX9DP) diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index d47166f7b6c..9516b2e29b2 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -31,6 +31,7 @@ #include "serial.h" #include "usb_joystick.h" #include "input_mapping.h" +#include "debug.h" #if defined(PCBTARANIS) #define N_TARANIS_FIELD(x) @@ -626,13 +627,37 @@ PACK(struct CustomScreenData { #define SCRIPT_DATA #endif +struct RGBLedColor { + uint8_t r; + uint8_t g; + uint8_t b; + + uint32_t getColor() { + return ((r << 16) + (g << 8) + b); + } + + void setColor(uint32_t color) { + r = color >> 16; + g = color >> 8; + b = color; + } +}; + +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + #define FUNCTION_SWITCHS_RGB_LEDS_FIELDS \ + RGBLedColor functionSwitchLedONColor[NUM_FUNCTIONS_SWITCHES]; \ + RGBLedColor functionSwitchLedOFFColor[NUM_FUNCTIONS_SWITCHES]; +#else + #define FUNCTION_SWITCHS_RGB_LEDS_FIELDS +#endif #if defined(FUNCTION_SWITCHES) #define FUNCTION_SWITCHS_FIELDS \ uint16_t functionSwitchConfig; \ uint16_t functionSwitchGroup; \ uint16_t functionSwitchStartConfig; \ - uint8_t functionSwitchLogicalState; \ - char switchNames[NUM_FUNCTIONS_SWITCHES][LEN_SWITCH_NAME]; + uint8_t functionSwitchLogicalState; \ + char switchNames[NUM_FUNCTIONS_SWITCHES][LEN_SWITCH_NAME]; \ + FUNCTION_SWITCHS_RGB_LEDS_FIELDS #else #define FUNCTION_SWITCHS_FIELDS #endif diff --git a/radio/src/edgetx.cpp b/radio/src/edgetx.cpp index 54979bfdcbc..cb07a0f4548 100644 --- a/radio/src/edgetx.cpp +++ b/radio/src/edgetx.cpp @@ -1365,8 +1365,6 @@ void edgeTxInit() menuHandlers[1] = menuModelSelect; #endif - switchInit(); - #if defined(GUI) && !defined(COLORLCD) lcdRefreshWait(); lcdClear(); diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index 8107bd43462..65197dcaf70 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -24,6 +24,7 @@ #include "hal/adc_driver.h" #include "hal/switch_driver.h" #include "hal/module_port.h" +#include "hal/rgbleds.h" #include "switches.h" #if defined(USBJ_EX) @@ -70,7 +71,30 @@ enum MenuModelSetupItems { ITEM_MODEL_SETUP_TIMER3_PERSISTENT, ITEM_MODEL_SETUP_TIMER3_MINUTE_BEEP, ITEM_MODEL_SETUP_TIMER3_COUNTDOWN_BEEP, -#if defined(FUNCTION_SWITCHES) +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + ITEM_MODEL_SETUP_LABEL, + ITEM_MODEL_SETUP_SW1, + ITEM_MODEL_SETUP_SW1_COLOR, + ITEM_MODEL_SETUP_SW2, + ITEM_MODEL_SETUP_SW2_COLOR, + ITEM_MODEL_SETUP_SW3, + ITEM_MODEL_SETUP_SW3_COLOR, + ITEM_MODEL_SETUP_SW4, + ITEM_MODEL_SETUP_SW4_COLOR, + ITEM_MODEL_SETUP_SW5, + ITEM_MODEL_SETUP_SW5_COLOR, + ITEM_MODEL_SETUP_SW6, + ITEM_MODEL_SETUP_SW6_COLOR, + ITEM_MODEL_SETUP_GROUP1_LABEL, + ITEM_MODEL_SETUP_GROUP1_ALWAYS_ON, + ITEM_MODEL_SETUP_GROUP1_START, + ITEM_MODEL_SETUP_GROUP2_LABEL, + ITEM_MODEL_SETUP_GROUP2_ALWAYS_ON, + ITEM_MODEL_SETUP_GROUP2_START, + ITEM_MODEL_SETUP_GROUP3_LABEL, + ITEM_MODEL_SETUP_GROUP3_ALWAYS_ON, + ITEM_MODEL_SETUP_GROUP3_START, +#elif defined(FUNCTION_SWITCHES) ITEM_MODEL_SETUP_LABEL, ITEM_MODEL_SETUP_SW1, ITEM_MODEL_SETUP_SW2, @@ -354,7 +378,30 @@ inline uint8_t TIMER_ROW(uint8_t timer, uint8_t value) #define EXTRA_MODULE_ROWS -#if defined(FUNCTION_SWITCHES) +#if defined(FUNCTION_SWITCHES_RGB_LEDS) +#define FUNCTION_SWITCHES_ROWS 1, \ + FS_ROW(NAVIGATION_LINE_BY_LINE|3), \ + FS_ROW(1), \ + FS_ROW(NAVIGATION_LINE_BY_LINE|3), \ + FS_ROW(1), \ + FS_ROW(NAVIGATION_LINE_BY_LINE|3), \ + FS_ROW(1), \ + FS_ROW(NAVIGATION_LINE_BY_LINE|3), \ + FS_ROW(1), \ + FS_ROW(NAVIGATION_LINE_BY_LINE|3), \ + FS_ROW(1), \ + FS_ROW(NAVIGATION_LINE_BY_LINE|3), \ + FS_ROW(1), \ + FS_ROW(G1_ROW(LABEL())), \ + FS_ROW(G1_ROW(0)), \ + FS_ROW(G1_ROW(0)), \ + FS_ROW(G2_ROW(LABEL())), \ + FS_ROW(G2_ROW(0)), \ + FS_ROW(G2_ROW(0)), \ + FS_ROW(G3_ROW(LABEL())), \ + FS_ROW(G3_ROW(0)), \ + FS_ROW(G3_ROW(0)), +#elif defined(FUNCTION_SWITCHES) #define FUNCTION_SWITCHES_ROWS 1, \ FS_ROW(NAVIGATION_LINE_BY_LINE|3), \ FS_ROW(NAVIGATION_LINE_BY_LINE|3), \ @@ -838,9 +885,15 @@ void menuModelSetup(event_t event) case ITEM_MODEL_SETUP_SW5: case ITEM_MODEL_SETUP_SW6: { - int index = k - ITEM_MODEL_SETUP_SW1; + int index = (k - ITEM_MODEL_SETUP_SW1) / 2; lcdDrawSizedText(INDENT_WIDTH, y, STR_CHAR_SWITCH, 2, menuHorizontalPosition < 0 ? attr : 0); - lcdDrawText(lcdNextPos, y, switchGetName(index+switchGetMaxSwitches()), menuHorizontalPosition < 0 ? attr : 0); + + // TODO: restore following line when switchGetName(index+switchGetMaxSwitches()) doesn't crash anymore + //lcdDrawText(lcdNextPos, y, switchGetName(index+switchGetMaxSwitches()), menuHorizontalPosition < 0 ? attr : 0); + + // TODO : delete next 2 lines when switchGetName(index+switchGetMaxSwitches()) doesn't crash anymore + lcdDrawText(lcdNextPos, y, "SW", menuHorizontalPosition < 0 ? attr : 0); + lcdDrawChar(lcdNextPos, y, '1' + index, menuHorizontalPosition < 0 ? attr : 0); if (ZEXIST(g_model.switchNames[index]) || (attr && s_editMode > 0 && menuHorizontalPosition == 0)) editName(35, y, g_model.switchNames[index], LEN_SWITCH_NAME, event, menuHorizontalPosition == 0 ? attr : 0, 0, old_editMode); @@ -892,6 +945,39 @@ void menuModelSetup(event_t event) break; } +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + case ITEM_MODEL_SETUP_SW1_COLOR: + case ITEM_MODEL_SETUP_SW2_COLOR: + case ITEM_MODEL_SETUP_SW3_COLOR: + case ITEM_MODEL_SETUP_SW4_COLOR: + case ITEM_MODEL_SETUP_SW5_COLOR: + case ITEM_MODEL_SETUP_SW6_COLOR: + { + int index = (k - ITEM_MODEL_SETUP_SW1_COLOR) / 2; + uint8_t selectedColor = 0; + + // ON + selectedColor = getRGBColorIndex(g_model.functionSwitchLedONColor[index].getColor()); + selectedColor = editChoice(INDENT_WIDTH + getTextWidth(STR_FS_ON_COLOR) + 2, y, STR_FS_ON_COLOR, \ + STR_FS_COLOR_LIST, selectedColor, 0, (sizeof(colorTable) / sizeof(colorTable[0])) - 1, menuHorizontalPosition == 0 ? attr : 0, event, INDENT_WIDTH); + if (attr && menuHorizontalPosition == 0 && checkIncDec_Ret) { + g_model.functionSwitchLedONColor[index].setColor(colorTable[selectedColor]); + storageDirty(EE_MODEL); + } + + // OFF + selectedColor = getRGBColorIndex(g_model.functionSwitchLedOFFColor[index].getColor()); + selectedColor = editChoice((30 + 5*FW) + getTextWidth(STR_FS_OFF_COLOR) + 2, y, STR_FS_OFF_COLOR, \ + STR_FS_COLOR_LIST, selectedColor, 0, (sizeof(colorTable) / sizeof(colorTable[0])) - 1, menuHorizontalPosition == 1 ? attr : 0, event, 30 + 5*FW); + if (attr && menuHorizontalPosition == 1 && checkIncDec_Ret) { + g_model.functionSwitchLedOFFColor[index].setColor(colorTable[selectedColor]); + storageDirty(EE_MODEL); + } + + break; + } +#endif + case ITEM_MODEL_SETUP_GROUP1_LABEL: case ITEM_MODEL_SETUP_GROUP2_LABEL: case ITEM_MODEL_SETUP_GROUP3_LABEL: diff --git a/radio/src/gui/128x64/radio_diagkeys.cpp b/radio/src/gui/128x64/radio_diagkeys.cpp index f9309ed7423..99391e01d85 100644 --- a/radio/src/gui/128x64/radio_diagkeys.cpp +++ b/radio/src/gui/128x64/radio_diagkeys.cpp @@ -24,6 +24,7 @@ #include "hal/switch_driver.h" #include "hal/key_driver.h" #include "switches.h" +#include "boards/generic_stm32/rgb_leds.h" void displayKeyState(uint8_t x, uint8_t y, uint8_t key) { @@ -54,9 +55,15 @@ static EnumKeys get_ith_key(uint8_t i) #if defined(FUNCTION_SWITCHES) void menuRadioDiagFS(event_t event) { +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + constexpr coord_t FS_1ST_COLUMN = 32; + constexpr coord_t FS_2ND_COLUMN = 60; + constexpr coord_t FS_3RD_COLUMN = 80; +#else constexpr coord_t FS_1ST_COLUMN = 40; constexpr coord_t FS_2ND_COLUMN = 70; constexpr coord_t FS_3RD_COLUMN = 100; +#endif SIMPLE_SUBMENU(STR_MENU_FSWITCH, 1); lcdDrawText(FS_1ST_COLUMN, MENU_HEADER_HEIGHT + 1, "Phys"); lcdDrawText(FS_2ND_COLUMN, MENU_HEADER_HEIGHT + 1, "Log"); @@ -68,7 +75,11 @@ void menuRadioDiagFS(event_t event) lcdDrawText(lcdNextPos, y, switchGetName(i+switchGetMaxSwitches()), 0); lcdDrawText(FS_1ST_COLUMN + 7, y, getFSPhysicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP); lcdDrawText(FS_2ND_COLUMN + 5, y, getFSLogicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP); - lcdDrawText(FS_3RD_COLUMN, y, STR_OFFON[getFSLedState(i)]); +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + lcdDrawText(FS_3RD_COLUMN, y, STR_FS_COLOR_LIST[getRGBColorIndex(rgbGetLedColor(i))], 0); +#else + lcdDrawText(FS_3RD_COLUMN, y, STR_OFFON[fsLedState(i)]); +#endif } } #endif diff --git a/radio/src/gui/128x64/startup_shutdown.cpp b/radio/src/gui/128x64/startup_shutdown.cpp index c5bf3cb65cd..68b0806b9a6 100644 --- a/radio/src/gui/128x64/startup_shutdown.cpp +++ b/radio/src/gui/128x64/startup_shutdown.cpp @@ -20,6 +20,8 @@ */ #include "edgetx.h" +#include "hal/rgbleds.h" +#include "boards/generic_stm32/rgb_leds.h" #define SLEEP_BITMAP_WIDTH 42 @@ -52,9 +54,14 @@ void drawStartupAnimation(uint32_t duration, uint32_t totalDuration) for (uint8_t j = 0; j < steps; j++) { if (index2 > j) { - fsLedOn(j); +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + fsLedRGB(j, 0xFFFFFF); + rgbLedColorApply(); +#else + setFSLedON(j); +#endif #if defined(RADIO_FAMILY_T20) - fsLedOn(j + steps); + setFSLedON(j + steps); #endif } } @@ -88,14 +95,14 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, steps); for (uint8_t j = 0; j < steps; j++) { - fsLedOff(j); + setFSLedOFF(j); #if defined(RADIO_FAMILY_T20) - fsLedOff(j + steps); + setFSLedOFF(j + steps); #endif if (steps - index2 > j) { - fsLedOn(j); + setFSLedON(j); #if defined(RADIO_FAMILY_T20) - fsLedOn(j + steps); + setFSLedON(j + steps); #endif } } diff --git a/radio/src/gui/colorlcd/model/function_switches.cpp b/radio/src/gui/colorlcd/model/function_switches.cpp index 103f28f989b..a45cce00f84 100644 --- a/radio/src/gui/colorlcd/model/function_switches.cpp +++ b/radio/src/gui/colorlcd/model/function_switches.cpp @@ -26,6 +26,13 @@ #include "edgetx.h" #include "strhelpers.h" #include "switches.h" +#include "color_picker.h" + +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + static constexpr coord_t LH = 72; +#else + static constexpr coord_t LH = 36; +#endif #define SET_DIRTY() storageDirty(EE_MODEL) @@ -116,6 +123,37 @@ class FunctionSwitch : public Window SET_DIRTY(); }); +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + new StaticText(this, {8 , 6 + 36, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_FS_OFF_COLOR, COLOR_THEME_PRIMARY1); + + auto offcolor = new ColorPicker( + this, rect_t{}, + [=]() -> int { // getValue + return g_model.functionSwitchLedOFFColor[switchIndex]; + }, + [=](int newValue) { // setValue + g_model.functionSwitchLedOFFColor[switchIndex] = + (uint32_t)newValue; + TRACE("Color: %x", g_model.functionSwitchLedOFFColor[switchIndex]); + SET_DIRTY(); + }); + offcolor->setPos(NM_X, 36); + + new StaticText(this, {TP_X, 6 + 36, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_FS_ON_COLOR, COLOR_THEME_PRIMARY1); + + auto oncolor = new ColorPicker( + this, rect_t{}, + [=]() -> int { // getValue + return g_model.functionSwitchLedONColor[switchIndex]; + }, + [=](int newValue) { // setValue + g_model.functionSwitchLedONColor[switchIndex] = + (uint32_t)newValue; + SET_DIRTY(); + }); + oncolor->setPos(GR_X, 36); +#endif //FUNCTION_SWITCHES_RGB_LEDS + setState(); } diff --git a/radio/src/gui/colorlcd/radio/radio_diagcustswitches.cpp b/radio/src/gui/colorlcd/radio/radio_diagcustswitches.cpp index f5d00cbc15c..6b749a093a3 100644 --- a/radio/src/gui/colorlcd/radio/radio_diagcustswitches.cpp +++ b/radio/src/gui/colorlcd/radio/radio_diagcustswitches.cpp @@ -23,6 +23,7 @@ #include "radio_diagcustswitches.h" +#include "hal/rgbleds.h" #include "board.h" #include "libopenui.h" #include "edgetx.h" diff --git a/radio/src/hal/CMakeLists.txt b/radio/src/hal/CMakeLists.txt index 1089a2e0a83..a01bb24307f 100644 --- a/radio/src/hal/CMakeLists.txt +++ b/radio/src/hal/CMakeLists.txt @@ -13,6 +13,12 @@ set(SRC ${SRC} hal/switch_driver.cpp ) +if(FUNCTION_SWITCHES) + set(SRC ${SRC} + hal/rgbleds.cpp + ) +endif() + if (FLEXSW) # define the number of allowed flexible adc entries used as switch add_definitions(-DMAX_FLEX_SWITCHES=${FLEXSW}) diff --git a/radio/src/hal/abnormal_reboot.h b/radio/src/hal/abnormal_reboot.h index 63704be798a..dcc07e72e41 100644 --- a/radio/src/hal/abnormal_reboot.h +++ b/radio/src/hal/abnormal_reboot.h @@ -46,3 +46,6 @@ uint32_t abnormalRebootGetCause(); #define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() \ (abnormalRebootGetCause() != ARC_None) + +#define WAS_RESET_BY_SOFTWARE() \ + (abnormalRebootGetCause() == ARC_Software) diff --git a/radio/src/hal/rgbleds.cpp b/radio/src/hal/rgbleds.cpp new file mode 100644 index 00000000000..c30bd4caed4 --- /dev/null +++ b/radio/src/hal/rgbleds.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "edgetx.h" +#include "rgbleds.h" +#include "boards/generic_stm32/rgb_leds.h" +#include "definitions.h" +#include "dataconstants.h" + +#if defined(FUNCTION_SWITCHES_RGB_LEDS) +void setFSLedOFF(uint8_t index) { + fsLedRGB(index, g_model.functionSwitchLedOFFColor[index].getColor()); +} + +void setFSLedON(uint8_t index) { + fsLedRGB(index, g_model.functionSwitchLedONColor[index].getColor()); +} + +bool getFSLedState(uint8_t index) { + return rgbGetLedColor(index) == g_model.functionSwitchLedONColor[index].getColor(); +} +#else +void setFSLedOFF(uint8_t index) { + fsLedOff(index); +} + +void setFSLedON(uint8_t index) { + fsLedOn(index); +} + +bool getFSLedState(uint8_t index) { + return fsLedState(index); +} +#endif diff --git a/radio/src/hal/rgbleds.h b/radio/src/hal/rgbleds.h new file mode 100644 index 00000000000..ad33f51beb6 --- /dev/null +++ b/radio/src/hal/rgbleds.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#pragma once + +#include +// MUST match TR_FS_COLOR_LIST ( "White", "Red", "Green", "Yellow", "Orange", "Blue", "Pink", "Off", Custom gets display when none previous match +constexpr uint32_t colorTable[] = {0xF8F8F8, 0xF80000, 0x00F800, 0xF8F800, 0xF84000, 0x0000F8, 0xF800F8, 0x000000}; + +void setFSLedOFF(uint8_t index); +void setFSLedON(uint8_t index); +bool getFSLedState(uint8_t index); diff --git a/radio/src/model_init.cpp b/radio/src/model_init.cpp index 9ff6e6e3d51..143f3a3f65c 100644 --- a/radio/src/model_init.cpp +++ b/radio/src/model_init.cpp @@ -114,6 +114,12 @@ void applyDefaultTemplate() g_model.functionSwitchGroup = DEFAULT_FS_GROUPS; g_model.functionSwitchStartConfig = DEFAULT_FS_STARTUP_CONFIG; g_model.functionSwitchLogicalState = 0; +#if defined(FUNCTION_SWITCHES_RGB_LEDS) + for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i++) { + g_model.functionSwitchLedOFFColor[i].setColor(0); + g_model.functionSwitchLedONColor[i].setColor(0xFFFFFF); + } +#endif #endif #if defined(COLORLCD) diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 76e6392f9ea..5cf6e578a70 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -365,7 +365,7 @@ void OpenTxSim::updateKeysAndSwitches(bool start) KEY_Left, KEY_LEFT, KEY_Up, KEY_UP, KEY_Down, KEY_DOWN, -#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_MT12) || defined(RADIO_POCKET) +#elif defined(NAVIGATION_X7_TX12) KEY_Page_Up, KEY_PAGEUP, KEY_Page_Down, KEY_PAGEDN, KEY_Return, KEY_ENTER, diff --git a/radio/src/storage/yaml/CMakeLists.txt b/radio/src/storage/yaml/CMakeLists.txt index 335e7e8cf21..07e8f4a6a22 100644 --- a/radio/src/storage/yaml/CMakeLists.txt +++ b/radio/src/storage/yaml/CMakeLists.txt @@ -31,6 +31,8 @@ elseif(PCB STREQUAL X7) set(YAML_GEN_OUTPUT storage/yaml/yaml_datastructs_tpro.cpp) elseif((PCBREV STREQUAL T20) OR (PCBREV STREQUAL T20V2)) set(YAML_GEN_OUTPUT storage/yaml/yaml_datastructs_t20.cpp) + elseif(PCBREV STREQUAL GX12) + set(YAML_GEN_OUTPUT storage/yaml/yaml_datastructs_gx12.cpp) elseif((PCBREV STREQUAL COMMANDO8) OR (PCBREV STREQUAL LR3PRO) OR (PCBREV STREQUAL T8) OR (PCBREV STREQUAL T12) OR (PCBREV STREQUAL TLITE)) set(YAML_GEN_OUTPUT storage/yaml/yaml_datastructs_xlite.cpp) else() diff --git a/radio/src/storage/yaml/yaml_datastructs.cpp b/radio/src/storage/yaml/yaml_datastructs.cpp index 5c644889613..52f3b6163a9 100644 --- a/radio/src/storage/yaml/yaml_datastructs.cpp +++ b/radio/src/storage/yaml/yaml_datastructs.cpp @@ -45,6 +45,8 @@ #include "yaml_datastructs_tpro.cpp" #elif defined(RADIO_FAMILY_T20) #include "yaml_datastructs_t20.cpp" + #elif defined(RADIO_GX12) + #include "yaml_datastructs_gx12.cpp" #elif defined(RADIO_COMMANDO8) || defined(RADIO_LR3PRO) || defined(RADIO_T8) || defined(RADIO_T12) || defined(RADIO_TLITE) #include "yaml_datastructs_xlite.cpp" #else diff --git a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp index 5feceb7feaa..43e8b80900d 100644 --- a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp @@ -605,7 +605,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_f16.cpp b/radio/src/storage/yaml/yaml_datastructs_f16.cpp index f2aee2dc226..0c4ab640737 100644 --- a/radio/src/storage/yaml/yaml_datastructs_f16.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_f16.cpp @@ -633,7 +633,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_gx12.cpp b/radio/src/storage/yaml/yaml_datastructs_gx12.cpp new file mode 100644 index 00000000000..6e964d91c23 --- /dev/null +++ b/radio/src/storage/yaml/yaml_datastructs_gx12.cpp @@ -0,0 +1,898 @@ +// generated by generate_yaml.py + +// +// Enums first +// + +const struct YamlIdStr enum_BacklightMode[] = { + { e_backlight_mode_off, "backlight_mode_off" }, + { e_backlight_mode_keys, "backlight_mode_keys" }, + { e_backlight_mode_sticks, "backlight_mode_sticks" }, + { e_backlight_mode_all, "backlight_mode_all" }, + { e_backlight_mode_on, "backlight_mode_on" }, + { 0, NULL } +}; +const struct YamlIdStr enum_AntennaModes[] = { + { ANTENNA_MODE_INTERNAL, "MODE_INTERNAL" }, + { ANTENNA_MODE_ASK, "MODE_ASK" }, + { ANTENNA_MODE_PER_MODEL, "MODE_PER_MODEL" }, + { ANTENNA_MODE_EXTERNAL, "MODE_EXTERNAL" }, + { 0, NULL } +}; +const struct YamlIdStr enum_ModuleType[] = { + { MODULE_TYPE_NONE, "TYPE_NONE" }, + { MODULE_TYPE_PPM, "TYPE_PPM" }, + { MODULE_TYPE_XJT_PXX1, "TYPE_XJT_PXX1" }, + { MODULE_TYPE_ISRM_PXX2, "TYPE_ISRM_PXX2" }, + { MODULE_TYPE_DSM2, "TYPE_DSM2" }, + { MODULE_TYPE_CROSSFIRE, "TYPE_CROSSFIRE" }, + { MODULE_TYPE_MULTIMODULE, "TYPE_MULTIMODULE" }, + { MODULE_TYPE_R9M_PXX1, "TYPE_R9M_PXX1" }, + { MODULE_TYPE_R9M_PXX2, "TYPE_R9M_PXX2" }, + { MODULE_TYPE_R9M_LITE_PXX1, "TYPE_R9M_LITE_PXX1" }, + { MODULE_TYPE_R9M_LITE_PXX2, "TYPE_R9M_LITE_PXX2" }, + { MODULE_TYPE_GHOST, "TYPE_GHOST" }, + { MODULE_TYPE_R9M_LITE_PRO_PXX2, "TYPE_R9M_LITE_PRO_PXX2" }, + { MODULE_TYPE_SBUS, "TYPE_SBUS" }, + { MODULE_TYPE_XJT_LITE_PXX2, "TYPE_XJT_LITE_PXX2" }, + { MODULE_TYPE_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" }, + { MODULE_TYPE_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" }, + { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, + { 0, NULL } +}; +const struct YamlIdStr enum_TrainerMultiplex[] = { + { TRAINER_OFF, "OFF" }, + { TRAINER_ADD, "ADD" }, + { TRAINER_REPL, "REPL" }, + { 0, NULL } +}; +const struct YamlIdStr enum_BeeperMode[] = { + { e_mode_quiet, "mode_quiet" }, + { e_mode_alarms, "mode_alarms" }, + { e_mode_nokeys, "mode_nokeys" }, + { e_mode_all, "mode_all" }, + { 0, NULL } +}; +const struct YamlIdStr enum_BluetoothModes[] = { + { BLUETOOTH_OFF, "OFF" }, + { BLUETOOTH_TELEMETRY, "TELEMETRY" }, + { BLUETOOTH_TRAINER, "TRAINER" }, + { 0, NULL } +}; +const struct YamlIdStr enum_Functions[] = { + { FUNC_OVERRIDE_CHANNEL, "OVERRIDE_CHANNEL" }, + { FUNC_TRAINER, "TRAINER" }, + { FUNC_INSTANT_TRIM, "INSTANT_TRIM" }, + { FUNC_RESET, "RESET" }, + { FUNC_SET_TIMER, "SET_TIMER" }, + { FUNC_ADJUST_GVAR, "ADJUST_GVAR" }, + { FUNC_VOLUME, "VOLUME" }, + { FUNC_SET_FAILSAFE, "SET_FAILSAFE" }, + { FUNC_RANGECHECK, "RANGECHECK" }, + { FUNC_BIND, "BIND" }, + { FUNC_PLAY_SOUND, "PLAY_SOUND" }, + { FUNC_PLAY_TRACK, "PLAY_TRACK" }, + { FUNC_PLAY_VALUE, "PLAY_VALUE" }, + { FUNC_PLAY_SCRIPT, "PLAY_SCRIPT" }, + { FUNC_BACKGND_MUSIC, "BACKGND_MUSIC" }, + { FUNC_BACKGND_MUSIC_PAUSE, "BACKGND_MUSIC_PAUSE" }, + { FUNC_VARIO, "VARIO" }, + { FUNC_HAPTIC, "HAPTIC" }, + { FUNC_LOGS, "LOGS" }, + { FUNC_BACKLIGHT, "BACKLIGHT" }, + { FUNC_SCREENSHOT, "SCREENSHOT" }, + { FUNC_RACING_MODE, "RACING_MODE" }, + { FUNC_SET_SCREEN, "SET_SCREEN" }, + { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, + { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_PUSH_CUST_SWITCH, "PUSH_CUST_SWITCH" }, + { FUNC_TEST, "TEST" }, + { 0, NULL } +}; +const struct YamlIdStr enum_TimerModes[] = { + { TMRMODE_OFF, "OFF" }, + { TMRMODE_ON, "ON" }, + { TMRMODE_START, "START" }, + { TMRMODE_THR, "THR" }, + { TMRMODE_THR_REL, "THR_REL" }, + { TMRMODE_THR_START, "THR_START" }, + { 0, NULL } +}; +const struct YamlIdStr enum_MixerMultiplex[] = { + { MLTPX_ADD, "ADD" }, + { MLTPX_MUL, "MUL" }, + { MLTPX_REPL, "REPL" }, + { 0, NULL } +}; +const struct YamlIdStr enum_MixSources[] = { + { MIXSRC_NONE, "NONE" }, + { MIXSRC_MIN, "MIN" }, + { MIXSRC_MAX, "MAX" }, + { MIXSRC_TX_VOLTAGE, "TX_VOLTAGE" }, + { MIXSRC_TX_TIME, "TX_TIME" }, + { MIXSRC_TX_GPS, "TX_GPS" }, + { 0, NULL } +}; +const struct YamlIdStr enum_LogicalSwitchesFunctions[] = { + { LS_FUNC_NONE, "FUNC_NONE" }, + { LS_FUNC_VEQUAL, "FUNC_VEQUAL" }, + { LS_FUNC_VALMOSTEQUAL, "FUNC_VALMOSTEQUAL" }, + { LS_FUNC_VPOS, "FUNC_VPOS" }, + { LS_FUNC_VNEG, "FUNC_VNEG" }, + { LS_FUNC_APOS, "FUNC_APOS" }, + { LS_FUNC_ANEG, "FUNC_ANEG" }, + { LS_FUNC_AND, "FUNC_AND" }, + { LS_FUNC_OR, "FUNC_OR" }, + { LS_FUNC_XOR, "FUNC_XOR" }, + { LS_FUNC_EDGE, "FUNC_EDGE" }, + { LS_FUNC_EQUAL, "FUNC_EQUAL" }, + { LS_FUNC_GREATER, "FUNC_GREATER" }, + { LS_FUNC_LESS, "FUNC_LESS" }, + { LS_FUNC_DIFFEGREATER, "FUNC_DIFFEGREATER" }, + { LS_FUNC_ADIFFEGREATER, "FUNC_ADIFFEGREATER" }, + { LS_FUNC_TIMER, "FUNC_TIMER" }, + { LS_FUNC_STICKY, "FUNC_STICKY" }, + { 0, NULL } +}; +const struct YamlIdStr enum_SwashType[] = { + { SWASH_TYPE_NONE, "TYPE_NONE" }, + { SWASH_TYPE_120, "TYPE_120" }, + { SWASH_TYPE_120X, "TYPE_120X" }, + { SWASH_TYPE_140, "TYPE_140" }, + { SWASH_TYPE_90, "TYPE_90" }, + { 0, NULL } +}; +const struct YamlIdStr enum_SwitchSources[] = { + { SWSRC_NONE, "NONE" }, + { SWSRC_ON, "ON" }, + { SWSRC_ONE, "ONE" }, + { SWSRC_TELEMETRY_STREAMING, "TELEMETRY_STREAMING" }, + { SWSRC_RADIO_ACTIVITY, "RADIO_ACTIVITY" }, + { SWSRC_TRAINER_CONNECTED, "TRAINER_CONNECTED" }, + { SWSRC_OFF, "OFF" }, + { 0, NULL } +}; +const struct YamlIdStr enum_PotsWarnMode[] = { + { POTS_WARN_OFF, "WARN_OFF" }, + { POTS_WARN_MANUAL, "WARN_MANUAL" }, + { POTS_WARN_AUTO, "WARN_AUTO" }, + { 0, NULL } +}; +const struct YamlIdStr enum_ModelOverridableEnable[] = { + { OVERRIDE_GLOBAL, "GLOBAL" }, + { OVERRIDE_OFF, "OFF" }, + { OVERRIDE_ON, "ON" }, + { 0, NULL } +}; +const struct YamlIdStr enum_FailsafeModes[] = { + { FAILSAFE_NOT_SET, "NOT_SET" }, + { FAILSAFE_HOLD, "HOLD" }, + { FAILSAFE_CUSTOM, "CUSTOM" }, + { FAILSAFE_NOPULSES, "NOPULSES" }, + { FAILSAFE_RECEIVER, "RECEIVER" }, + { 0, NULL } +}; +const struct YamlIdStr enum_TelemetrySensorFormula[] = { + { TELEM_FORMULA_ADD, "FORMULA_ADD" }, + { TELEM_FORMULA_AVERAGE, "FORMULA_AVERAGE" }, + { TELEM_FORMULA_MIN, "FORMULA_MIN" }, + { TELEM_FORMULA_MAX, "FORMULA_MAX" }, + { TELEM_FORMULA_MULTIPLY, "FORMULA_MULTIPLY" }, + { TELEM_FORMULA_TOTALIZE, "FORMULA_TOTALIZE" }, + { TELEM_FORMULA_CELL, "FORMULA_CELL" }, + { TELEM_FORMULA_CONSUMPTION, "FORMULA_CONSUMPTION" }, + { TELEM_FORMULA_DIST, "FORMULA_DIST" }, + { 0, NULL } +}; +const struct YamlIdStr enum_TelemetrySensorType[] = { + { TELEM_TYPE_CUSTOM, "TYPE_CUSTOM" }, + { TELEM_TYPE_CALCULATED, "TYPE_CALCULATED" }, + { 0, NULL } +}; +const struct YamlIdStr enum_USBJoystickIfMode[] = { + { USBJOYS_JOYSTICK, "JOYSTICK" }, + { USBJOYS_GAMEPAD, "GAMEPAD" }, + { USBJOYS_MULTIAXIS, "MULTIAXIS" }, + { 0, NULL } +}; +const struct YamlIdStr enum_USBJoystickCh[] = { + { USBJOYS_CH_NONE, "CH_NONE" }, + { USBJOYS_CH_BUTTON, "CH_BUTTON" }, + { USBJOYS_CH_AXIS, "CH_AXIS" }, + { USBJOYS_CH_SIM, "CH_SIM" }, + { 0, NULL } +}; + +// +// Structs last +// + +static const struct YamlNode struct_CalibData[] = { + YAML_IDX_CUST("calib",r_calib,w_calib), + YAML_SIGNED( "mid", 16 ), + YAML_SIGNED( "spanNeg", 16 ), + YAML_SIGNED( "spanPos", 16 ), + YAML_END +}; +static const struct YamlNode struct_signed_16[] = { + YAML_IDX, + YAML_SIGNED( "val", 16 ), + YAML_END +}; +static const struct YamlNode struct_TrainerMix[] = { + YAML_IDX, + YAML_UNSIGNED( "srcChn", 6 ), + YAML_ENUM("mode", 2, enum_TrainerMultiplex), + YAML_SIGNED( "studWeight", 8 ), + YAML_END +}; +static const struct YamlNode struct_TrainerData[] = { + YAML_ARRAY("calib", 16, 4, struct_signed_16, NULL), + YAML_ARRAY("mix", 16, 4, struct_TrainerMix, NULL), + YAML_END +}; +static const struct YamlNode struct_anonymous_1[] = { + YAML_STRING("name", 8), + YAML_END +}; +static const struct YamlNode struct_anonymous_2[] = { + YAML_SIGNED( "val", 16 ), + YAML_UNSIGNED( "mode", 8 ), + YAML_UNSIGNED( "param", 8 ), + YAML_SIGNED( "val2", 32 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_3[] = { + YAML_SIGNED( "val1", 32 ), + YAML_SIGNED( "val2", 32 ), + YAML_END +}; +static const struct YamlNode union_anonymous_0_elmts[] = { + YAML_STRUCT("play", 64, struct_anonymous_1, NULL), + YAML_STRUCT("all", 64, struct_anonymous_2, NULL), + YAML_STRUCT("clear", 64, struct_anonymous_3, NULL), + YAML_END +}; +static const struct YamlNode struct_CustomFunctionData[] = { + YAML_IDX, + YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), + YAML_ENUM("func", 6, enum_Functions), + YAML_CUSTOM("def",r_customFn,w_customFn), + YAML_PADDING( 64 ), + YAML_PADDING( 1 ), + YAML_PADDING( 7 ), + YAML_END +}; +static const struct YamlNode struct_RadioData[] = { + YAML_UNSIGNED( "manuallyEdited", 1 ), + YAML_SIGNED( "timezoneMinutes", 3 ), + YAML_UNSIGNED( "ppmunit", 2 ), + YAML_PADDING( 2 ), + YAML_CUSTOM("semver",nullptr,w_semver), + YAML_CUSTOM("board",nullptr,w_board), + YAML_ARRAY("calib", 48, 12, struct_CalibData, NULL), + YAML_PADDING( 16 ), + YAML_SIGNED( "currModel", 8 ), + YAML_UNSIGNED( "contrast", 8 ), + YAML_UNSIGNED( "vBatWarn", 8 ), + YAML_SIGNED( "txVoltageCalibration", 8 ), + YAML_ENUM("backlightMode", 3, enum_BacklightMode), + YAML_ENUM("antennaMode", 2, enum_AntennaModes), + YAML_UNSIGNED( "disableRtcWarning", 1 ), + YAML_UNSIGNED( "keysBacklight", 1 ), + YAML_UNSIGNED( "dontPlayHello", 1 ), + YAML_ENUM("internalModule", 8, enum_ModuleType), + YAML_STRUCT("trainer", 128, struct_TrainerData, NULL), + YAML_UNSIGNED( "view", 8 ), + YAML_PADDING( 2 ), + YAML_UNSIGNED( "fai", 1 ), + YAML_SIGNED_CUST( "beepMode", 2, r_beeperMode, w_beeperMode ), + YAML_UNSIGNED( "alarmsFlash", 1 ), + YAML_UNSIGNED( "disableMemoryWarning", 1 ), + YAML_UNSIGNED( "disableAlarmWarning", 1 ), + YAML_UNSIGNED( "stickMode", 2 ), + YAML_SIGNED( "timezone", 5 ), + YAML_UNSIGNED( "adjustRTC", 1 ), + YAML_UNSIGNED( "inactivityTimer", 8 ), + YAML_CUSTOM("telemetryBaudrate",r_telemetryBaudrate,nullptr), + YAML_UNSIGNED( "internalModuleBaudrate", 3 ), + YAML_SIGNED( "splashMode", 3 ), + YAML_SIGNED_CUST( "hapticMode", 2, r_beeperMode, w_beeperMode ), + YAML_SIGNED( "switchesDelay", 8 ), + YAML_UNSIGNED( "lightAutoOff", 8 ), + YAML_UNSIGNED( "templateSetup", 8 ), + YAML_SIGNED( "PPM_Multiplier", 8 ), + YAML_SIGNED_CUST( "hapticLength", 8, r_5pos, w_5pos ), + YAML_SIGNED_CUST( "beepLength", 3, r_5pos, w_5pos ), + YAML_SIGNED_CUST( "hapticStrength", 3, r_5pos, w_5pos ), + YAML_UNSIGNED( "gpsFormat", 1 ), + YAML_UNSIGNED( "audioMuteEnable", 1 ), + YAML_UNSIGNED_CUST( "speakerPitch", 8, r_spPitch, w_spPitch ), + YAML_SIGNED_CUST( "speakerVolume", 8, r_vol, w_vol ), + YAML_SIGNED_CUST( "vBatMin", 8, r_vbat_min, w_vbat_min ), + YAML_SIGNED_CUST( "vBatMax", 8, r_vbat_max, w_vbat_max ), + YAML_UNSIGNED( "backlightBright", 8 ), + YAML_UNSIGNED( "globalTimer", 32 ), + YAML_UNSIGNED( "bluetoothBaudrate", 4 ), + YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes), + YAML_UNSIGNED( "countryCode", 2 ), + YAML_SIGNED( "pwrOnSpeed", 3 ), + YAML_SIGNED( "pwrOffSpeed", 3 ), + YAML_CUSTOM("jitterFilter",r_jitterFilter,nullptr), + YAML_UNSIGNED( "noJitterFilter", 1 ), + YAML_UNSIGNED( "imperial", 1 ), + YAML_UNSIGNED( "disableRssiPoweroffAlarm", 1 ), + YAML_UNSIGNED( "USBMode", 2 ), + YAML_UNSIGNED( "jackMode", 2 ), + YAML_PADDING( 1 ), + YAML_STRING("ttsLanguage", 2), + YAML_SIGNED_CUST( "beepVolume", 4, r_5pos, w_5pos ), + YAML_SIGNED_CUST( "wavVolume", 4, r_5pos, w_5pos ), + YAML_SIGNED_CUST( "varioVolume", 4, r_5pos, w_5pos ), + YAML_SIGNED_CUST( "backgroundVolume", 4, r_5pos, w_5pos ), + YAML_SIGNED_CUST( "varioPitch", 8, r_vPitch, w_vPitch ), + YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), + YAML_SIGNED( "varioRepeat", 8 ), + YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), + YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr), + YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr), + YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr), + YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid), + YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr), + YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr), + YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr), + YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid), + YAML_UNSIGNED( "backlightColor", 8 ), + YAML_STRING("bluetoothName", 10), + YAML_STRING("ownerRegistrationID", 8), + YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr), + YAML_UNSIGNED( "rotEncMode", 3 ), + YAML_SIGNED( "uartSampleMode", 2 ), + YAML_PADDING( 3 ), + YAML_UNSIGNED( "radioGFDisabled", 1 ), + YAML_UNSIGNED( "radioTrainerDisabled", 1 ), + YAML_UNSIGNED( "modelHeliDisabled", 1 ), + YAML_UNSIGNED( "modelFMDisabled", 1 ), + YAML_UNSIGNED( "modelCurvesDisabled", 1 ), + YAML_UNSIGNED( "modelGVDisabled", 1 ), + YAML_UNSIGNED( "modelLSDisabled", 1 ), + YAML_UNSIGNED( "modelSFDisabled", 1 ), + YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ), + YAML_UNSIGNED( "modelTelemetryDisabled", 1 ), + YAML_UNSIGNED( "disableTrainerPoweroffAlarm", 1 ), + YAML_UNSIGNED( "disablePwrOnOffHaptic", 1 ), + YAML_UNSIGNED( "invertLCD", 1 ), + YAML_PADDING( 3 ), + YAML_UNSIGNED( "pwrOffIfInactive", 8 ), + YAML_END +}; +static const struct YamlNode struct_unsigned_8[] = { + YAML_IDX, + YAML_UNSIGNED( "val", 8 ), + YAML_END +}; +static const struct YamlNode struct_ModelHeader[] = { + YAML_STRING("name", 10), + YAML_ARRAY("modelId", 8, 2, struct_unsigned_8, NULL), + YAML_END +}; +static const struct YamlNode struct_TimerData[] = { + YAML_IDX, + YAML_UNSIGNED( "start", 22 ), + YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), + YAML_SIGNED( "value", 22 ), + YAML_ENUM("mode", 3, enum_TimerModes), + YAML_UNSIGNED( "countdownBeep", 2 ), + YAML_UNSIGNED( "minuteBeep", 1 ), + YAML_UNSIGNED( "persistent", 2 ), + YAML_SIGNED( "countdownStart", 2 ), + YAML_UNSIGNED( "showElapsed", 1 ), + YAML_UNSIGNED( "extraHaptic", 1 ), + YAML_PADDING( 6 ), + YAML_STRING("name", 3), + YAML_END +}; +static const struct YamlNode struct_CurveRef[] = { + YAML_UNSIGNED( "type", 5 ), + YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ), + YAML_END +}; +static const struct YamlNode struct_MixData[] = { + YAML_UNSIGNED( "destCh", 5 ), + YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ), + YAML_UNSIGNED( "carryTrim", 1 ), + YAML_UNSIGNED( "mixWarn", 2 ), + YAML_ENUM("mltpx", 2, enum_MixerMultiplex), + YAML_UNSIGNED( "delayPrec", 1 ), + YAML_UNSIGNED( "speedPrec", 1 ), + YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), + YAML_PADDING( 1 ), + YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), + YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), + YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), + YAML_STRUCT("curve", 16, struct_CurveRef, NULL), + YAML_UNSIGNED( "delayUp", 8 ), + YAML_UNSIGNED( "delayDown", 8 ), + YAML_UNSIGNED( "speedUp", 8 ), + YAML_UNSIGNED( "speedDown", 8 ), + YAML_STRING("name", 6), + YAML_END +}; +static const struct YamlNode struct_LimitData[] = { + YAML_IDX, + YAML_SIGNED_CUST( "min", 11, in_read_weight, in_write_weight ), + YAML_SIGNED_CUST( "max", 11, in_read_weight, in_write_weight ), + YAML_SIGNED( "ppmCenter", 10 ), + YAML_SIGNED_CUST( "offset", 11, in_read_weight, in_write_weight ), + YAML_UNSIGNED( "symetrical", 1 ), + YAML_UNSIGNED( "revert", 1 ), + YAML_PADDING( 3 ), + YAML_SIGNED( "curve", 8 ), + YAML_STRING("name", 4), + YAML_END +}; +static const struct YamlNode struct_ExpoData[] = { + YAML_UNSIGNED( "mode", 2 ), + YAML_UNSIGNED( "scale", 14 ), + YAML_CUSTOM("carryTrim",r_carryTrim,nullptr), + YAML_SIGNED( "trimSource", 6 ), + YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ), + YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), + YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), + YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), + YAML_STRUCT("curve", 16, struct_CurveRef, NULL), + YAML_UNSIGNED( "chn", 5 ), + YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), + YAML_PADDING( 2 ), + YAML_STRING("name", 6), + YAML_END +}; +static const struct YamlNode struct_CurveHeader[] = { + YAML_IDX, + YAML_UNSIGNED( "type", 1 ), + YAML_UNSIGNED( "smooth", 1 ), + YAML_SIGNED( "points", 6 ), + YAML_STRING("name", 3), + YAML_END +}; +static const struct YamlNode struct_signed_8[] = { + YAML_IDX, + YAML_SIGNED( "val", 8 ), + YAML_END +}; +static const struct YamlNode struct_LogicalSwitchData[] = { + YAML_IDX, + YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions), + YAML_CUSTOM("def",r_logicSw,w_logicSw), + YAML_PADDING( 10 ), + YAML_PADDING( 10 ), + YAML_SIGNED_CUST( "andsw", 10, r_swtchSrc, w_swtchSrc ), + YAML_UNSIGNED( "lsPersist", 1 ), + YAML_UNSIGNED( "lsState", 1 ), + YAML_PADDING( 16 ), + YAML_UNSIGNED( "delay", 8 ), + YAML_UNSIGNED( "duration", 8 ), + YAML_END +}; +static const struct YamlNode struct_SwashRingData[] = { + YAML_ENUM("type", 8, enum_SwashType), + YAML_UNSIGNED( "value", 8 ), + YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ), + YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ), + YAML_UNSIGNED_CUST( "elevatorSource", 8, r_mixSrcRaw, w_mixSrcRaw ), + YAML_SIGNED( "collectiveWeight", 8 ), + YAML_SIGNED( "aileronWeight", 8 ), + YAML_SIGNED( "elevatorWeight", 8 ), + YAML_END +}; +static const struct YamlNode struct_trim_t[] = { + YAML_IDX, + YAML_SIGNED( "value", 11 ), + YAML_UNSIGNED( "mode", 5 ), + YAML_END +}; +static const struct YamlNode struct_FlightModeData[] = { + YAML_IDX, + YAML_ARRAY("trim", 16, 6, struct_trim_t, NULL), + YAML_STRING("name", 6), + YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), + YAML_PADDING( 6 ), + YAML_UNSIGNED( "fadeIn", 8 ), + YAML_UNSIGNED( "fadeOut", 8 ), + YAML_ARRAY("gvars", 16, 9, struct_signed_16, gvar_is_active), + YAML_END +}; +static const struct YamlNode struct_GVarData[] = { + YAML_IDX, + YAML_STRING("name", 3), + YAML_UNSIGNED( "min", 12 ), + YAML_UNSIGNED( "max", 12 ), + YAML_UNSIGNED( "popup", 1 ), + YAML_UNSIGNED( "prec", 1 ), + YAML_UNSIGNED( "unit", 2 ), + YAML_PADDING( 4 ), + YAML_END +}; +static const struct YamlNode struct_VarioData[] = { + YAML_UNSIGNED_CUST( "source", 7, r_tele_sensor, w_tele_sensor ), + YAML_UNSIGNED( "centerSilent", 1 ), + YAML_SIGNED( "centerMax", 8 ), + YAML_SIGNED( "centerMin", 8 ), + YAML_SIGNED( "min", 8 ), + YAML_SIGNED( "max", 8 ), + YAML_END +}; +static const struct YamlNode struct_RssiAlarmData[] = { + YAML_CUSTOM("disabled",r_rssiDisabled,nullptr), + YAML_CUSTOM("warning",r_rssiWarning,nullptr), + YAML_CUSTOM("critical",r_rssiCritical,nullptr), + YAML_END +}; +static const struct YamlNode struct_RFAlarmData[] = { + YAML_SIGNED( "warning", 8 ), + YAML_SIGNED( "critical", 8 ), + YAML_END +}; +static const struct YamlNode struct_PpmModule[] = { + YAML_SIGNED( "delay", 6 ), + YAML_UNSIGNED( "pulsePol", 1 ), + YAML_UNSIGNED( "outputType", 1 ), + YAML_SIGNED( "frameLength", 8 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_5[] = { + YAML_PADDING( 8 ), + YAML_UNSIGNED( "disableTelemetry", 1 ), + YAML_UNSIGNED( "disableMapping", 1 ), + YAML_UNSIGNED( "autoBindMode", 1 ), + YAML_UNSIGNED( "lowPowerMode", 1 ), + YAML_UNSIGNED( "receiverTelemetryOff", 1 ), + YAML_UNSIGNED( "receiverHigherChannels", 1 ), + YAML_PADDING( 2 ), + YAML_SIGNED( "optionValue", 8 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_6[] = { + YAML_UNSIGNED( "power", 2 ), + YAML_PADDING( 2 ), + YAML_UNSIGNED( "receiverTelemetryOff", 1 ), + YAML_UNSIGNED( "receiverHigherChannels", 1 ), + YAML_SIGNED( "antennaMode", 2 ), + YAML_PADDING( 8 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_7[] = { + YAML_PADDING( 6 ), + YAML_UNSIGNED( "noninverted", 1 ), + YAML_PADDING( 1 ), + YAML_SIGNED( "refreshRate", 8 ), + YAML_END +}; +static const struct YamlNode struct_string_64[] = { + YAML_IDX, + YAML_STRING("val", 8), + YAML_END +}; +static const struct YamlNode struct_anonymous_8[] = { + YAML_UNSIGNED( "receivers", 7 ), + YAML_UNSIGNED( "racingMode", 1 ), + YAML_ARRAY("receiverName", 64, 3, struct_string_64, NULL), + YAML_END +}; +static const struct YamlNode struct_anonymous_9[] = { + YAML_ARRAY("rx_id", 8, 4, struct_unsigned_8, NULL), + YAML_UNSIGNED( "mode", 3 ), + YAML_UNSIGNED( "rfPower", 1 ), + YAML_UNSIGNED( "reserved", 4 ), + YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL), + YAML_END +}; +static const struct YamlNode struct_anonymous_10[] = { + YAML_UNSIGNED( "emi", 2 ), + YAML_UNSIGNED( "telemetry", 1 ), + YAML_UNSIGNED( "phyMode", 3 ), + YAML_UNSIGNED( "reserved", 2 ), + YAML_UNSIGNED( "rfPower", 8 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_11[] = { + YAML_UNSIGNED( "raw12bits", 1 ), + YAML_UNSIGNED( "telemetryBaudrate", 3 ), + YAML_PADDING( 4 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_12[] = { + YAML_UNSIGNED( "telemetryBaudrate", 3 ), + YAML_UNSIGNED( "crsfArmingMode", 1 ), + YAML_PADDING( 4 ), + YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), + YAML_SIGNED( "spare3", 6 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_13[] = { + YAML_UNSIGNED( "flags", 8 ), + YAML_END +}; +static const struct YamlNode union_anonymous_4_elmts[] = { + YAML_ARRAY("raw", 8, 25, struct_unsigned_8, NULL), + YAML_STRUCT("ppm", 16, struct_PpmModule, NULL), + YAML_STRUCT("multi", 24, struct_anonymous_5, NULL), + YAML_STRUCT("pxx", 16, struct_anonymous_6, NULL), + YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL), + YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL), + YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL), + YAML_STRUCT("afhds3", 16, struct_anonymous_10, NULL), + YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL), + YAML_STRUCT("crsf", 24, struct_anonymous_12, NULL), + YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL), + YAML_END +}; +static const struct YamlNode struct_ModuleData[] = { + YAML_IDX, + YAML_UNSIGNED_CUST( "type", 8, r_moduleType, w_moduleType ), + YAML_CUSTOM("subType",r_modSubtype,w_modSubtype), + YAML_UNSIGNED( "channelsStart", 8 ), + YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ), + YAML_ENUM("failsafeMode", 4, enum_FailsafeModes), + YAML_PADDING( 4 ), + YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type), + YAML_END +}; +static const struct YamlNode struct_TrainerModuleData[] = { + YAML_UNSIGNED_CUST( "mode", 8, r_trainerMode, w_trainerMode ), + YAML_UNSIGNED( "channelsStart", 8 ), + YAML_SIGNED( "channelsCount", 8 ), + YAML_SIGNED( "frameLength", 8 ), + YAML_SIGNED( "delay", 6 ), + YAML_UNSIGNED( "pulsePol", 1 ), + YAML_PADDING( 1 ), + YAML_END +}; +static const struct YamlNode union_ScriptDataInput_elmts[] = { + YAML_SIGNED( "value", 16 ), + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), + YAML_END +}; +static const struct YamlNode union_ScriptDataInput[] = { + YAML_IDX, + YAML_UNION("u", 16, union_ScriptDataInput_elmts, select_script_input), + YAML_END +}; +static const struct YamlNode struct_ScriptData[] = { + YAML_IDX, + YAML_STRING("file", 6), + YAML_STRING("name", 6), + YAML_ARRAY("inputs", 16, 6, union_ScriptDataInput, NULL), + YAML_END +}; +static const struct YamlNode struct_string_24[] = { + YAML_IDX, + YAML_STRING("val", 3), + YAML_END +}; +static const struct YamlNode union_anonymous_14_elmts[] = { + YAML_UNSIGNED( "id", 16 ), + YAML_UNSIGNED( "persistentValue", 16 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_16[] = { + YAML_UNSIGNED( "physID", 5 ), + YAML_UNSIGNED( "rxIndex", 3 ), + YAML_END +}; +static const struct YamlNode union_anonymous_15_elmts[] = { + YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL), + YAML_UNSIGNED( "instance", 8 ), + YAML_ENUM("formula", 8, enum_TelemetrySensorFormula), + YAML_END +}; +static const struct YamlNode struct_anonymous_18[] = { + YAML_UNSIGNED( "ratio", 16 ), + YAML_SIGNED( "offset", 16 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_19[] = { + YAML_UNSIGNED( "source", 8 ), + YAML_UNSIGNED( "index", 8 ), + YAML_PADDING( 16 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_20[] = { + YAML_ARRAY("sources", 8, 4, struct_signed_8, NULL), + YAML_END +}; +static const struct YamlNode struct_anonymous_21[] = { + YAML_UNSIGNED( "source", 8 ), + YAML_PADDING( 24 ), + YAML_END +}; +static const struct YamlNode struct_anonymous_22[] = { + YAML_UNSIGNED( "gps", 8 ), + YAML_UNSIGNED( "alt", 8 ), + YAML_PADDING( 16 ), + YAML_END +}; +static const struct YamlNode union_anonymous_17_elmts[] = { + YAML_STRUCT("custom", 32, struct_anonymous_18, NULL), + YAML_STRUCT("cell", 32, struct_anonymous_19, NULL), + YAML_STRUCT("calc", 32, struct_anonymous_20, NULL), + YAML_STRUCT("consumption", 32, struct_anonymous_21, NULL), + YAML_STRUCT("dist", 32, struct_anonymous_22, NULL), + YAML_UNSIGNED( "param", 32 ), + YAML_END +}; +static const struct YamlNode struct_TelemetrySensor[] = { + YAML_IDX, + YAML_UNION("id1", 16, union_anonymous_14_elmts, select_id1), + YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2), + YAML_STRING("label", 4), + YAML_UNSIGNED( "subId", 8 ), + YAML_ENUM("type", 1, enum_TelemetrySensorType), + YAML_PADDING( 1 ), + YAML_UNSIGNED( "unit", 6 ), + YAML_UNSIGNED( "prec", 2 ), + YAML_UNSIGNED( "autoOffset", 1 ), + YAML_UNSIGNED( "filter", 1 ), + YAML_UNSIGNED( "logs", 1 ), + YAML_UNSIGNED( "persistent", 1 ), + YAML_UNSIGNED( "onlyPositive", 1 ), + YAML_PADDING( 1 ), + YAML_UNION("cfg", 32, union_anonymous_17_elmts, select_sensor_cfg), + YAML_END +}; +static const struct YamlNode struct_FrSkyBarData[] = { + YAML_IDX, + YAML_UNSIGNED_CUST( "source", 16, r_mixSrcRaw, w_mixSrcRaw ), + YAML_SIGNED( "barMin", 16 ), + YAML_SIGNED( "barMax", 16 ), + YAML_END +}; +static const struct YamlNode struct_LineDataSource[] = { + YAML_IDX, + YAML_UNSIGNED_CUST( "val", 16, r_mixSrcRaw, w_mixSrcRaw ), + YAML_END +}; +static const struct YamlNode struct_FrSkyLineData[] = { + YAML_IDX, + YAML_ARRAY("sources", 16, 2, struct_LineDataSource, NULL), + YAML_END +}; +static const struct YamlNode struct_TelemetryScriptData[] = { + YAML_STRING("file", 6), + YAML_ARRAY("inputs", 16, 8, struct_signed_16, NULL), + YAML_END +}; +static const struct YamlNode union_TelemetryScreenData_u_elmts[] = { + YAML_ARRAY("bars", 48, 4, struct_FrSkyBarData, NULL), + YAML_ARRAY("lines", 32, 4, struct_FrSkyLineData, NULL), + YAML_STRUCT("script", 176, struct_TelemetryScriptData, NULL), + YAML_END +}; +static const struct YamlNode struct_TelemetryScreenData[] = { + YAML_IDX, + YAML_CUSTOM("type",r_tele_screen_type,w_tele_screen_type), + YAML_UNION("u", 192, union_TelemetryScreenData_u_elmts, select_tele_screen_data), + YAML_END +}; +static const struct YamlNode struct_RGBLedColor[] = { + YAML_IDX, + YAML_UNSIGNED( "r", 8 ), + YAML_UNSIGNED( "g", 8 ), + YAML_UNSIGNED( "b", 8 ), + YAML_END +}; +static const struct YamlNode struct_USBJoystickChData[] = { + YAML_IDX, + YAML_ENUM("mode", 3, enum_USBJoystickCh), + YAML_UNSIGNED( "inversion", 1 ), + YAML_UNSIGNED( "param", 4 ), + YAML_UNSIGNED( "btn_num", 5 ), + YAML_UNSIGNED( "switch_npos", 3 ), + YAML_END +}; +static const struct YamlNode struct_ModelData[] = { + YAML_CUSTOM("semver",nullptr,w_semver), + YAML_STRUCT("header", 96, struct_ModelHeader, NULL), + YAML_ARRAY("timers", 96, 3, struct_TimerData, NULL), + YAML_UNSIGNED( "telemetryProtocol", 3 ), + YAML_UNSIGNED( "thrTrim", 1 ), + YAML_UNSIGNED( "noGlobalFunctions", 1 ), + YAML_UNSIGNED( "displayTrims", 2 ), + YAML_UNSIGNED( "ignoreSensorIds", 1 ), + YAML_SIGNED( "trimInc", 3 ), + YAML_UNSIGNED( "disableThrottleWarning", 1 ), + YAML_UNSIGNED( "displayChecklist", 1 ), + YAML_UNSIGNED( "extendedLimits", 1 ), + YAML_UNSIGNED( "extendedTrims", 1 ), + YAML_UNSIGNED( "throttleReversed", 1 ), + YAML_UNSIGNED( "enableCustomThrottleWarning", 1 ), + YAML_UNSIGNED( "disableTelemetryWarning", 1 ), + YAML_UNSIGNED( "showInstanceIds", 1 ), + YAML_UNSIGNED( "checklistInteractive", 1 ), + YAML_PADDING( 4 ), + YAML_SIGNED( "customThrottleWarningPosition", 8 ), + YAML_UNSIGNED( "beepANACenter", 16 ), + YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), + YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), + YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL), + YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL), + YAML_ARRAY("points", 8, 512, struct_signed_8, NULL), + YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL), + YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), + YAML_STRUCT("swashR", 64, struct_SwashRingData, swash_is_active), + YAML_ARRAY("flightModeData", 320, 9, struct_FlightModeData, fmd_is_active), + YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ), + YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr), + YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr), + YAML_PADDING(1), + YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL), + YAML_STRUCT("varioData", 40, struct_VarioData, NULL), + YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ), + YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL), + YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL), + YAML_UNSIGNED( "thrTrimSw", 3 ), + YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode), + YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable), + YAML_PADDING( 1 ), + YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL), + YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL), + YAML_STRUCT("trainerData", 40, struct_TrainerModuleData, NULL), + YAML_ARRAY("scriptsData", 192, 7, struct_ScriptData, NULL), + YAML_ARRAY("inputNames", 24, 32, struct_string_24, NULL), + YAML_UNSIGNED( "potsWarnEnabled", 8 ), + YAML_ARRAY("potsWarnPosition", 8, 8, struct_signed_8, NULL), + YAML_ARRAY("telemetrySensors", 112, 40, struct_TelemetrySensor, NULL), + YAML_PADDING( 8 ), + YAML_ARRAY("screens", 192, 4, struct_TelemetryScreenData, NULL), + YAML_UNSIGNED( "view", 8 ), + YAML_STRING("modelRegistrationID", 8), + YAML_UNSIGNED( "functionSwitchConfig", 16 ), + YAML_UNSIGNED( "functionSwitchGroup", 16 ), + YAML_UNSIGNED( "functionSwitchStartConfig", 16 ), + YAML_UNSIGNED( "functionSwitchLogicalState", 8 ), + YAML_ARRAY("switchNames", 24, 6, struct_string_24, NULL), + YAML_ARRAY("functionSwitchLedONColor", 24, 6, struct_RGBLedColor, NULL), + YAML_ARRAY("functionSwitchLedOFFColor", 24, 6, struct_RGBLedColor, NULL), + YAML_UNSIGNED( "usbJoystickExtMode", 1 ), + YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode), + YAML_UNSIGNED( "usbJoystickCircularCut", 4 ), + YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL), + YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable), + YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable), + YAML_END +}; +static const struct YamlNode struct_PartialModel[] = { + YAML_STRUCT("header", 96, struct_ModelHeader, NULL), + YAML_ARRAY("timers", 96, 3, struct_TimerData, NULL), + YAML_END +}; + +#define MAX_RADIODATA_MODELDATA_PARTIALMODEL_STR_LEN 29 + +static const struct YamlNode __RadioData_root_node = YAML_ROOT( struct_RadioData ); + +const YamlNode* get_radiodata_nodes() +{ + return &__RadioData_root_node; +} +static const struct YamlNode __ModelData_root_node = YAML_ROOT( struct_ModelData ); + +const YamlNode* get_modeldata_nodes() +{ + return &__ModelData_root_node; +} +static const struct YamlNode __PartialModel_root_node = YAML_ROOT( struct_PartialModel ); + +const YamlNode* get_partialmodel_nodes() +{ + return &__PartialModel_root_node; +} + diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 130b786595d..91d5f52647d 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -630,7 +630,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_pl18.cpp b/radio/src/storage/yaml/yaml_datastructs_pl18.cpp index e9721f26878..ee4a54f657c 100644 --- a/radio/src/storage/yaml/yaml_datastructs_pl18.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_pl18.cpp @@ -630,7 +630,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_t15.cpp b/radio/src/storage/yaml/yaml_datastructs_t15.cpp index 4077e97505e..0ac5f7771ed 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t15.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t15.cpp @@ -633,7 +633,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_t20.cpp b/radio/src/storage/yaml/yaml_datastructs_t20.cpp index 33b993a7f66..0727d42ed40 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t20.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t20.cpp @@ -606,7 +606,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp index 2ba8d2f0cc9..cef905287d2 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp @@ -606,7 +606,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x10.cpp b/radio/src/storage/yaml/yaml_datastructs_x10.cpp index c4bedbafe5a..f45ca1160ec 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x10.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x10.cpp @@ -632,7 +632,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp index 3252922cd86..925f5a22d15 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp @@ -604,7 +604,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9dp2019.cpp b/radio/src/storage/yaml/yaml_datastructs_x9dp2019.cpp index b75f96910f7..34a657a0a74 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9dp2019.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9dp2019.cpp @@ -605,7 +605,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp index 5fd70f965ef..dd1e1afe572 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp @@ -605,7 +605,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_xlite.cpp b/radio/src/storage/yaml/yaml_datastructs_xlite.cpp index 6fd277c58e5..6fa9cee5af7 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlite.cpp @@ -604,7 +604,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp index 67dfc96ba20..11d5bec5712 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp @@ -608,7 +608,7 @@ static const struct YamlNode struct_anonymous_12[] = { YAML_UNSIGNED( "crsfArmingMode", 1 ), YAML_PADDING( 4 ), YAML_SIGNED_CUST( "crsfArmingTrigger", 10, r_swtchSrc, w_swtchSrc ), - YAML_PADDING( 6 ), + YAML_SIGNED( "spare3", 6 ), YAML_END }; static const struct YamlNode struct_anonymous_13[] = { diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index 10a2eee0279..54cf712639b 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -21,6 +21,7 @@ #include "hal/switch_driver.h" #include "hal/adc_driver.h" +#include "hal/rgbleds.h" #include "myeeprom.h" #include "edgetx.h" @@ -168,7 +169,7 @@ void evalFunctionSwitches() uint8_t fct_switches = switchGetMaxFctSwitches(); for (uint8_t i = 0; i < fct_switches; i++) { if (FSWITCH_CONFIG(i) == SWITCH_NONE) { - fsLedOff(i); + setFSLedOFF(i); continue; } @@ -202,9 +203,9 @@ void evalFunctionSwitches() if (!pwrPressed()) { if (getFSLogicalState(i)) - fsLedOn(i); + setFSLedON(i); else - fsLedOff(i); + setFSLedOFF(i); } } } diff --git a/radio/src/switches.h b/radio/src/switches.h index 59020d4fc14..4f49e65ebda 100644 --- a/radio/src/switches.h +++ b/radio/src/switches.h @@ -106,5 +106,7 @@ extern uint8_t functionSwitchFunctionState; //led_driver.cpp void fsLedOff(uint8_t); void fsLedOn(uint8_t); -bool getFSLedState(uint8_t index); +bool fsLedState(uint8_t index); +void fsLedRGB(uint8_t, uint32_t color); +uint8_t getRGBColorIndex(uint32_t color); #endif diff --git a/radio/src/targets/common/arm/stm32/flysky_gimbal_driver.cpp b/radio/src/targets/common/arm/stm32/flysky_gimbal_driver.cpp index f03dcb886a0..7014f064b7b 100644 --- a/radio/src/targets/common/arm/stm32/flysky_gimbal_driver.cpp +++ b/radio/src/targets/common/arm/stm32/flysky_gimbal_driver.cpp @@ -35,10 +35,10 @@ static const stm32_usart_t fsUSART = { .USARTx = FLYSKY_HALL_SERIAL_USART, - .txGPIO = GPIO_UNDEF, + .txGPIO = FLYSKY_HALL_SERIAL_TX_GPIO, .rxGPIO = FLYSKY_HALL_SERIAL_RX_GPIO, .IRQn = FLYSKY_HALL_SERIAL_USART_IRQn, - .IRQ_Prio = 6, + .IRQ_Prio = 4, .txDMA = nullptr, .txDMA_Stream = 0, .txDMA_Channel = 0, @@ -49,6 +49,13 @@ static const stm32_usart_t fsUSART = { DEFINE_STM32_SERIAL_PORT(FSGimbal, fsUSART, HALLSTICK_BUFF_SIZE, 0); +static const etx_serial_port_t _fs_gimbal_serial_port = { + .name = "gimbals", + .uart = &STM32SerialDriver, + .hw_def = REF_STM32_SERIAL_PORT(FSGimbal), + .set_pwr = nullptr, +}; + static STRUCT_HALL HallProtocol = { 0 }; static void* _fs_usart_ctx = nullptr; @@ -150,7 +157,7 @@ static void flysky_gimbal_loop(void*) } } -static void flysky_gimbal_deinit() +void flysky_gimbal_deinit() { STM32SerialDriver.deinit(_fs_usart_ctx); } @@ -181,3 +188,8 @@ bool flysky_gimbal_init() flysky_gimbal_deinit(); return false; } + +const etx_serial_port_t* flysky_gimbal_get_port() +{ + return &_fs_gimbal_serial_port; +} diff --git a/radio/src/targets/common/arm/stm32/flysky_gimbal_driver.h b/radio/src/targets/common/arm/stm32/flysky_gimbal_driver.h index dd3fdabb42d..88f01effb81 100644 --- a/radio/src/targets/common/arm/stm32/flysky_gimbal_driver.h +++ b/radio/src/targets/common/arm/stm32/flysky_gimbal_driver.h @@ -18,6 +18,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ + +#pragma once + +#include "hal/serial_port.h" #define HALLSTICK_BUFF_SIZE ( 512 ) #define FLYSKY_HALL_BAUDRATE ( 921600 ) @@ -124,3 +128,5 @@ extern unsigned short hall_adc_values[FLYSKY_HALL_CHANNEL_COUNT]; // returns true if the gimbals were detected properly bool flysky_gimbal_init(); +void flysky_gimbal_deinit(); +const etx_serial_port_t* flysky_gimbal_get_port(); diff --git a/radio/src/targets/common/arm/stm32/stm32_gpio.h b/radio/src/targets/common/arm/stm32/stm32_gpio.h index a36675064a4..9a95aa95080 100644 --- a/radio/src/targets/common/arm/stm32/stm32_gpio.h +++ b/radio/src/targets/common/arm/stm32/stm32_gpio.h @@ -27,7 +27,7 @@ #define GPIO_UNDEF (0xffffffff) // #define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y) -#define GPIO_PIN(x, y) ((intptr_t)x | y) +#define GPIO_PIN(x, y) ((uintptr_t)x | y) // Generate GPIO mode bitfields // diff --git a/radio/src/targets/common/arm/stm32/stm32_ws2812.cpp b/radio/src/targets/common/arm/stm32/stm32_ws2812.cpp index 15b11c3f34e..b0eca0e9ac3 100644 --- a/radio/src/targets/common/arm/stm32/stm32_ws2812.cpp +++ b/radio/src/targets/common/arm/stm32/stm32_ws2812.cpp @@ -231,6 +231,22 @@ void ws2812_set_color(uint8_t led, uint8_t r, uint8_t g, uint8_t b) pixel[_b_offset] = b; } +uint32_t ws2812_get_color(uint8_t led) +{ + if (led >= _led_strip_len) return 0; + + uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED]; + return (pixel[1] << 16) + (pixel[0] << 8) + pixel[2]; +} + +bool ws2812_get_state(uint8_t led) +{ + if (led >= _led_strip_len) return false; + + uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED]; + return pixel[0] || pixel[1] || pixel[2]; +} + void ws2812_update(const stm32_pulse_timer_t* tim) { WS2812_DBG_HIGH; diff --git a/radio/src/targets/common/arm/stm32/stm32_ws2812.h b/radio/src/targets/common/arm/stm32/stm32_ws2812.h index d993ea5856f..5131b4ee0c8 100644 --- a/radio/src/targets/common/arm/stm32/stm32_ws2812.h +++ b/radio/src/targets/common/arm/stm32/stm32_ws2812.h @@ -42,6 +42,8 @@ void ws2812_init(const stm32_pulse_timer_t* timer, uint8_t strip_len, uint8_t type); void ws2812_update(const stm32_pulse_timer_t* timer); +bool ws2812_get_state(uint8_t led); void ws2812_dma_isr(const stm32_pulse_timer_t* timer); void ws2812_set_color(uint8_t led, uint8_t r, uint8_t g, uint8_t b); +uint32_t ws2812_get_color(uint8_t led); diff --git a/radio/src/targets/horus/board.cpp b/radio/src/targets/horus/board.cpp index 826ee25e725..45d9fd19f68 100644 --- a/radio/src/targets/horus/board.cpp +++ b/radio/src/targets/horus/board.cpp @@ -30,6 +30,7 @@ #include "hal/rotary_encoder.h" #include "hal/usb_driver.h" #include "hal/gpio.h" +#include "hal/rgbleds.h" #include "board.h" #include "boards/generic_stm32/module_ports.h" @@ -127,7 +128,7 @@ void boardInit() board_set_bor_level(); #endif -#if defined(FUNCTION_SWITCHES) && !defined(DEBUG) +#if defined(MANUFACTURER_JUMPER) && defined(FUNCTION_SWITCHES) && !defined(DEBUG) // This is needed to prevent radio from starting when usb is plugged to charge usbInit(); // prime debounce state... diff --git a/radio/src/targets/horus/led_driver.cpp b/radio/src/targets/horus/led_driver.cpp index 53eca1ba531..643f97ea92c 100644 --- a/radio/src/targets/horus/led_driver.cpp +++ b/radio/src/targets/horus/led_driver.cpp @@ -21,8 +21,9 @@ #include "hal/gpio.h" #include "stm32_gpio.h" - +#include "boards/generic_stm32/rgb_leds.h" #include "board.h" +#include "colors.h" void ledInit() { @@ -39,7 +40,7 @@ void ledInit() gpio_init(LED_BLUE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW); #endif -#if defined(FUNCTION_SWITCHES) +#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS) gpio_init(FSLED_GPIO_1, GPIO_OUT, GPIO_PIN_SPEED_LOW); gpio_init(FSLED_GPIO_2, GPIO_OUT, GPIO_PIN_SPEED_LOW); gpio_init(FSLED_GPIO_3, GPIO_OUT, GPIO_PIN_SPEED_LOW); @@ -50,7 +51,23 @@ void ledInit() } -#if defined(FUNCTION_SWITCHES) +#if defined(FUNCTION_SWITCHES_RGB_LEDS) +// used to map switch number to led number in the rgbled chain +uint8_t ledMapping[] = {1, 2, 3, 4, 5, 6}; + +void fsLedOff(uint8_t index, uint32_t color) +{ + rgbSetLedColor(ledMapping[index], GET_RED(color), \ + GET_GREEN(color),GET_BLUE(color)); +} + +void fsLedOn(uint8_t index, uint32_t color) +{ + rgbSetLedColor(ledMapping[index], GET_RED(color), \ + GET_GREEN(color),GET_BLUE(color)); +} + +#elif defined(FUNCTION_SWITCHES) gpio_t fsLeds[] = {FSLED_GPIO_1, FSLED_GPIO_2, FSLED_GPIO_3, FSLED_GPIO_4, FSLED_GPIO_5, FSLED_GPIO_6}; @@ -65,7 +82,7 @@ void fsLedOn(uint8_t index) gpio_set(fsLeds[index]); } -bool getFSLedState(uint8_t index) +bool fsLedState(uint8_t index) { return (gpio_read(fsLeds[index])); } diff --git a/radio/src/targets/simu/led_driver.cpp b/radio/src/targets/simu/led_driver.cpp index 3596fdd0278..e48faf35fcb 100644 --- a/radio/src/targets/simu/led_driver.cpp +++ b/radio/src/targets/simu/led_driver.cpp @@ -20,6 +20,7 @@ */ #include +#include "hal/rgbleds.h" bool usbChargerLed() { return true; } void ledRed() {} @@ -28,6 +29,33 @@ void ledBlue() {} void ledOff() {} void fsLedOn(uint8_t) {} void fsLedOff(uint8_t) {} -bool getFSLedState(uint8_t) { return false;} +void fsLedRGB(uint8_t, uint32_t) {} +bool fsLedState(uint8_t) { return false;} void rgbSetLedColor(unsigned char, unsigned char, unsigned char, unsigned char) {} void rgbLedColorApply() {} + +uint8_t getRGBColorIndex(uint32_t color) +{ + for (uint8_t i = 0; i < (sizeof(colorTable) / sizeof(colorTable[0])); i++) { + if (color == colorTable[i]) + return(i); + } + return 5; // Custom value set with Companion +} + +// RGB +#define WS2812_BYTES_PER_LED 3 + +// Maximum number of supported LEDs +#if !defined(WS2812_MAX_LEDS) +# define WS2812_MAX_LEDS 48 +#endif + +// Pixel values +static uint8_t _led_colors[WS2812_BYTES_PER_LED * WS2812_MAX_LEDS]; + +uint32_t rgbGetLedColor(uint8_t led) +{ + uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED]; + return (pixel[1] << 16) + (pixel[0] << 8) + pixel[2]; +} \ No newline at end of file diff --git a/radio/src/targets/taranis/CMakeLists.txt b/radio/src/targets/taranis/CMakeLists.txt index 373e8e21a62..777f0e6675e 100644 --- a/radio/src/targets/taranis/CMakeLists.txt +++ b/radio/src/targets/taranis/CMakeLists.txt @@ -7,6 +7,7 @@ option(INTERNAL_MODULE_PPM "Support for PPM internal module" OFF) option(AUTOUPDATE "Auto update internal chips from SD" OFF) option(BIND_KEY "Enable bind button" OFF) option(BLUETOOTH "FrSky BT module support" OFF) +option(RGBLEDS "WS2812 addressable LED support" OFF) set(USE_RTC_CLOCK YES) set(HARDWARE_EXTERNAL_MODULE YES) @@ -122,7 +123,7 @@ elseif(PCB STREQUAL X7) set(FLAVOUR tpro) set(ROTARY_ENCODER YES) set(CPU_TYPE_FULL STM32F205xE) - add_definitions(-DFUNCTION_SWITCHES) + set(FUNCTION_SWITCHES ON) add_definitions(-DRADIO_TPRO) add_definitions(-DMANUFACTURER_JUMPER) set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough") @@ -133,7 +134,7 @@ elseif(PCB STREQUAL X7) set(FLAVOUR tprov2) set(CPU_TYPE_FULL STM32F407xE) set(ROTARY_ENCODER YES) - add_definitions(-DFUNCTION_SWITCHES) + set(FUNCTION_SWITCHES ON) add_definitions(-DRADIO_TPROV2) add_definitions(-DMANUFACTURER_JUMPER) set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough") @@ -156,7 +157,7 @@ elseif(PCB STREQUAL X7) set(NAVIGATION_TYPE x7) set(CPU_TYPE_FULL STM32F407xG) set(ROTARY_ENCODER YES) - add_definitions(-DFUNCTION_SWITCHES) + set(FUNCTION_SWITCHES YES) add_definitions(-DRADIO_BUMBLEBEE) add_definitions(-DMANUFACTURER_JUMPER) set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough") @@ -192,7 +193,7 @@ elseif(PCB STREQUAL X7) set(ROTARY_ENCODER YES) set(CPU_TYPE_FULL STM32F407xE) set(FLYSKY_GIMBAL ON) - add_definitions(-DFUNCTION_SWITCHES) + set(FUNCTION_SWITCHES ON) add_definitions(-DRADIO_T20) add_definitions(-DRADIO_FAMILY_T20) add_definitions(-DMANUFACTURER_JUMPER) @@ -206,7 +207,7 @@ elseif(PCB STREQUAL X7) set(CPU_TYPE_FULL STM32F407xG) set(FLYSKY_GIMBAL ON) set(PXX2 ON) - add_definitions(-DFUNCTION_SWITCHES) + set(FUNCTION_SWITCHES ON) add_definitions(-DRADIO_T20V2) add_definitions(-DRADIO_FAMILY_T20) add_definitions(-DMANUFACTURER_JUMPER) @@ -285,6 +286,7 @@ elseif(PCB STREQUAL X7) if (NOT BLUETOOTH) set(AUX_SERIAL ON) endif() + set(RGBLEDS YES) elseif(PCBREV STREQUAL BOXER) set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module") set(INTERNAL_MODULE_SERIAL YES) @@ -301,6 +303,24 @@ elseif(PCB STREQUAL X7) if (NOT BLUETOOTH) set(AUX_SERIAL ON) endif() + elseif(PCBREV STREQUAL GX12) + set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module") + set(INTERNAL_MODULE_SERIAL YES) + set(MODULE_SIZE_SML YES) + set(FLAVOUR gx12) + set(NAVIGATION_TYPE x7) + set(CPU_TYPE_FULL STM32F407xG) + set(ROTARY_ENCODER YES) + set(USB_CHARGER YES) + add_definitions(-DRADIO_GX12) + add_definitions(-DMANUFACTURER_RADIOMASTER) + set(PXX2 ON) + set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough") + set(FLYSKY_GIMBAL TES) + set(AUX_SERIAL ON) + set(AUX2_SERIAL OFF) + set(RGBLEDS YES) + set(FUNCTION_SWITCHES_WITH_RGB YES) elseif(PCBREV STREQUAL ZORRO) set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module") set(INTERNAL_MODULE_SERIAL YES) @@ -533,6 +553,15 @@ else() message(FATAL_ERROR "Unknown CPU_TYPE_FULL" ) endif() +if(FUNCTION_SWITCHES) + add_definitions(-DFUNCTION_SWITCHES) +endif() + +if(FUNCTION_SWITCHES_WITH_RGB) + set(FUNCTION_SWITCHES YES) + add_definitions(-DFUNCTION_SWITCHES) + add_definitions(-DFUNCTION_SWITCHES_RGB_LEDS) +endif() if(ENABLE_SERIAL_PASSTHROUGH) set(CLI ON "Enable CLI") @@ -644,6 +673,17 @@ if(USE_RTC_CLOCK) add_definitions(-DRTCLOCK) endif() +if(RGBLEDS) + add_definitions(-DRGBLEDS) +endif() + +if(FLAVOUR STREQUAL gx12) + target_sources(board PRIVATE + drivers/pca95xx.cpp + ${TARGET_SRC_DIR}/gx12/bsp_io.cpp + ) + target_include_directories(board PRIVATE ${TARGET_SRC_DIR}/gx12) +endif() set(SRC ${SRC} io/frsky_firmware_update.cpp diff --git a/radio/src/targets/taranis/board.cpp b/radio/src/targets/taranis/board.cpp index f23e34e9974..d27688b1339 100644 --- a/radio/src/targets/taranis/board.cpp +++ b/radio/src/targets/taranis/board.cpp @@ -30,6 +30,7 @@ #include "hal/abnormal_reboot.h" #include "hal/usb_driver.h" #include "hal/gpio.h" +#include "hal/rgbleds.h" #include "board.h" #include "boards/generic_stm32/module_ports.h" @@ -198,12 +199,12 @@ void boardInit() delay_ms(20); #if defined(FUNCTION_SWITCHES) // Support for FS Led to indicate battery charge level - if (getBatteryVoltage() >= 660) fsLedOn(0); - if (getBatteryVoltage() >= 700) fsLedOn(1); - if (getBatteryVoltage() >= 740) fsLedOn(2); - if (getBatteryVoltage() >= 780) fsLedOn(3); - if (getBatteryVoltage() >= 820) fsLedOn(4); - if (getBatteryVoltage() >= 842) fsLedOn(5); + if (getBatteryVoltage() >= 660) setFSLedON(0); + if (getBatteryVoltage() >= 700) setFSLedON(1); + if (getBatteryVoltage() >= 740) setFSLedON(2); + if (getBatteryVoltage() >= 780) setFSLedON(3); + if (getBatteryVoltage() >= 820) setFSLedON(4); + if (getBatteryVoltage() >= 842) setFSLedON(5); #elif defined(STATUS_LEDS) // Use Status LED to indicate battery charge level instead if (getBatteryVoltage() <= 660) ledRed(); // low discharge @@ -216,6 +217,9 @@ void boardInit() } #endif + delaysInit(); + __enable_irq(); + keysInit(); switchInit(); @@ -223,9 +227,6 @@ void boardInit() rotaryEncoderInit(); #endif - delaysInit(); - __enable_irq(); - #if defined(PWM_STICKS) sticksPwmDetect(); #endif @@ -296,6 +297,11 @@ void boardInit() #if defined(GUI) lcdSetContrast(true); #endif + +#if defined(RADIO_GX12) + gpio_init(HALL_SYNC, GPIO_OUT, GPIO_PIN_SPEED_LOW); +#endif + } #endif diff --git a/radio/src/targets/taranis/gx12/bsp_io.cpp b/radio/src/targets/taranis/gx12/bsp_io.cpp new file mode 100644 index 00000000000..00cd592b281 --- /dev/null +++ b/radio/src/targets/taranis/gx12/bsp_io.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "bsp_io.h" +#include "hal/switch_driver.h" +#include "drivers/pca95xx.h" +#include "stm32_i2c_driver.h" +#include "timers_driver.h" +#include "boards/generic_stm32/rgb_leds.h" + +#include +#include + +#include "myeeprom.h" +#include "bitfield.h" + +struct bsp_io_expander { + pca95xx_t exp; + uint32_t mask; + uint32_t state; +}; + +static bsp_io_expander _io_switches; +static bsp_io_expander _io_fs_switches; + + +static void _init_io_expander(bsp_io_expander* io, uint32_t mask) +{ + io->mask = mask; + io->state = 0; +} + +static uint32_t _read_io_expander(bsp_io_expander* io) +{ + uint16_t value = 0; + if (pca95xx_read(&io->exp, io->mask, &value) == 0) { + io->state = value; + } + return io->state; +} + +static void _poll_switches(void *pvParameter1, uint32_t ulParameter2) +{ + (void)ulParameter2; + bsp_io_expander* io = (bsp_io_expander*)pvParameter1; + _read_io_expander(io); +} + +static void _io_int_handler(bsp_io_expander* io) +{ + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { + xTimerPendFunctionCallFromISR(_poll_switches, (void*)io, 0, + &xHigherPriorityTaskWoken); + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); + } else { + _read_io_expander(io); + } +} + +static void _io_int_handler() { + _io_int_handler(&_io_switches); + _io_int_handler(&_io_fs_switches); +} + +int bsp_io_init() +{ + timersInit(); + + if (i2c_init(I2C_Bus_2) < 0) { + return -1; + } + + // configure expander 1 + _init_io_expander(&_io_switches, 0xFC3F); + if (pca95xx_init(&_io_switches.exp, I2C_Bus_2, 0x74) < 0) { + return -1; + } + + // configure expander 2 + _init_io_expander(&_io_fs_switches, 0x3F); + if (pca95xx_init(&_io_fs_switches.exp, I2C_Bus_2, 0x75) < 0) { + return -1; + } + + // setup expanders pin change interrupt + gpio_init_int(IO_INT_GPIO, GPIO_IN, GPIO_FALLING, _io_int_handler); + + // setup expanders reset pin + gpio_init(IO_RESET_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW); + gpio_set(IO_RESET_GPIO); + + bsp_io_read_switches(); + bsp_io_read_fs_switches(); + + return 0; +} + +uint32_t bsp_io_read_switches() +{ + return _read_io_expander(&_io_switches); +} + +uint32_t bsp_io_read_fs_switches() +{ + return _read_io_expander(&_io_fs_switches); +} + +void boardInitSwitches() +{ + bsp_io_init(); +} + +struct bsp_io_sw_def { + uint32_t pin_high; + uint32_t pin_low; +}; + +static constexpr uint32_t RGB_OFFSET = (1 << 16); // first after bspio pins +static uint16_t soft2POSLogicalState = 0xFFFF; + +static const bsp_io_sw_def _switch_defs[] = { + { SWITCH_A, RGB_OFFSET + 7 }, + { SWITCH_B_H, SWITCH_B_L }, + { SWITCH_C_H, SWITCH_C_L }, + { SWITCH_D, RGB_OFFSET + 6 }, + { SWITCH_E_H, SWITCH_E_L }, + { SWITCH_F_H, SWITCH_F_L }, + { SWITCH_G, 0 }, + { SWITCH_H, 0 }, +}; + +static SwitchHwPos _get_switch_pos(uint8_t idx) +{ + static uint32_t oldState = 0; + SwitchHwPos pos = SWITCH_HW_UP; + const bsp_io_sw_def* def = &_switch_defs[idx]; + + uint32_t state = _io_switches.state; + + if (def->pin_low > RGB_OFFSET) { + // Potential soft 2pos + if ((SWITCH_CONFIG(idx) == SWITCH_TOGGLE)) { + if ((state & def->pin_high) == 0) { + pos = SWITCH_HW_DOWN; + } + } + else { + if (((state & def->pin_high) == 0) && ((state & def->pin_high) != (oldState & def->pin_high))) { + soft2POSLogicalState ^= def->pin_high; + } + if ((soft2POSLogicalState & def->pin_high) == 0) { + pos = SWITCH_HW_DOWN; + } + else { + pos = SWITCH_HW_UP; + } + + } + + if(pos == SWITCH_HW_UP) { + rgbSetLedColor(def->pin_low - RGB_OFFSET, 0x0, 0x0, 0x0); + } + else { + rgbSetLedColor(def->pin_low - RGB_OFFSET, 0xFF, 0xFF, 0xFF); + } + } + else if (!def->pin_low) { + // 2POS switch + if ((state & def->pin_high) == 0) { + pos = SWITCH_HW_DOWN; + } + } else { + bool hi = state & def->pin_high; + bool lo = state & def->pin_low; + + if (hi && lo) { + pos = SWITCH_HW_MID; + } else if (!hi && lo) { + pos = SWITCH_HW_DOWN; + } + } + + if (idx == switchGetMaxSwitches() - 1) + oldState = state; + + return pos; +} + +static SwitchHwPos _get_fs_switch_pos(uint8_t idx) +{ + uint32_t state = _io_fs_switches.state; + if ((state & (1 << idx)) == 0) { + return SWITCH_HW_DOWN; + } else { + return SWITCH_HW_UP; + } +} + +SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx) +{ + if (cat == SWITCH_PHYSICAL) { + return _get_switch_pos(idx); + } else if (cat == SWITCH_FUNCTION){ + return _get_fs_switch_pos(idx); + } + + return SWITCH_HW_UP; +} diff --git a/radio/src/targets/taranis/gx12/bsp_io.h b/radio/src/targets/taranis/gx12/bsp_io.h new file mode 100644 index 00000000000..bb1f322ee88 --- /dev/null +++ b/radio/src/targets/taranis/gx12/bsp_io.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#pragma once + +#include "drivers/pca95xx.h" + +// Port expander 1 (0x74) +#define SWITCH_H PCA95XX_PIN_0 +#define SWITCH_D PCA95XX_PIN_1 + +#define SWITCH_F_H PCA95XX_PIN_3 +#define SWITCH_F_L PCA95XX_PIN_2 + +#define SWITCH_C_L PCA95XX_PIN_4 +#define SWITCH_C_H PCA95XX_PIN_5 + +#define SWITCH_B_H PCA95XX_PIN_10 +#define SWITCH_B_L PCA95XX_PIN_11 + +#define SWITCH_E_H PCA95XX_PIN_12 +#define SWITCH_E_L PCA95XX_PIN_13 + +#define SWITCH_A PCA95XX_PIN_14 +#define SWITCH_G PCA95XX_PIN_15 + +#define IO_INT_GPIO GPIO_PIN(GPIOE, 14) +#define IO_RESET_GPIO GPIO_PIN(GPIOE, 15) + +// Port expander 1 (0x75) +#define FSSWITCH_1 PCA95XX_PIN_0 +#define FSSWITCH_2 PCA95XX_PIN_1 +#define FSSWITCH_3 PCA95XX_PIN_2 +#define FSSWITCH_4 PCA95XX_PIN_3 +#define FSSWITCH_5 PCA95XX_PIN_4 +#define FSSWITCH_6 PCA95XX_PIN_5 + + +int bsp_io_init(); +uint32_t bsp_io_read_switches(); +uint32_t bsp_io_read_fs_switches(); diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index fded243dce0..938c48b987c 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -90,7 +90,7 @@ #define KEYS_GPIO_PIN_LEFT LL_GPIO_PIN_7 // PD.07 #define KEYS_GPIO_REG_RIGHT GPIOD #define KEYS_GPIO_PIN_RIGHT LL_GPIO_PIN_3 // PD.03 -#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_MT12) || defined(RADIO_POCKET) +#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_MT12) || defined(RADIO_POCKET) || defined(RADIO_GX12) #if defined(RADIO_MT12) #define KEYS_GPIO_REG_PAGEUP GPIOD #define KEYS_GPIO_PIN_PAGEUP LL_GPIO_PIN_7 // PD.07 @@ -109,7 +109,7 @@ #define KEYS_GPIO_REG_EXIT GPIOC #define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_5 // PC.05 #endif -#if defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) +#if defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_GX12) #define KEYS_GPIO_REG_ENTER GPIOA #define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_10 // PA.10 #else @@ -178,6 +178,21 @@ #define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_2 // PD.02 #define KEYS_GPIO_REG_ENTER GPIOA #define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_13 // PA.13 +#elif defined(RADIO_GX12) + #define KEYS_GPIO_REG_SYS GPIOB + #define KEYS_GPIO_PIN_SYS LL_GPIO_PIN_4 // PB.04 + #define KEYS_GPIO_REG_ENTER GPIOA + #define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_10 // PA.10 + #define KEYS_GPIO_REG_EXIT GPIOC + #define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_5 // PC.05 + #define KEYS_GPIO_REG_MDL GPIOE + #define KEYS_GPIO_PIN_MDL LL_GPIO_PIN_11 // PE.11 + #define KEYS_GPIO_REG_PAGEUP GPIOD + #define KEYS_GPIO_PIN_PAGEUP LL_GPIO_PIN_7 // PD.03 + #define KEYS_GPIO_REG_PAGEDN GPIOD + #define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_3 // PD.07 + #define KEYS_GPIO_REG_TELE GPIOD + #define KEYS_GPIO_PIN_TELE LL_GPIO_PIN_2 // PD.02 #elif defined(RADIO_V14) || defined(RADIO_V12) #define KEYS_GPIO_REG_PAGEUP GPIOD #define KEYS_GPIO_PIN_PAGEUP LL_GPIO_PIN_3 // PD.03 @@ -233,6 +248,8 @@ #define KEYS_GPIO_PIN_MINUS LL_GPIO_PIN_11 // PE.11 #define KEYS_GPIO_REG_ENTER GPIOE #define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_12 // PE.12 + #define KEYS_GPIO_REG_SYS GPIOB + #define KEYS_GPIO_PIN_SYS LL_GPIO_PIN_4 // PB.04 #endif // Rotary Encoder @@ -305,7 +322,7 @@ #define USE_EXTI15_10_IRQ #define EXTI15_10_IRQ_Priority 5 #endif -#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_MT12) || defined(RADIO_POCKET) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) +#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_MT12) || defined(RADIO_POCKET) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) || defined(RADIO_GX12) #define ROTARY_ENCODER_NAVIGATION #define ROTARY_ENCODER_GPIO GPIOE #define ROTARY_ENCODER_GPIO_PIN_A LL_GPIO_PIN_9 // PE.9 @@ -442,6 +459,23 @@ #define TRIMS_GPIO_PIN_T5R LL_GPIO_PIN_15 // PE.15 #define TRIMS_GPIO_REG_T5L GPIOE #define TRIMS_GPIO_PIN_T5L LL_GPIO_PIN_14 // PE.14 +#elif defined(RADIO_GX12) + #define TRIMS_GPIO_REG_LHL GPIOD + #define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_15 // PD.15 + #define TRIMS_GPIO_REG_LHR GPIOC + #define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_1 // PC.01 + #define TRIMS_GPIO_REG_LVD GPIOE + #define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_6 // PE.06 + #define TRIMS_GPIO_REG_LVU GPIOE + #define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_5 // PE.05 + #define TRIMS_GPIO_REG_RVD GPIOC + #define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_3 // PC.03 + #define TRIMS_GPIO_REG_RHL GPIOE + #define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_3 // PE.03 + #define TRIMS_GPIO_REG_RVU GPIOC + #define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_2 // PC.02 + #define TRIMS_GPIO_REG_RHR GPIOE + #define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_4 // PE.04 #elif defined(RADIO_TPROS) #define TRIMS_GPIO_REG_LHL GPIOC #define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_3 // PC.03 @@ -599,79 +633,56 @@ // Switches #if defined(PCBX9E) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A_H GPIOD #define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_10 // PD.10 #define SWITCHES_GPIO_REG_A_L GPIOD #define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_14 // PD.14 #elif defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_MT12) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A_H GPIOE #define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_1 // PE.01 #define SWITCHES_GPIO_REG_A_L GPIOE #define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_0 // PE.00 #elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_POCKET) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A GPIOC #define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_13 // PC.13 +#elif defined(RADIO_GX12) + #define SWITCHES_A_2POS #elif defined(RADIO_T14) || defined(RADIO_T12MAX) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A GPIOC #define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_5 // PC.05 #elif defined(RADIO_T8) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A GPIOE #define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_14 // PE.14 #elif defined(RADIO_COMMANDO8) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A GPIOE #define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_3 // PE.03 #elif defined(RADIO_TPRO) || defined(RADIO_TPROV2) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A_L GPIOE #define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_13 // PE.13 #define SWITCHES_GPIO_REG_A_H GPIOE #define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_7 // PE.07 #elif defined(RADIO_TPROS) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A_H GPIOE #define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_0 // PE.00 #define SWITCHES_GPIO_REG_A_L GPIOD #define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_11 // PD.11 #elif defined(RADIO_BUMBLEBEE) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A_L GPIOD #define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_2 // PD.02 #define SWITCHES_GPIO_REG_A_H GPIOD #define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_1 // PD.01 #elif defined(RADIO_FAMILY_T20) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_A_INVERTED #define SWITCHES_GPIO_REG_A GPIOD #define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_0 // PD.00 #elif defined(RADIO_V14) || defined(RADIO_V12) // ADC based switch #elif defined(PCBX7) - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A_L GPIOE #define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_7 // PE.07 #define SWITCHES_GPIO_REG_A_H GPIOE #define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_13 // PE.13 #else - #define STORAGE_SWITCH_A - #define HARDWARE_SWITCH_A #define SWITCHES_GPIO_REG_A_H GPIOB #define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_5 // PB.05 #define SWITCHES_GPIO_REG_A_L GPIOE @@ -679,103 +690,75 @@ #endif #if defined(PCBX9E) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_H GPIOG #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_11 // PG.11 #define SWITCHES_GPIO_REG_B_L GPIOG #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_10 // PG.10 #elif defined(PCBXLITE) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOA #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_6 // PA.06 #define SWITCHES_GPIO_REG_B_H GPIOA #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_5 // PA.05 #elif defined(RADIO_T8) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOE #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_7 // PE.07 #define SWITCHES_GPIO_REG_B_H GPIOE #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_13 // PE.13 #elif defined(RADIO_COMMANDO8) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOE #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_5 // PE.05 #define SWITCHES_GPIO_REG_B_H GPIOE #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_4 // PE.04 #elif defined(RADIO_TLITE) || defined(RADIO_TPRO) || defined(RADIO_TPROV2) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOE #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_1 // PE.01 #define SWITCHES_GPIO_REG_B_H GPIOE #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_2 // PE.02 #elif defined(RADIO_TPROS) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOA #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_5 // PA.05 #define SWITCHES_GPIO_REG_B_H GPIOE #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_15 // PE.15 #elif defined(RADIO_BUMBLEBEE) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_H GPIOE #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_0 // PE.00 #define SWITCHES_GPIO_REG_B_L GPIOE #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_1 // PE.01 #elif defined(RADIO_FAMILY_T20) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_B_INVERTED #define SWITCHES_GPIO_REG_B GPIOE #define SWITCHES_GPIO_PIN_B LL_GPIO_PIN_2 // PE.02 #elif (RADIO_LR3PRO) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOE #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_15 // PE.15 #define SWITCHES_GPIO_REG_B_H GPIOA #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_5 // PA.05 #elif defined(RADIO_BOXER) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOE #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_15 // PE.15 #define SWITCHES_GPIO_REG_B_H GPIOE #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_7 // PE.07 #elif defined(RADIO_T14) || defined(RADIO_T12MAX) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B GPIOE #define SWITCHES_GPIO_PIN_B LL_GPIO_PIN_7 // PE.07 #elif defined(RADIO_MT12) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B GPIOD #define SWITCHES_GPIO_PIN_B LL_GPIO_PIN_11 // PD.11 +#elif defined(RADIO_GX12) + #define SWITCHES_B_3POS #elif defined(RADIO_V14) || defined(RADIO_V12) - // ADC based switch +// ADC based switch #elif defined(PCBX7) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOE #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_15 // PE.15 #define SWITCHES_GPIO_REG_B_H GPIOA #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_5 // PA.05 #elif defined(PCBX9LITE) - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_L GPIOB #define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_4 // PB.04 #define SWITCHES_GPIO_REG_B_H GPIOB #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_5 // PB.05 #else - #define STORAGE_SWITCH_B - #define HARDWARE_SWITCH_B #define SWITCHES_GPIO_REG_B_H GPIOE #define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_1 // PE.01 #define SWITCHES_GPIO_REG_B_L GPIOE @@ -783,93 +766,67 @@ #endif #if defined(PCBX9E) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_H GPIOF #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_13 // PF.13 #define SWITCHES_GPIO_REG_C_L GPIOF #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_14 // PF.14 #elif defined(PCBXLITE) || defined(PCBX9LITE) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_L GPIOE #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_2 // PE.02 #define SWITCHES_GPIO_REG_C_H GPIOE #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_3 // PE.03 #elif defined(RADIO_TX12MK2) || defined(RADIO_BOXER) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_L GPIOE #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_0 // PE.00 #define SWITCHES_GPIO_REG_C_H GPIOD #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_11 // PD.11 #elif defined(RADIO_T14) || defined(RADIO_T12MAX) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_H GPIOE #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_0 // PE.00 #define SWITCHES_GPIO_REG_C_L GPIOD #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_11 // PD.11 #elif defined(RADIO_TX12) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_L GPIOD #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_11 // PD.11 #define SWITCHES_GPIO_REG_C_H GPIOE #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_0 // PE.00 #elif defined(RADIO_ZORRO) || defined(RADIO_POCKET) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_L GPIOE #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_0 // PE.00 #define SWITCHES_GPIO_REG_C_H GPIOD #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_11 // PD.11 #elif defined(RADIO_T8) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_L GPIOE #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_2 // PE.02 #define SWITCHES_GPIO_REG_C_H GPIOE #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_1 // PE.01 #elif defined(RADIO_COMMANDO8) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_L GPIOC #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_4 // PC.04 #define SWITCHES_GPIO_REG_C_H GPIOA #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_6 // PA.06 #elif defined(RADIO_TLITE) || defined(RADIO_TPRO) || defined(RADIO_TPROV2) || defined(RADIO_LR3PRO) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C GPIOE #define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_14 // PE.14 #elif defined(RADIO_TPROS) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C GPIOE #define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_8 // PE.08 #elif defined(RADIO_BUMBLEBEE) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C GPIOD #define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_0 // PD.00 #elif defined(RADIO_FAMILY_T20) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_L GPIOD #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_2 // PD.02 #define SWITCHES_GPIO_REG_C_H GPIOD #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_1 // PD.01 #elif defined(RADIO_MT12) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C GPIOC #define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_13 // PC.13 +#elif defined(RADIO_GX12) + #define SWITCHES_C_3POS #elif defined(RADIO_V14) || defined(RADIO_V12) - // ADC based switch +// ADC based switch #elif defined(PCBX7) - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_L GPIOD #define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_11 // PD.11 #if defined(PCBX7ACCESS) @@ -880,8 +837,6 @@ #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_0 // PE.00 #endif #else - #define STORAGE_SWITCH_C - #define HARDWARE_SWITCH_C #define SWITCHES_GPIO_REG_C_H GPIOE #define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_15 // PE.15 #define SWITCHES_GPIO_REG_C_L GPIOA @@ -889,99 +844,69 @@ #endif #if defined(PCBX9E) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D_H GPIOE #define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_1 // PE.01 #define SWITCHES_GPIO_REG_D_L GPIOE #define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_2 // PE.02 #elif defined(PCBX9DP) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D_H GPIOE #define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_7 // PE.07 #define SWITCHES_GPIO_REG_D_L GPIOE #define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_13 // PE.13 #elif defined(PCBXLITE) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D_L GPIOB #define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_4 // PB.04 #define SWITCHES_GPIO_REG_D_H GPIOB #define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_5 // PB.05 #elif defined(RADIO_T8) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D GPIOD #define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_14 // PD.14 #elif defined(RADIO_COMMANDO8) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D GPIOA #define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_5 // PA.05 #elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_POCKET) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D GPIOE #define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_8 // PE.08 #elif defined(RADIO_TLITE) || defined(RADIO_TPRO) || defined(RADIO_TPROV2) || defined(RADIO_LR3PRO) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D GPIOD #define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_14 // PD.14 #elif defined(RADIO_TPROS) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D GPIOC #define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_13// PC.13 #elif defined(RADIO_T14) || defined(RADIO_T12MAX) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D_L GPIOA #define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_5 // PA.05 #define SWITCHES_GPIO_REG_D_H GPIOE #define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_15 // PE.15 #elif defined(RADIO_BUMBLEBEE) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D GPIOE #define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_2 // PE.02 #elif defined(RADIO_FAMILY_T20) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D_L GPIOE #define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_0 // PE.00 #define SWITCHES_GPIO_REG_D_H GPIOE #define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_1 // PE.01 #elif defined(RADIO_MT12) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D GPIOC #define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_3 // PC.03 +#elif defined(RADIO_GX12) + #define SWITCHES_D_2POS #elif defined(RADIO_V14) || defined(RADIO_V12) - // ADC based switch +// ADC based switch #elif defined(PCBX7) && !defined(RADIO_COMMANDO8) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D_L GPIOE #define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_1 // PE.01 #define SWITCHES_GPIO_REG_D_H GPIOE #define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_2 // PE.02 #elif defined(PCBX7) && defined(RADIO_COMMANDO8) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D_L GPIOE #define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_1 // PE.01 #define SWITCHES_GPIO_REG_D_H GPIOE #define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_2 // PE.02 #elif defined(PCBX9LITE) - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D GPIOC #define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_13 // PC.13 #else - #define STORAGE_SWITCH_D - #define HARDWARE_SWITCH_D #define SWITCHES_GPIO_REG_D_H GPIOE #define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_7 // PE.07 #define SWITCHES_GPIO_REG_D_L GPIOB @@ -989,91 +914,62 @@ #endif #if defined(PCBX9E) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E_H GPIOE #define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_7 // PE.07 #define SWITCHES_GPIO_REG_E_L GPIOE #define SWITCHES_GPIO_PIN_E_L LL_GPIO_PIN_13 // PE.13 #elif defined(PCBXLITES) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOE #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_5 // PE.05 #elif defined(PCBXLITE) // no SWE but we want to remain compatible with XLiteS - #define STORAGE_SWITCH_E #elif defined(PCBX9LITE) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOA #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_5 // PA.05 #elif defined(RADIO_ZORRO) || defined(RADIO_POCKET) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOE #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_7 // PE.07 #elif defined(RADIO_BOXER) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOE #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_14 // PE.14 #elif defined(RADIO_TX12) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E_H GPIOE #define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_13 // PE.13 #define SWITCHES_GPIO_REG_E_L GPIOE #define SWITCHES_GPIO_PIN_E_L LL_GPIO_PIN_7 // PE.07 #elif defined(RADIO_TX12MK2) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E_H GPIOE #define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_14 // PE.14 #define SWITCHES_GPIO_REG_E_L GPIOE #define SWITCHES_GPIO_PIN_E_L LL_GPIO_PIN_7 // PE.07 #elif defined(RADIO_TPROS) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOC #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_5 // PC.05 #elif defined(RADIO_TPRO) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOG #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_10 // PG.10 #elif defined(RADIO_TPROV2) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOG #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_0 // PG.00 #elif defined(RADIO_BUMBLEBEE) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOD #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_3 // PD.03 #elif defined(RADIO_T14) || defined(RADIO_T12MAX) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOE #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_8 // PE.08 #elif defined(RADIO_FAMILY_T20) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOD #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_3 // PD.03 #elif defined(RADIO_MT12) // ADC based switch/pot +#elif defined(RADIO_GX12) + #define SWITCHES_E_3POS #elif defined(RADIO_V14) || defined(RADIO_V12) - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E GPIOC #define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_13 // PC.13 #elif defined(PCBX7) // no SWE #else - #define STORAGE_SWITCH_E - #define HARDWARE_SWITCH_E #define SWITCHES_GPIO_REG_E_H GPIOB #define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_3 // PB.03 #define SWITCHES_GPIO_REG_E_L GPIOB @@ -1081,145 +977,100 @@ #endif #if defined(PCBX9E) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOE #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_11 // PE.11 #elif defined(PCBXLITES) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOC #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_3 // PC.03 #elif defined(PCBXLITE) // no SWF but we want to remain compatible with XLiteS - #define STORAGE_SWITCH_F #elif defined(PCBX9LITES) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOC #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_3 // PC.03 #elif defined(PCBX9LITE) // no SWF #elif defined(RADIO_ZORRO) || defined(RADIO_BOXER) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOE #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_1 // PE.01 #elif defined(RADIO_TX12) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F_L GPIOE #define SWITCHES_GPIO_PIN_F_L LL_GPIO_PIN_1 // PE.01 #define SWITCHES_GPIO_REG_F_H GPIOE #define SWITCHES_GPIO_PIN_F_H LL_GPIO_PIN_2 // PE.02 #elif defined(RADIO_TX12MK2) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F_L GPIOD #define SWITCHES_GPIO_PIN_F_L LL_GPIO_PIN_14 // PD.14 #define SWITCHES_GPIO_REG_F_H GPIOE #define SWITCHES_GPIO_PIN_F_H LL_GPIO_PIN_1 // PE.01 #elif defined(RADIO_TPROS) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOE #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_7 // PE.07 #elif defined(RADIO_TPRO) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOG #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_9 // PG.09 #elif defined(RADIO_TPROV2) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOG #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_1 // PG.01 #elif defined(RADIO_BUMBLEBEE) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOB #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_5 // PB.05 #elif defined(RADIO_T14) || defined(RADIO_T12MAX) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOC #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_13// PC.13 #elif defined(RADIO_FAMILY_T20) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOB #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_5 // PB.05 #elif defined(RADIO_MT12) // ADC based switch/pot #elif defined(RADIO_T8) || defined(RADIO_TLITE) || defined(RADIO_TPROV2) || defined(RADIO_COMMANDO8) || defined(RADIO_LR3PRO) || defined(RADIO_POCKET) // no SWF - #define STORAGE_SWITCH_F #elif defined(RADIO_T12) // no SWF +#elif defined(RADIO_GX12) + #define SWITCHES_F_3POS #elif defined(RADIO_V14) || defined(RADIO_V12) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOE #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_8 // PE.08 #elif defined(PCBX7) - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOE #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_14 // PE.14 #else - #define STORAGE_SWITCH_F - #define HARDWARE_SWITCH_F #define SWITCHES_GPIO_REG_F GPIOE #define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_14 // PE.14 #endif #if defined(PCBX9E) - #define STORAGE_SWITCH_G - #define HARDWARE_SWITCH_G #define SWITCHES_GPIO_REG_G_H GPIOF #define SWITCHES_GPIO_PIN_G_H LL_GPIO_PIN_3 // PF.03 #define SWITCHES_GPIO_REG_G_L GPIOF #define SWITCHES_GPIO_PIN_G_L LL_GPIO_PIN_4 // PF.04 #elif defined(PCBX9LITES) - #define STORAGE_SWITCH_G - #define HARDWARE_SWITCH_G #define SWITCHES_GPIO_REG_G GPIOC #define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_2 // PC.02 #elif defined(RADIO_T12) || defined(RADIO_ZORRO) - #define STORAGE_SWITCH_G - #define HARDWARE_SWITCH_G #define SWITCHES_GPIO_REG_G GPIOE #define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_14 // PE.14 #elif defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_V14) || defined(RADIO_V12) - #define STORAGE_SWITCH_G #elif defined(RADIO_TPROV2) - #define STORAGE_SWITCH_G - #define HARDWARE_SWITCH_G #define SWITCHES_GPIO_REG_G GPIOG #define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_10 // PG.10 #elif defined(RADIO_TPRO) // SW1 #define FUNCTION_SWITCH_1 SG - #define STORAGE_SWITCH_G - #define HARDWARE_SWITCH_G #define SWITCHES_GPIO_REG_G GPIOG #define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_7 // PG.07 #elif defined(RADIO_BUMBLEBEE) - #define STORAGE_SWITCH_G - #define HARDWARE_SWITCH_G #define SWITCHES_GPIO_REG_G GPIOD #define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_15// PD.15 - Left trim push #elif defined(RADIO_FAMILY_T20) //TRIM left low - #define STORAGE_SWITCH_G - #define HARDWARE_SWITCH_G #define SWITCHES_GPIO_REG_G GPIOD #define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_15 // PD.15 +#elif defined(RADIO_GX12) + #define SWITCHES_G_2POS #elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_T8) || defined(RADIO_COMMANDO8) || defined(RADIO_MT12) || defined(RADIO_POCKET) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) // no SWG #else - #define STORAGE_SWITCH_G - #define HARDWARE_SWITCH_G #define SWITCHES_GPIO_REG_G_H GPIOE #define SWITCHES_GPIO_PIN_G_H LL_GPIO_PIN_9 // PE.09 #define SWITCHES_GPIO_REG_G_L GPIOE @@ -1227,216 +1078,147 @@ #endif #if defined(PCBX9E) - #define STORAGE_SWITCH_H - #define HARDWARE_SWITCH_H #define SWITCHES_GPIO_REG_H GPIOF #define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_1 // PF.01 #elif defined(PCBX9DP) - #define STORAGE_SWITCH_H - #define HARDWARE_SWITCH_H #define SWITCHES_GPIO_REG_H GPIOD #define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_14 // PD.14 #elif defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_POCKET) // no SWH #elif defined(RADIO_T8) || defined(RADIO_COMMANDO8) - #define STORAGE_SWITCH_H // no SWH #elif defined(RADIO_TX12) || defined(RADIO_MT12) #elif defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_V14) || defined(RADIO_V12) -#define STORAGE_SWITCH_H #elif defined(RADIO_TPROV2) - #define STORAGE_SWITCH_H - #define HARDWARE_SWITCH_H #define SWITCHES_GPIO_REG_H GPIOG #define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_9 // PG.09 #elif defined(RADIO_TPRO) // SW2 #define FUNCTION_SWITCH_2 SH - #define STORAGE_SWITCH_H - #define HARDWARE_SWITCH_H #define SWITCHES_GPIO_REG_H GPIOG #define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_6 // PG.06 #elif defined(RADIO_BUMBLEBEE) - #define STORAGE_SWITCH_H - #define HARDWARE_SWITCH_H #define SWITCHES_GPIO_REG_H GPIOF #define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_0 // PF.00 - Right trim push #elif defined(RADIO_FAMILY_T20) //TRIM right low - #define STORAGE_SWITCH_H - #define HARDWARE_SWITCH_H #define SWITCHES_GPIO_REG_H GPIOF #define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_0 // PF.00 #elif defined(RADIO_TLITE) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_LR3PRO) // no SWH - #define STORAGE_SWITCH_H +#elif defined(RADIO_GX12) + #define SWITCHES_H_2POS #elif defined(PCBX7) - #define STORAGE_SWITCH_H - #define HARDWARE_SWITCH_H #define SWITCHES_GPIO_REG_H GPIOD #define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_14 // PD.14 #else - #define STORAGE_SWITCH_H - #define HARDWARE_SWITCH_H #define SWITCHES_GPIO_REG_H GPIOE #define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_13 // PE.13 #endif #if defined(RADIO_X9DP2019) - #define STORAGE_SWITCH_I - #define HARDWARE_SWITCH_I #define SWITCHES_GPIO_REG_I GPIOD #define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_10 // PD.10 #elif defined(PCBX9D) || defined(PCBX9DP) - #define STORAGE_SWITCH_I #endif // X7 P400 P401 headers additionnal momentary switches #if defined(PCBX7ACCESS) - #define STORAGE_SWITCH_I - #define HARDWARE_SWITCH_I #define SWITCHES_GPIO_REG_I GPIOC #define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_13 // PC.13 - #define STORAGE_SWITCH_J #elif defined(RADIO_T8) || defined(RADIO_COMMANDO8) - #define STORAGE_SWITCH_I - #define STORAGE_SWITCH_J // no SWI/J #elif defined(RADIO_TX12) - #define STORAGE_SWITCH_I - #define HARDWARE_SWITCH_I #define SWITCHES_GPIO_REG_I GPIOE #define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_14 // PE.14 - #define STORAGE_SWITCH_J - #define HARDWARE_SWITCH_J #define SWITCHES_GPIO_REG_J GPIOD #define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_14 // PD.14 #elif defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_V14) || defined(RADIO_V12) // no headers #elif defined(RADIO_TLITE) || defined(RADIO_LR3PRO) // no SWI - #define STORAGE_SWITCH_I // no SWJ - #define STORAGE_SWITCH_J #elif defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) // No I/J #elif defined(RADIO_TPROV2) // SW1 #define FUNCTION_SWITCH_1 SI - #define STORAGE_SWITCH_I - #define HARDWARE_SWITCH_I #define SWITCHES_GPIO_REG_I GPIOG #define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_7 // PG.07 // SW2 #define FUNCTION_SWITCH_2 SJ - #define STORAGE_SWITCH_J - #define HARDWARE_SWITCH_J #define SWITCHES_GPIO_REG_J GPIOG #define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_6 // PG.06 // SW3 #define FUNCTION_SWITCH_3 SK - #define STORAGE_SWITCH_K - #define HARDWARE_SWITCH_K #define SWITCHES_GPIO_REG_K GPIOG #define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_5 // PG.05 // SW4 #define FUNCTION_SWITCH_4 SL - #define STORAGE_SWITCH_L - #define HARDWARE_SWITCH_L #define SWITCHES_GPIO_REG_L GPIOG #define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_4 // PG.04 // SW5 #define FUNCTION_SWITCH_5 SM - #define STORAGE_SWITCH_M - #define HARDWARE_SWITCH_M #define SWITCHES_GPIO_REG_M GPIOG #define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_3 // PG.03 // SW6 #define FUNCTION_SWITCH_6 SO - #define STORAGE_SWITCH_O - #define HARDWARE_SWITCH_O #define SWITCHES_GPIO_REG_O GPIOG #define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_2 // PG.02 #elif defined(RADIO_BUMBLEBEE) // SW1 #define FUNCTION_SWITCH_1 SJ - #define STORAGE_SWITCH_J - #define HARDWARE_SWITCH_J #define SWITCHES_GPIO_REG_J GPIOE #define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_15 // PE.15 // SW2 #define FUNCTION_SWITCH_2 SK - #define STORAGE_SWITCH_K - #define HARDWARE_SWITCH_K #define SWITCHES_GPIO_REG_K GPIOE #define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_14 // PE.14 // SW3 #define FUNCTION_SWITCH_3 SL - #define STORAGE_SWITCH_L - #define HARDWARE_SWITCH_L #define SWITCHES_GPIO_REG_L GPIOE #define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_13 // PE.13 // SW4 #define FUNCTION_SWITCH_4 SM - #define STORAGE_SWITCH_M - #define HARDWARE_SWITCH_M #define SWITCHES_GPIO_REG_M GPIOE #define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_10 // PE.10 // SW5 #define FUNCTION_SWITCH_5 SO - #define STORAGE_SWITCH_O - #define HARDWARE_SWITCH_O #define SWITCHES_GPIO_REG_O GPIOE #define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_8 // PE.08 // SW6 #define FUNCTION_SWITCH_6 SP - #define STORAGE_SWITCH_P - #define HARDWARE_SWITCH_P #define SWITCHES_GPIO_REG_P GPIOE #define SWITCHES_GPIO_PIN_P LL_GPIO_PIN_12 // PE.12 #elif defined(RADIO_TPRO) // SW3 #define FUNCTION_SWITCH_3 SI - #define STORAGE_SWITCH_I - #define HARDWARE_SWITCH_I #define SWITCHES_GPIO_REG_I GPIOG #define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_5 // PG.05 // SW4 #define FUNCTION_SWITCH_4 SJ - #define STORAGE_SWITCH_J - #define HARDWARE_SWITCH_J #define SWITCHES_GPIO_REG_J GPIOG #define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_4 // PG.04 // SW5 #define FUNCTION_SWITCH_5 SK - #define STORAGE_SWITCH_K - #define HARDWARE_SWITCH_K #define SWITCHES_GPIO_REG_K GPIOG #define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_3 // PG.03 // SW6 #define FUNCTION_SWITCH_6 SL - #define STORAGE_SWITCH_L - #define HARDWARE_SWITCH_L #define SWITCHES_GPIO_REG_L GPIOG #define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_2 // PG.02 #elif defined(RADIO_FAMILY_T20) //TRIM left up - #define STORAGE_SWITCH_I - #define HARDWARE_SWITCH_I #define SWITCHES_GPIO_REG_I GPIOG #define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_11 // PG.11 //TRIM right up - #define STORAGE_SWITCH_J - #define HARDWARE_SWITCH_J #define SWITCHES_GPIO_REG_J GPIOG #define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_14 // PG.14 +#elif defined(RADIO_GX12) + // I and J are part of function switches bellow #elif defined(PCBX7) - #define STORAGE_SWITCH_I - #define HARDWARE_SWITCH_I #define SWITCHES_GPIO_REG_I GPIOC #define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_13 // PC.13 - #define STORAGE_SWITCH_J - #define HARDWARE_SWITCH_J #define SWITCHES_GPIO_REG_J GPIOD #define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_10 // PD.10 #endif @@ -1444,99 +1226,82 @@ #if defined(RADIO_FAMILY_T20) //SW1 #define FUNCTION_SWITCH_1 SK - #define STORAGE_SWITCH_K - #define HARDWARE_SWITCH_K #define SWITCHES_GPIO_REG_K GPIOE #define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_10 // PE.10 //SW2 #define FUNCTION_SWITCH_2 SL - #define STORAGE_SWITCH_L - #define HARDWARE_SWITCH_L #define SWITCHES_GPIO_REG_L GPIOE #define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_8 // PE.08 //SW3 #define FUNCTION_SWITCH_3 SM - #define STORAGE_SWITCH_M - #define HARDWARE_SWITCH_M #define SWITCHES_GPIO_REG_M GPIOE #define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_12 // PE.12 //SW4 #define FUNCTION_SWITCH_4 SN - #define STORAGE_SWITCH_N - #define HARDWARE_SWITCH_N #define SWITCHES_GPIO_REG_N GPIOE #define SWITCHES_GPIO_PIN_N LL_GPIO_PIN_13 // PE.13 //SW5 #define FUNCTION_SWITCH_5 SO - #define STORAGE_SWITCH_O - #define HARDWARE_SWITCH_O #define SWITCHES_GPIO_REG_O GPIOE #define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_14 // PE.14 //SW6 #define FUNCTION_SWITCH_6 SP - #define STORAGE_SWITCH_P - #define HARDWARE_SWITCH_P #define SWITCHES_GPIO_REG_P GPIOE #define SWITCHES_GPIO_PIN_P LL_GPIO_PIN_15 // PE.15 #endif +#if defined(RADIO_GX12) + //SW1 + #define FUNCTION_SWITCH_1 + //SW2 + #define FUNCTION_SWITCH_2 + //SW3 + #define FUNCTION_SWITCH_3 + //SW4 + #define FUNCTION_SWITCH_4 + //SW5 + #define FUNCTION_SWITCH_5 + //SW6 + #define FUNCTION_SWITCH_6 +#endif + #if defined(PCBX9E) - #define STORAGE_SWITCH_I - #define HARDWARE_SWITCH_I #define SWITCHES_GPIO_REG_I_H GPIOF #define SWITCHES_GPIO_PIN_I_H LL_GPIO_PIN_15 // PF.15 #define SWITCHES_GPIO_REG_I_L GPIOE #define SWITCHES_GPIO_PIN_I_L LL_GPIO_PIN_14 // PE.14 - #define STORAGE_SWITCH_J - #define HARDWARE_SWITCH_J #define SWITCHES_GPIO_REG_J_H GPIOG #define SWITCHES_GPIO_PIN_J_H LL_GPIO_PIN_7 // PG.07 #define SWITCHES_GPIO_REG_J_L GPIOG #define SWITCHES_GPIO_PIN_J_L LL_GPIO_PIN_8 // PG.08 - #define STORAGE_SWITCH_K - #define HARDWARE_SWITCH_K #define SWITCHES_GPIO_REG_K_H GPIOG #define SWITCHES_GPIO_PIN_K_H LL_GPIO_PIN_13 // PG.13 #define SWITCHES_GPIO_REG_K_L GPIOG #define SWITCHES_GPIO_PIN_K_L LL_GPIO_PIN_12 // PG.12 - #define STORAGE_SWITCH_L - #define HARDWARE_SWITCH_L #define SWITCHES_GPIO_REG_L_H GPIOE #define SWITCHES_GPIO_PIN_L_H LL_GPIO_PIN_9 // PE.09 #define SWITCHES_GPIO_REG_L_L GPIOE #define SWITCHES_GPIO_PIN_L_L LL_GPIO_PIN_8 // PE.08 - #define STORAGE_SWITCH_M - #define HARDWARE_SWITCH_M #define SWITCHES_GPIO_REG_M_H GPIOE #define SWITCHES_GPIO_PIN_M_H LL_GPIO_PIN_15 // PE.15 #define SWITCHES_GPIO_REG_M_L GPIOA #define SWITCHES_GPIO_PIN_M_L LL_GPIO_PIN_5 // PA.05 - #define STORAGE_SWITCH_N - #define HARDWARE_SWITCH_N #define SWITCHES_GPIO_REG_N_H GPIOB #define SWITCHES_GPIO_PIN_N_H LL_GPIO_PIN_3 // PB.03 #define SWITCHES_GPIO_REG_N_L GPIOB #define SWITCHES_GPIO_PIN_N_L LL_GPIO_PIN_4 // PB.04 - #define STORAGE_SWITCH_O - #define HARDWARE_SWITCH_O #define SWITCHES_GPIO_REG_O_H GPIOF #define SWITCHES_GPIO_PIN_O_H LL_GPIO_PIN_7 // PF.07 #define SWITCHES_GPIO_REG_O_L GPIOE #define SWITCHES_GPIO_PIN_O_L LL_GPIO_PIN_10 // PE.10 - #define STORAGE_SWITCH_P - #define HARDWARE_SWITCH_P #define SWITCHES_GPIO_REG_P_H GPIOF #define SWITCHES_GPIO_PIN_P_H LL_GPIO_PIN_11 // PF.11 #define SWITCHES_GPIO_REG_P_L GPIOF #define SWITCHES_GPIO_PIN_P_L LL_GPIO_PIN_12 // PF.12 - #define STORAGE_SWITCH_Q - #define HARDWARE_SWITCH_Q #define SWITCHES_GPIO_REG_Q_H GPIOF #define SWITCHES_GPIO_PIN_Q_H LL_GPIO_PIN_5 // PF.05 #define SWITCHES_GPIO_REG_Q_L GPIOF #define SWITCHES_GPIO_PIN_Q_L LL_GPIO_PIN_6 // PF.06 - #define STORAGE_SWITCH_R - #define HARDWARE_SWITCH_R #define SWITCHES_GPIO_REG_R_H GPIOB #define SWITCHES_GPIO_PIN_R_H LL_GPIO_PIN_5 // PB.05 #define SWITCHES_GPIO_REG_R_L GPIOE @@ -1878,9 +1643,6 @@ #define ADC_EXT_SAMPTIME LL_ADC_SAMPLINGTIME_56CYCLES #define ADC_VREF_PREC2 330 #elif defined(RADIO_MT12) - #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_DMA2) - #define ADC_RCC_APB1Periph 0 - #define ADC_RCC_APB2Periph 0 #define ADC_GPIO_PIN_STICK_TH LL_GPIO_PIN_0 // PA.00 #define ADC_GPIO_PIN_STICK_ST LL_GPIO_PIN_1 // PA.01 #define ADC_CHANNEL_STICK_TH LL_ADC_CHANNEL_0 // ADC1_IN0 @@ -1898,6 +1660,31 @@ #define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_TH | ADC_GPIO_PIN_STICK_ST | ADC_GPIO_PIN_POT1 | ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_POT3 | ADC_GPIO_PIN_POT4) #define ADC_GPIOC_PINS (ADC_GPIO_PIN_BATT) #define ADC_VREF_PREC2 330 +#elif defined(RADIO_GX12) + // Serial gimbal only + #define ADC_GPIO_PIN_STICK_LH + #define ADC_GPIO_PIN_STICK_LV + #define ADC_GPIO_PIN_STICK_RV + #define ADC_GPIO_PIN_STICK_RH + #define ADC_CHANNEL_STICK_LH + #define ADC_CHANNEL_STICK_LV + #define ADC_CHANNEL_STICK_RV + #define ADC_CHANNEL_STICK_RH + // Analogs + #define ADC_GPIO_PIN_POT1 LL_GPIO_PIN_2 // PA.02 + #define ADC_GPIO_PIN_POT2 LL_GPIO_PIN_3 // PA.03 + #define ADC_GPIO_PIN_SLIDER1 LL_GPIO_PIN_0 // PB.00 + #define ADC_GPIO_PIN_SLIDER2 LL_GPIO_PIN_5 // PA.05 + #define ADC_GPIO_PIN_BATT LL_GPIO_PIN_0 // PC.00 + #define ADC_CHANNEL_POT1 LL_ADC_CHANNEL_2 // ADC123_IN2 + #define ADC_CHANNEL_POT2 LL_ADC_CHANNEL_3 // ADC123_IN3 + #define ADC_CHANNEL_SLIDER1 LL_ADC_CHANNEL_8 // ADC12_IN8 + #define ADC_CHANNEL_SLIDER2 LL_ADC_CHANNEL_5 // ADC12_IN6 + #define ADC_CHANNEL_BATT LL_ADC_CHANNEL_10 // ADC123_IN10 + #define ADC_GPIOA_PINS (ADC_GPIO_PIN_POT1 | ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_SLIDER2) + #define ADC_GPIOB_PINS (ADC_GPIO_PIN_SLIDER1) + #define ADC_GPIOC_PINS (ADC_GPIO_PIN_BATT) + #define ADC_VREF_PREC2 330 #elif defined(RADIO_V14) || defined(RADIO_V12) #define ADC_GPIO_PIN_STICK_RV LL_GPIO_PIN_0 // PA.00 #define ADC_GPIO_PIN_STICK_RH LL_GPIO_PIN_1 // PA.01 @@ -2033,6 +1820,8 @@ #define ADC_DIRECTION {1,-1,1,-1, -1,1,-1,-1,-1,-1} #elif defined(RADIO_MT12) #define ADC_DIRECTION {1,-1, -1,-1, 0, 0, 0, 0} +#elif defined(RADIO_GX12) + #define ADC_DIRECTION {1,1,1,1, -1,-1, 1,-1} #elif defined(RADIO_V14) #define ADC_DIRECTION {1,-1,1,-1, -1,-1,1, 0, 1,1,1,1 } #elif defined(RADIO_V12) @@ -2133,7 +1922,7 @@ #define LED_GREEN_GPIO GPIO_PIN(GPIOG, 1) // PG.01 #define LED_RED_GPIO GPIO_PIN(GPIOC, 5) // PC.05 #define LED_BLUE_GPIO GPIO_PIN(GPIOC, 4) // PC.04 -#elif defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) +#elif defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_GX12) #define STATUS_LEDS #define GPIO_LED_GPIO_ON gpio_set #define GPIO_LED_GPIO_OFF gpio_clear @@ -2170,8 +1959,12 @@ #endif // LED Strip -#if defined(RADIO_MT12) - #define LED_STRIP_LENGTH 7 +#if defined(RGBLEDS) + #if defined(RADIO_GX12) + #define LED_STRIP_LENGTH 8 + #else + #define LED_STRIP_LENGTH 7 + #endif #define LED_STRIP_GPIO GPIO_PIN(GPIOA, 8) // PA.08 / TIM1_CH1 #define LED_STRIP_GPIO_AF LL_GPIO_AF_1 // TIM1 / TIM2 #define LED_STRIP_TIMER TIM1 @@ -2284,7 +2077,7 @@ #define INTMODULE_DMA_STREAM_IRQ DMA2_Stream7_IRQn #define INTMODULE_DMA_STREAM_IRQHandler DMA2_Stream7_IRQHandler #define INTMODULE_DMA_CHANNEL LL_DMA_CHANNEL_4 -#elif defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_T20V2) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) || defined(RADIO_BUMBLEBEE) +#elif defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_T20V2) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) || defined(RADIO_GX12) || defined(RADIO_BUMBLEBEE) #if defined(RADIO_T20V2) || defined(RADIO_BUMBLEBEE) #define INTMODULE_BOOTCMD_GPIO GPIO_PIN(GPIOE, 4) // PE.04 #define INTMODULE_PWR_GPIO GPIO_PIN(GPIOC, 6) // PC.06 @@ -2381,11 +2174,13 @@ #endif // External Module -#if defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_X9DP2019) || defined(PCBX7ACCESS) || defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) - #if defined(RADIO_X9DP2019) || defined(RADIO_X7ACCESS) || defined(RADIO_ZORRO)|| defined(RADIO_POCKET) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12)|| defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) +#if defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_X9DP2019) || defined(PCBX7ACCESS) || defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) || defined(RADIO_T12MAX) || defined(RADIO_GX12) + #if defined(RADIO_X9DP2019) || defined(RADIO_X7ACCESS) || defined(RADIO_ZORRO)|| defined(RADIO_POCKET) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12)|| defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) #define EXTMODULE_PWR_GPIO GPIO_PIN(GPIOD, 8) // PD.08 #elif defined(PCBX9LITE) #define EXTMODULE_PWR_GPIO GPIO_PIN(GPIOA, 8) // PA.08 + #elif defined(RADIO_GX12) + #define EXTMODULE_PWR_GPIO GPIO_PIN(GPIOE, 0) // PE.00 #else #define EXTMODULE_PWR_GPIO GPIO_PIN(GPIOD, 11) // PD.11 #endif @@ -2499,6 +2294,16 @@ // Serial Port #if (defined(PCBX7) && !defined(AUX_SERIAL)) || defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_X9DP2019) +#elif defined(RADIO_GX12) + #define HARDWARE_TRAINER_AUX_SERIAL + #define AUX_SERIAL_GPIO GPIOD + #define AUX_SERIAL_TX_GPIO GPIO_PIN(GPIOD, 8) // PD.08 + #define AUX_SERIAL_RX_GPIO GPIO_PIN(GPIOD, 9) // PD.09 + #define AUX_SERIAL_USART USART3 + #define AUX_SERIAL_USART_IRQn USART3_IRQn + #define AUX_SERIAL_DMA_RX DMA1 + #define AUX_SERIAL_DMA_RX_STREAM LL_DMA_STREAM_1 + #define AUX_SERIAL_DMA_RX_CHANNEL LL_DMA_CHANNEL_4 #else #define HARDWARE_TRAINER_AUX_SERIAL #define AUX_SERIAL_GPIO GPIOB @@ -2644,7 +2449,8 @@ #if defined(PCBX9LITE) || defined(PCBXLITE) || defined(RADIO_X9DP2019) || \ defined(PCBX7ACCESS) || defined(RADIO_ZORRO) || defined(RADIO_POCKET) || \ defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12) ||\ - defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_V14) || defined(RADIO_V12) + defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_V14) || defined(RADIO_V12) \ + || defined(RADIO_GX12) #define TRAINER_MODULE_CPPM_TIMER TIM3 #define TRAINER_MODULE_CPPM_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1) #define TRAINER_MODULE_CPPM_GPIO EXTMODULE_RX_GPIO @@ -2708,7 +2514,7 @@ #define BACKLIGHT_CCMR1 TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 // Channel 1, PWM #define BACKLIGHT_CCER TIM_CCER_CC1E #define BACKLIGHT_COUNTER_REGISTER BACKLIGHT_TIMER->CCR1 -#elif defined(RADIO_T8) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_BUMBLEBEE) +#elif defined(RADIO_T8) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_BUMBLEBEE) || defined(RADIO_GX12) // No backlight: OLED display #elif defined(RADIO_COMMANDO8) #define BACKLIGHT_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1) @@ -2737,11 +2543,11 @@ #if defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_FAMILY_JUMPER_T12) || defined(RADIO_T8) || defined(RADIO_COMMANDO8) || defined(RADIO_TPRO) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_FAMILY_T20) || defined(RADIO_MT12) || defined(RADIO_T12MAX) || defined(RADIO_V14) || defined(RADIO_V12) || defined(RADIO_BUMBLEBEE) #define LCD_VERTICAL_INVERT #endif -#if defined(RADIO_LR3PRO) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_BUMBLEBEE) +#if defined(RADIO_LR3PRO) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_BUMBLEBEE) || defined(RADIO_GX12) #define LCD_HORIZONTAL_INVERT #define OLED_SCREEN #endif -#if defined(RADIO_T14) +#if defined(RADIO_T14) || defined(RADIO_GX12) #define SSD1309_LCD #endif #if defined(PCBX9E) @@ -2803,13 +2609,17 @@ #else #define LCD_SPI_PRESCALER 0 #endif +#if defined(RADIO_GX12) + #define OLED_VCC_CS GPIO_PIN(GPIOD, 11) // PD.11 +#endif // I2C Bus 1: EEPROM and CAT5137 digital pot for volume control #define I2C_B1 I2C1 #define I2C_B1_GPIO_AF LL_GPIO_AF_4 #if defined(PCBXLITE) || defined(PCBX9LITE) || defined(PCBX7ACCESS) || \ - defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_X9DP2019) + defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_X9DP2019) || \ + defined(RADIO_GX12) #define I2C_B1_SCL_GPIO GPIO_PIN(GPIOB, 8) // PB.08 #define I2C_B1_SDA_GPIO GPIO_PIN(GPIOB, 9) // PB.09 #else @@ -2824,7 +2634,8 @@ #elif defined(PCBX7ACCESS) #define EEPROM_WP_GPIO GPIOB #define EEPROM_WP_GPIO_PIN LL_GPIO_PIN_5 // PB.05 -#elif defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_TX12MK2)|| defined(RADIO_BOXER) +#elif defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_TX12MK2)|| \ + defined(RADIO_BOXER) || defined(RADIO_GX12) #define EEPROM_WP_GPIO GPIOD #define EEPROM_WP_GPIO_PIN LL_GPIO_PIN_10 // PD.10 #elif defined(RADIO_X9DP2019) @@ -2861,8 +2672,19 @@ #define IMU_I2C_ADDRESS 0x6B #endif +#if defined(RADIO_GX12) + #define I2C_B2 I2C2 + #define I2C_B2_SCL_GPIO GPIO_PIN(GPIOB, 10) // PB.10 + #define I2C_B2_SDA_GPIO GPIO_PIN(GPIOB, 11) // PB.11 + #define I2C_B2_GPIO_AF LL_GPIO_AF_4 + #define I2C_B2_CLK_RATE 400000 + + #define USE_EXTI1_IRQ + #define EXTI1_IRQ_Priority 5 +#endif + // SD - SPI2 -#if defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_BUMBLEBEE) +#if defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_BUMBLEBEE) || defined(RADIO_GX12) // Using chip, so no detect #else #if defined(PCBXLITE) || defined(PCBX9LITE) @@ -2922,7 +2744,7 @@ #endif // Haptic -#if defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_TX12MK2)|| defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_T20V2) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) || defined(RADIO_BUMBLEBEE) +#if defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_ZORRO) || defined(RADIO_POCKET) || defined(RADIO_TX12MK2)|| defined(RADIO_BOXER) || defined(RADIO_MT12) || defined(RADIO_T20V2) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12) || defined(RADIO_BUMBLEBEE) || defined(RADIO_GX12) #define HAPTIC_PWM #define HAPTIC_GPIO GPIO_PIN(GPIOB, 3) // PB.03 #define HAPTIC_GPIO_AF GPIO_AF1 @@ -2954,7 +2776,7 @@ #define HAPTIC_GPIO GPIO_PIN(GPIOC, 12) // PC.12 #endif -#if defined(RADIO_BOXER) || defined(RADIO_FAMILY_T20) || defined(RADIO_X9DP2019) || defined (RADIO_V14) +#if defined(RADIO_BOXER) || defined(RADIO_FAMILY_T20) || defined(RADIO_X9DP2019) || defined (RADIO_V14) || defined(RADIO_GX12) // Flysky Hall Stick #define FLYSKY_HALL_SERIAL_USART UART4 #define FLYSKY_HALL_SERIAL_GPIO GPIOA @@ -2967,6 +2789,10 @@ #define FLYSKY_HALL_DMA_Stream_TX LL_DMA_STREAM_4 #endif +#if defined(RADIO_GX12) + #define HALL_SYNC GPIO_PIN(GPIOE, 7) // PE.07 +#endif + // Top LCD on X9E #if defined(PCBX9E) #define TOPLCD_GPIO diff --git a/radio/src/targets/taranis/lcd_driver_spi.cpp b/radio/src/targets/taranis/lcd_driver_spi.cpp index 94342f6ed19..1c549cac1ab 100644 --- a/radio/src/targets/taranis/lcd_driver_spi.cpp +++ b/radio/src/targets/taranis/lcd_driver_spi.cpp @@ -106,6 +106,14 @@ void lcdHardwareInit() NVIC_SetPriority(LCD_DMA_Stream_IRQn, 7); NVIC_EnableIRQ(LCD_DMA_Stream_IRQn); + +#if defined(OLED_VCC_CS) + gpio_init(OLED_VCC_CS, GPIO_OUT, GPIO_PIN_SPEED_LOW); + + // Coming from bootloader or EM, screen is already on + if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) + gpio_set(OLED_VCC_CS); +#endif } #if defined(SSD1309_LCD) @@ -145,6 +153,10 @@ void lcdStart() lcdWriteCommand(0xA4); // Disable Entire Display On lcdWriteCommand(0xA6); // Set Normal Display (not inverted) lcdWriteCommand(0x2E); // Deactivate scroll +#if defined(OLED_VCC_CS) + delay_ms(100); + gpio_set(OLED_VCC_CS); +#endif #else #if defined(LCD_VERTICAL_INVERT) // T12 and TX12 have the screen inverted. @@ -353,7 +365,12 @@ void lcdOff() to re-init LCD without any delay */ lcdWriteCommand(0xAE); // LCD sleep +#if defined(OLED_VCC_CS) + gpio_clear(OLED_VCC_CS); + delay_ms(100); +#else delay_ms(3); // Wait for caps to drain +#endif } void lcdReset() diff --git a/radio/src/targets/taranis/led_driver.cpp b/radio/src/targets/taranis/led_driver.cpp index 3a5ad9e275c..94c616f8b30 100644 --- a/radio/src/targets/taranis/led_driver.cpp +++ b/radio/src/targets/taranis/led_driver.cpp @@ -20,11 +20,19 @@ */ #include "hal/gpio.h" +#include "hal/rgbleds.h" #include "stm32_gpio.h" - +#include "boards/generic_stm32/rgb_leds.h" #include "board.h" +#if defined(LED_STRIP_GPIO) +#include "boards/generic_stm32/rgb_leds.h" +#endif + +#define GET_RED(color) (((color) & 0xF80000) >>16) +#define GET_GREEN(color) (((color) & 0x000F800) >> 8) +#define GET_BLUE(color) (((color) & 0xF8)) -#if defined(FUNCTION_SWITCHES) +#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS) static const uint32_t fsLeds[] = {FSLED_GPIO_PIN_1, FSLED_GPIO_PIN_2, FSLED_GPIO_PIN_3, FSLED_GPIO_PIN_4, FSLED_GPIO_PIN_5, FSLED_GPIO_PIN_6}; @@ -44,14 +52,32 @@ void ledInit() gpio_init(LED_BLUE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW); #endif -#if defined(FUNCTION_SWITCHES) +#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS) for (size_t i = 0; i < DIM(fsLeds); i++) { gpio_init(fsLeds[i], GPIO_OUT, GPIO_PIN_SPEED_LOW); } #endif } -#if defined(FUNCTION_SWITCHES) +#if defined(FUNCTION_SWITCHES_RGB_LEDS) +// used to map switch number to led number in the rgbled chain +uint8_t ledMapping[] = {0, 1, 2, 3, 4, 5, 6}; + +void fsLedRGB(uint8_t index, uint32_t color) +{ + rgbSetLedColor(ledMapping[index], GET_RED(color), \ + GET_GREEN(color),GET_BLUE(color)); +} + +uint8_t getRGBColorIndex(uint32_t color) +{ + for (uint8_t i = 0; i < (sizeof(colorTable) / sizeof(colorTable[0])); i++) { + if (color == colorTable[i]) + return(i); + } + return 5; // Custom value set with Companion +} +#elif defined(FUNCTION_SWITCHES) void fsLedOff(uint8_t index) { gpio_clear(fsLeds[index]); @@ -62,7 +88,7 @@ void fsLedOn(uint8_t index) gpio_set(fsLeds[index]); } -bool getFSLedState(uint8_t index) +bool fsLedState(uint8_t index) { return gpio_read(fsLeds[index]) ? true : false; } diff --git a/radio/src/targets/taranis/usb_descriptor.h b/radio/src/targets/taranis/usb_descriptor.h index 1cf001348e6..16486677b60 100644 --- a/radio/src/targets/taranis/usb_descriptor.h +++ b/radio/src/targets/taranis/usb_descriptor.h @@ -37,6 +37,10 @@ #define USB_NAME "Radiomaster MT12" #define USB_MANUFACTURER 'R', 'M', '_', 'T', 'X', ' ', ' ', ' ' /* 8 bytes */ #define USB_PRODUCT 'R', 'M', ' ', 'M', 'T', '1', '2', ' ' /* 8 Bytes */ +#elif defined(RADIO_GX12) + #define USB_NAME "Radiomaster GX12" + #define USB_MANUFACTURER 'R', 'M', '_', 'T', 'X', ' ', ' ', ' ' /* 8 bytes */ + #define USB_PRODUCT 'R', 'M', ' ', 'G', 'X', '1', '2', ' ' /* 8 Bytes */ #elif defined(RADIO_POCKET) #define USB_NAME "Radiomaster Pocket" #define USB_MANUFACTURER 'R', 'M', '_', 'T', 'X', ' ', ' ', ' ' /* 8 bytes */ diff --git a/radio/src/tasks/mixer_task.cpp b/radio/src/tasks/mixer_task.cpp index 37a37a68a2a..921c92c7f6c 100644 --- a/radio/src/tasks/mixer_task.cpp +++ b/radio/src/tasks/mixer_task.cpp @@ -28,6 +28,10 @@ #include "hal/usb_driver.h" #include "hal/watchdog_driver.h" +#if defined(HALL_SYNC) && !defined(SIMU) +#include "stm32_gpio.h" +#include "hal/gpio.h" +#endif RTOS_TASK_HANDLE mixerTaskId; RTOS_DEFINE_STACK(mixerTaskId, mixerStack, MIXER_STACK_SIZE); @@ -224,6 +228,10 @@ void doMixerCalculations() tmr10ms_t tmr10ms = get_tmr10ms(); +#if defined(HALL_SYNC) && !defined(SIMU) + gpio_set(HALL_SYNC); +#endif + #if defined(DEBUG_LATENCY_MIXER_RF) || defined(DEBUG_LATENCY_RF_ONLY) static tmr10ms_t lastLatencyToggle = 0; if (tmr10ms - lastLatencyToggle >= 10) { @@ -249,4 +257,8 @@ void doMixerCalculations() DEBUG_TIMER_START(debugTimerEvalMixes); evalMixes(tick10ms); DEBUG_TIMER_STOP(debugTimerEvalMixes); + +#if defined(HALL_SYNC) && !defined(SIMU) + gpio_clear(HALL_SYNC); +#endif } diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 065e3986a04..b3ec71b956c 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -104,6 +104,7 @@ ISTR(PREFLIGHT_POTSLIDER_CHECK); ISTR(PPMUNIT); #if defined(FUNCTION_SWITCHES) ISTR(FUNCTION_SWITCH_GROUPS); +ISTR(FS_COLOR_LIST); #endif #if defined(HELI) @@ -167,6 +168,8 @@ const char STR_MS[] = TR_MS; const char STR_SWITCH[] = TR_SWITCH; #if defined(FUNCTION_SWITCHES) const char STR_GROUPS[] = TR_GROUPS; +const char STR_FS_ON_COLOR[] = TR_FS_ON_COLOR; +const char STR_FS_OFF_COLOR[] = TR_FS_OFF_COLOR; const char STR_LAST[] = TR_LAST; const char STR_MORE_INFO[] = TR_MORE_INFO; const char STR_SWITCH_TYPE[] = TR_SWITCH_TYPE; diff --git a/radio/src/translations.h b/radio/src/translations.h index 94f0ccc5251..d126c949560 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -290,6 +290,9 @@ extern const char STR_MS[]; extern const char STR_SWITCH[]; extern const char STR_FUNCTION_SWITCHES[]; extern const char STR_GROUP[]; +extern const char STR_FS_ON_COLOR[]; +extern const char STR_FS_OFF_COLOR[]; +extern const char* const STR_FS_COLOR_LIST[]; extern const char STR_GROUP_ALWAYS_ON[]; extern const char STR_GROUPS[]; extern const char STR_LAST[]; diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index fdb16e0e662..ef42183a8d3 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -284,8 +284,7 @@ #define TR_MS "ms" #define TR_SWITCH "开关" #define TR_FUNCTION_SWITCHES "可自定义开关" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index 49776023cde..4fa41668eec 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -298,8 +298,7 @@ #define TR_MS "ms" #define TR_SWITCH "Spínač" #define TR_FUNCTION_SWITCHES "Nastavitelné přepínače" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 4b06b3a9dbd..046113931a6 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -291,13 +291,12 @@ #define TR_MS "ms" #define TR_SWITCH "Kontakt" #define TR_FUNCTION_SWITCHES "Kontakter der kan tilpasses" -#define TR_GROUP "Gruppe" -#define TR_GROUP_ALWAYS_ON "Altid til" -#define TR_GROUP "Gruppe" -#define TR_GROUP_ALWAYS_ON "Altid til" -#define TR_GROUPS "Altid til gruppe" -#define TR_LAST "Sidste" -#define TR_MORE_INFO "Mere info" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" +#define TR_GROUP "Group" +#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_GROUPS "Always on groups" +#define TR_LAST "Last" +#define TR_MORE_INFO "More info" #define TR_SWITCH_TYPE "Type" #define TR_SWITCH_STARTUP "Start" #define TR_SWITCH_GROUP "Gruppe" diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index 79d9d91b52e..51414239e43 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -289,10 +289,11 @@ #define TR_MS "ms" #define TR_SWITCH TR("Schalt.", "Schalter") #define TR_FUNCTION_SWITCHES "Anpassbare Schalter" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_ON_COLOR TR("ON:","ON Color") +#define TR_FS_OFF_COLOR TR("OFF:","OFF Color") #define TR_GROUPS "Always on groups" #define TR_LAST "Last" #define TR_MORE_INFO "More info" diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 973f12dea00..968faa75b57 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -288,8 +288,11 @@ #define TR_MS "ms" #define TR_SWITCH "Switch" #define TR_FUNCTION_SWITCHES "Customizable Switches" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_ON_COLOR TR("ON:","ON Color") +#define TR_FS_OFF_COLOR TR("OFF:","OFF Color") #define TR_GROUPS "Always on groups" #define TR_LAST "Last" #define TR_MORE_INFO "More info" diff --git a/radio/src/translations/es.h b/radio/src/translations/es.h index b814b8c1faf..60e3ca21b61 100644 --- a/radio/src/translations/es.h +++ b/radio/src/translations/es.h @@ -286,8 +286,7 @@ #define TR_MS "ms" #define TR_SWITCH TR("Interr.", "Interruptor") #define TR_FUNCTION_SWITCHES "Customizable switches" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/fi.h b/radio/src/translations/fi.h index 412b1daf2a4..2a8e25be1bb 100644 --- a/radio/src/translations/fi.h +++ b/radio/src/translations/fi.h @@ -299,8 +299,7 @@ #define TR_MS "ms" #define TR_SWITCH "Switch" #define TR_FUNCTION_SWITCHES "Customizable switches" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 4563daf5c93..74fb3957154 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -294,6 +294,7 @@ #define TR_MS "ms" #define TR_SWITCH TR("Inter", "Interrupteur") #define TR_FUNCTION_SWITCHES "Inters paramétrables" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/he.h b/radio/src/translations/he.h index 45f7349029d..fc8674d8345 100644 --- a/radio/src/translations/he.h +++ b/radio/src/translations/he.h @@ -292,8 +292,7 @@ #define TR_MS "ms" #define TR_SWITCH "מתג" #define TR_FUNCTION_SWITCHES "מפסקים בהתאמה אישית" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index 81e8824ca1d..3171375c378 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -288,8 +288,7 @@ #define TR_MS "ms" #define TR_SWITCH "Inter." #define TR_FUNCTION_SWITCHES "Interruttori personalizzabili" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index 59653809da1..c6aa7d39ca2 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -287,8 +287,7 @@ #define TR_MS "ms" #define TR_SWITCH "スイッチ" #define TR_FUNCTION_SWITCHES "カスタマイズ スイッチ" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/nl.h b/radio/src/translations/nl.h index 08a6719dca0..7e8a4f23db1 100644 --- a/radio/src/translations/nl.h +++ b/radio/src/translations/nl.h @@ -285,8 +285,7 @@ #define TR_MS "ms" #define TR_SWITCH TR("Schak.", "Schakelaar") #define TR_FUNCTION_SWITCHES "Customizable switches" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index 163e4f3892e..1e151d4aebd 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -285,9 +285,7 @@ #define TR_MS "ms" #define TR_SWITCH "Przełą" #define TR_FUNCTION_SWITCHES "Ustawiane przełączniki" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" -#define TR_GROUP "Group" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" #define TR_LAST "Last" diff --git a/radio/src/translations/pt.h b/radio/src/translations/pt.h index b2762922195..fcd0ef5af8a 100644 --- a/radio/src/translations/pt.h +++ b/radio/src/translations/pt.h @@ -291,8 +291,7 @@ #define TR_MS "ms" #define TR_SWITCH "Chave" #define TR_FUNCTION_SWITCHES "Chaves customizáveis" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/ru.h b/radio/src/translations/ru.h index be6f159ca32..1b1542c3756 100644 --- a/radio/src/translations/ru.h +++ b/radio/src/translations/ru.h @@ -290,8 +290,7 @@ #define TR_MS "ms" #define TR_SWITCH "Тумблер" #define TR_FUNCTION_SWITCHES "Настр тумблеры" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index eb42eab6307..875497f2c6e 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -300,6 +300,7 @@ #define TR_MS "ms" #define TR_SWITCH "Brytare" #define TR_FUNCTION_SWITCHES "Anpassningsbara brytare" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Grupp" #define TR_GROUP_ALWAYS_ON "Alltid på" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index e15d2792535..6b6a63a4ae6 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -289,8 +289,7 @@ #define TR_MS "ms" #define TR_SWITCH "開關" #define TR_FUNCTION_SWITCHES "可自定義開關" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/src/translations/ua.h b/radio/src/translations/ua.h index b3d54a8b422..30bdc1bd43d 100644 --- a/radio/src/translations/ua.h +++ b/radio/src/translations/ua.h @@ -290,8 +290,7 @@ #define TR_MS "ms" #define TR_SWITCH "Перемикач" #define TR_FUNCTION_SWITCHES "Користувацькі перемикачі" -#define TR_GROUP "Group" -#define TR_GROUP_ALWAYS_ON "Always on" +#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom" #define TR_GROUP "Group" #define TR_GROUP_ALWAYS_ON "Always on" #define TR_GROUPS "Always on groups" diff --git a/radio/util/build-firmware.py b/radio/util/build-firmware.py index 34b034eb21e..dead4cd71d2 100755 --- a/radio/util/build-firmware.py +++ b/radio/util/build-firmware.py @@ -164,6 +164,11 @@ def main(): cmake_options["PCBREV"] = "MT12" firmware_options = options_radiomaster_mt12 maxsize = 65536 * 8 * 2 + elif board_name == "gx12": + cmake_options["PCB"] = "X7" + cmake_options["PCBREV"] = "GX12" + firmware_options = options_radiomaster_gx12 + maxsize = 65536 * 8 * 2 elif board_name == "t8": cmake_options["PCB"] = "X7" cmake_options["PCBREV"] = "T8" diff --git a/radio/util/fwoptions.py b/radio/util/fwoptions.py index 016f2dedd07..2a1d09b8786 100755 --- a/radio/util/fwoptions.py +++ b/radio/util/fwoptions.py @@ -259,6 +259,18 @@ "internalelrs": ("INTERNAL_MODULE_ELRS", "YES", "NO"), } +options_radiomaster_gx12 = { + "noheli": ("HELI", "NO", "YES"), + "lua": ("LUA", "YES", "NO_MODEL_SCRIPTS"), + "nogvars": ("GVARS", "NO", "YES"), + "faimode": ("FAI", "YES", None), + "faichoice": ("FAI", "CHOICE", None), + "nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"), + "flexr9m": ("MODULE_PROTOCOL_FLEX", "YES", None), + "afhds3": ("AFHDS3", "YES", "NO"), + "internalelrs": ("INTERNAL_MODULE_ELRS", "YES", "NO"), +} + options_radiomaster_pocket = { "noheli": ("HELI", "NO", "YES"), "lua": ("LUA", "YES", "NO_MODEL_SCRIPTS"), diff --git a/radio/util/hw_defs/hal_switches.py b/radio/util/hw_defs/hal_switches.py index 155d9d64f32..8d84c4182fe 100644 --- a/radio/util/hw_defs/hal_switches.py +++ b/radio/util/hw_defs/hal_switches.py @@ -1,22 +1,27 @@ from switch_config import switch_cfg_by_target + class Switch: + TYPE_2POS = "2POS" + TYPE_3POS = "3POS" + TYPE_ADC = "ADC" - TYPE_2POS = '2POS' - TYPE_3POS = '3POS' - TYPE_ADC = 'ADC' - def __init__(self, name, sw_type, flags): self.name = name self.type = sw_type self.flags = flags + self.inverted = False + self.default = None + self.display = [] + class Switch2POS(Switch): def __init__(self, name, gpio, pin, flags=0): super(Switch2POS, self).__init__(name, Switch.TYPE_2POS, flags) self.gpio = gpio self.pin = pin - + + class Switch3POS(Switch): def __init__(self, name, gpio_high, pin_high, gpio_low, pin_low, flags=0): super(Switch3POS, self).__init__(name, Switch.TYPE_3POS, flags) @@ -25,22 +30,38 @@ def __init__(self, name, gpio_high, pin_high, gpio_low, pin_low, flags=0): self.gpio_low = gpio_low self.pin_low = pin_low + class SwitchADC(Switch): def __init__(self, name, adc_input, flags=0): super(SwitchADC, self).__init__(name, Switch.TYPE_ADC, flags) self.adc_input = adc_input - + + +class SwitchCustom(Switch): + def __init__(self, name, type, flags=0): + super(SwitchCustom, self).__init__(name, type, flags) + def AZ_seq(): - return [chr(i) for i in range(ord('A'), ord('Z') + 1)] + return [chr(i) for i in range(ord("A"), ord("Z") + 1)] + def eprint(*args, **kwargs): from sys import stderr + print(*args, file=stderr, **kwargs) + +def prefixsearch(dictionary, prefix): + for k in dictionary.keys(): + if k.startswith(prefix): + return k[len(prefix) :] + + return None + + # switches from A to Z def parse_switches(target, hw_defs, adc_parser): - switches = [] def find_switch(name): @@ -48,22 +69,22 @@ def find_switch(name): if name == sw.name: return sw return None - + for s in AZ_seq(): + name = f"S{s}" - name = f'S{s}' + reg = f"SWITCHES_GPIO_REG_{s}" + reg_high = f"{reg}_H" + reg_low = f"{reg}_L" - reg = f'SWITCHES_GPIO_REG_{s}' - reg_high = f'{reg}_H' - reg_low = f'{reg}_L' + pin = f"SWITCHES_GPIO_PIN_{s}" + pin_high = f"{pin}_H" + pin_low = f"{pin}_L" - pin = f'SWITCHES_GPIO_PIN_{s}' - pin_high = f'{pin}_H' - pin_low = f'{pin}_L' + inverted = f"SWITCHES_{s}_INVERTED" - inverted = f'SWITCHES_{s}_INVERTED' - - adc_input_name = f'SW{s}' + adc_input_name = f"SW{s}" + custom = f"SWITCHES_{s}_" switch = None if reg in hw_defs: @@ -78,10 +99,13 @@ def find_switch(name): reg_low = hw_defs[reg_low] pin_low = hw_defs[pin_low] switch = Switch3POS(name, reg_high, pin_high, reg_low, pin_low) - else: + elif adc_parser.find_input(adc_input_name): # ADC switch - if adc_parser.find_input(adc_input_name): - switch = SwitchADC(name, adc_input_name) + switch = SwitchADC(name, adc_input_name) + else: + type = prefixsearch(hw_defs, custom) + if type is not None: + switch = SwitchCustom(name, type) if switch: if inverted in hw_defs: @@ -89,18 +113,22 @@ def find_switch(name): cfg = switch_cfg_by_target(target, name) if cfg: - switch.default = cfg.get('default') - switch.display = cfg.get('display') - #eprint(switch.default) + switch.default = cfg.get("default") + switch.display = cfg.get("display") + # eprint(switch.default) switches.append(switch) for i in range(1, 6 + 1): - f_sw_marker = f'FUNCTION_SWITCH_{i}' + f_sw_marker = f"FUNCTION_SWITCH_{i}" if f_sw_marker in hw_defs: switch = find_switch(hw_defs[f_sw_marker]) if switch: - switch.type = 'FSWITCH' - switch.name = f'SW{i}' + switch.type = "FSWITCH" + switch.name = f"SW{i}" + else: + switch = SwitchCustom(f"SW{i}", Switch.TYPE_2POS) + switch.type = "FSWITCH" + switches.append(switch) return switches diff --git a/radio/util/hw_defs/json_index.py b/radio/util/hw_defs/json_index.py index 91d24c2fc1a..9efbe0ee554 100644 --- a/radio/util/hw_defs/json_index.py +++ b/radio/util/hw_defs/json_index.py @@ -1,34 +1,32 @@ - # # These methods are used to build helper indexes on JSON structures # def build_adc_index(adc_inputs): - i = 0 index = {} - for adc_input in adc_inputs['inputs']: - name = adc_input['name'] + for adc_input in adc_inputs["inputs"]: + name = adc_input["name"] index[name] = i i = i + 1 return index + def append_to_index(d, key, val): if key not in d: d[key] = [] d[key].append(val) -def build_adc_gpio_port_index(adc_inputs): +def build_adc_gpio_port_index(adc_inputs): i = 0 gpios = {} - for adc_input in adc_inputs['inputs']: - - if adc_input['adc'] == 'SPI': + for adc_input in adc_inputs["inputs"]: + if adc_input["adc"] == "SPI": continue - - gpio = adc_input['gpio'] + + gpio = adc_input["gpio"] if gpio is None: i = i + 1 continue @@ -36,57 +34,60 @@ def build_adc_gpio_port_index(adc_inputs): if gpio not in gpios: gpios[gpio] = [] - pin = { - 'pin': adc_input['pin'], - 'idx': i - } + pin = {"pin": adc_input["pin"], "idx": i} gpios[gpio].append(pin) i = i + 1 return gpios -def build_switch_gpio_port_index(switches): - i = 0 +def build_switch_gpio_port_index(switches): gpios = {} for switch in switches: - sw_type = switch['type'] + sw_type = switch["type"] - if sw_type == '2POS' or sw_type == 'FSWITCH': - append_to_index(gpios, switch['gpio'], switch['pin']) + if sw_type == "2POS" or sw_type == "FSWITCH": + gpio = switch.get("gpio") + pin = switch.get("pin") + if gpio is not None and pin is not None: + append_to_index(gpios, gpio, pin) - elif sw_type == '3POS': + elif sw_type == "3POS": + gpio_high = switch.get("gpio_high") + pin_high = switch.get("pin_high") + if gpio_high is not None and pin_high is not None: + append_to_index(gpios, gpio_high, pin_high) - append_to_index(gpios, switch['gpio_high'], switch['pin_high']) - append_to_index(gpios, switch['gpio_low'], switch['pin_low']) + gpio_low = switch.get("gpio_low") + pin_low = switch.get("pin_low") + if gpio_low is not None and pin_low is not None: + append_to_index(gpios, gpio_low, pin_low) return gpios -def build_trim_gpio_port_index(trims): +def build_trim_gpio_port_index(trims): def index_contact(gpios, contact): - gpio = contact['gpio'] - pin = contact['pin'] + gpio = contact["gpio"] + pin = contact["pin"] if gpio and pin: - append_to_index(gpios, contact['gpio'], contact['pin']) + append_to_index(gpios, contact["gpio"], contact["pin"]) - i = 0 gpios = {} for trim in trims: - dec = trim.get('dec') - inc = trim.get('inc') + dec = trim.get("dec") + inc = trim.get("inc") if dec and inc: index_contact(gpios, dec) index_contact(gpios, inc) return gpios -def build_key_gpio_port_index(keys): - i = 0 +def build_key_gpio_port_index(keys): gpios = {} for key in keys: - append_to_index(gpios, key['gpio'], key['pin']) + append_to_index(gpios, key["gpio"], key["pin"]) return gpios diff --git a/radio/util/hw_defs/legacy_names.py b/radio/util/hw_defs/legacy_names.py index 76f2c70b475..1eb60d719a7 100644 --- a/radio/util/hw_defs/legacy_names.py +++ b/radio/util/hw_defs/legacy_names.py @@ -343,6 +343,59 @@ } } }, + { + "targets": {"gx12"}, + "inputs": { + "LH": { + "yaml": "Rud", + "lua": "rud", + "description": "Rudder" + }, + "LV": { + "yaml": "Ele", + "lua": "ele", + "description": "Elevator" + }, + "RV": { + "yaml": "Thr", + "lua": "thr", + "description": "Throttle" + }, + "RH": { + "yaml": "Ail", + "lua": "ail", + "description": "Aileron" + }, + "P1": { + "yaml": "POT1", + "lua": "p1", + "label": "P1", + "short_label": "1", + "description": "Potentiometer 1" + }, + "P2": { + "yaml": "POT2", + "lua": "p2", + "label": "P2", + "short_label": "2", + "description": "Potentiometer 2" + }, + "SL1": { + "yaml": "SLIDER1", + "lua": "s1", + "label": "S1", + "short_label": "S1", + "description": "Left slider" + }, + "SL2": { + "yaml": "SLIDER2", + "lua": "s2", + "label": "S2", + "short_label": "S2", + "description": "Right slider" + } + } + }, { "targets": {"mt12"}, "inputs": { diff --git a/radio/util/hw_defs/pot_config.py b/radio/util/hw_defs/pot_config.py index 2d3159065cf..153beb93c8a 100644 --- a/radio/util/hw_defs/pot_config.py +++ b/radio/util/hw_defs/pot_config.py @@ -4,7 +4,14 @@ "boxer": { "P1": {"default": "POT_CENTER"}, "P2": {"default": "POT_CENTER"}, - "P3": {"default": "MULTIPOS"} + "S1": {"default": "SLIDER"}, + "S2": {"default": "SLIDER"} + }, + "gx12": { + "P1": {"default": "POT_CENTER"}, + "P2": {"default": "POT_CENTER"}, + "SL1": {"default": "SLIDER"}, + "SL2": {"default": "SLIDER"} }, "el18": { "P1": {"default": "POT_CENTER"}, diff --git a/radio/util/hw_defs/stm32_switches.jinja b/radio/util/hw_defs/stm32_switches.jinja index 0eab64c4ac1..32010075f0e 100644 --- a/radio/util/hw_defs/stm32_switches.jinja +++ b/radio/util/hw_defs/stm32_switches.jinja @@ -11,15 +11,18 @@ static const stm32_switch_t _switch_defs[] = { {% if switch.type == '2POS' %} { "{{ switch.name }}", - {{ switch.gpio }}, {{ switch.pin }}, + {{ switch.gpio or "nullptr" }}, + {{ switch.pin or 0 }}, nullptr, 0, SWITCH_HW_2POS, {{ 'SWITCH_HW_INVERTED' if switch.inverted else 0 }} }, {% elif switch.type == '3POS' %} { "{{ switch.name }}", - {{ switch.gpio_high }}, {{ switch.pin_high }}, - {{ switch.gpio_low }}, {{ switch.pin_low }}, + {{ switch.gpio_high or "nullptr" }}, + {{ switch.pin_high or 0 }}, + {{ switch.gpio_low or "nullptr" }}, + {{ switch.pin_low or 0 }}, SWITCH_HW_3POS, {{ 'SWITCH_HW_INVERTED' if switch.inverted else 0 }} }, {% elif switch.type == 'ADC' %} @@ -34,7 +37,8 @@ static const stm32_switch_t _switch_defs[] = { {% for switch in function_switches %} { "{{ switch.name }}", - {{ switch.gpio }}, {{ switch.pin }}, + {{ switch.gpio or "nullptr" }}, + {{ switch.pin or 0 }}, nullptr, 0, SWITCH_HW_2POS, {{ 'SWITCH_HW_INVERTED' if switch.inverted else 0 }} }, diff --git a/radio/util/hw_defs/switch_config.py b/radio/util/hw_defs/switch_config.py index 8dd9a8f55f7..523cc69f81e 100644 --- a/radio/util/hw_defs/switch_config.py +++ b/radio/util/hw_defs/switch_config.py @@ -5,11 +5,25 @@ # left side "SA": {"default": "2POS", "display": [0, 0]}, "SB": {"default": "3POS", "display": [0, 1]}, - "SE": {"default": "2POS", "display": [0, 2]}, + "SE": {"default": "3POS", "display": [0, 2]}, + "SG": {"default": "2POS", "display": [0, 3]}, # right side "SC": {"default": "3POS", "display": [1, 0]}, "SD": {"default": "2POS", "display": [1, 1]}, "SF": {"default": "TOGGLE", "display": [1, 2]}, + "SH": {"default": "2POS", "display": [1, 3]}, + }, + "gx12": { + # left side + "SA": {"default": "TOGGLE", "display": [0, 0]}, + "SB": {"default": "3POS", "display": [0, 1]}, + "SE": {"default": "3POS", "display": [0, 2]}, + "SG": {"default": "TOGGLE", "display": [0, 3]}, + # right side + "SC": {"default": "3POS", "display": [1, 1]}, + "SD": {"default": "TOGGLE", "display": [1, 0]}, + "SF": {"default": "3POS", "display": [1, 2]}, + "SH": {"default": "TOGGLE", "display": [1, 3]}, }, "commando8": { # left side diff --git a/tools/build-common.sh b/tools/build-common.sh index d1c8cd23d3b..6989b4f900b 100644 --- a/tools/build-common.sh +++ b/tools/build-common.sh @@ -23,6 +23,9 @@ get_target_build_options() { tx12mk2) BUILD_OPTIONS+="-DPCB=X7 -DPCBREV=TX12MK2" ;; + gx12) + BUILD_OPTIONS+="-DPCB=X7 -DPCBREV=GX12" + ;; boxer) BUILD_OPTIONS+="-DPCB=X7 -DPCBREV=BOXER" ;; diff --git a/tools/build-companion.sh b/tools/build-companion.sh index 7b4f939ef70..b06dea441cd 100755 --- a/tools/build-companion.sh +++ b/tools/build-companion.sh @@ -69,7 +69,7 @@ cd build declare -a simulator_plugins=(x9lite x9lites x7 x7access t8 t12 t12max tx12 tx12mk2 - zorro commando8 boxer pocket mt12 + zorro commando8 boxer pocket mt12 gx12 tlite tpro tprov2 tpros bumblebee lr3pro t14 x9d x9dp x9dp2019 x9e xlite xlites diff --git a/tools/generate-hw-defs.sh b/tools/generate-hw-defs.sh index 767fa833bdc..d2bee0ce781 100755 --- a/tools/generate-hw-defs.sh +++ b/tools/generate-hw-defs.sh @@ -5,11 +5,11 @@ set -e # set -x SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -. "$SCRIPT_DIR/build-common.sh" +. "$SCRIPT_DIR/build-common.sh" : "${SRCDIR:=$(dirname "$(pwd)/$0")/..}" -: ${FLAVOR:="nv14;el18;t12;t12max;t15;t16;t18;t8;zorro;pocket;commando8;tlite;tpro;tprov2;tpros;bumblebee;t20;t20v2;t14;lr3pro;mt12;tx12;tx12mk2;boxer;tx16s;x10;x10express;x12s;x7;x7access;x9d;x9dp;x9dp2019;x9e;x9lite;x9lites;xlite;xlites;f16;v14;v12"} +: ${FLAVOR:="nv14;el18;t12;t12max;t15;t16;t18;t8;zorro;pocket;commando8;tlite;tpro;tprov2;tpros;bumblebee;t20;t20v2;t14;lr3pro;mt12;gx12;tx12;tx12mk2;boxer;tx16s;x10;x10express;x12s;x7;x7access;x9d;x9dp;x9dp2019;x9e;x9lite;x9lites;xlite;xlites;f16;v14;v12"} : ${COMMON_OPTIONS:="-DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_RULE_MESSAGES=OFF -Wno-dev -DCMAKE_MESSAGE_LOG_LEVEL=WARNING"} # wipe build directory clean diff --git a/tools/generate-yaml.sh b/tools/generate-yaml.sh index 23e2ff429c4..71ada347431 100755 --- a/tools/generate-yaml.sh +++ b/tools/generate-yaml.sh @@ -4,14 +4,14 @@ set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -. "$SCRIPT_DIR/build-common.sh" +. "$SCRIPT_DIR/build-common.sh" # Add GCC_ARM to PATH if [[ -n ${GCC_ARM} ]] ; then export PATH=${GCC_ARM}:$PATH fi -: ${FLAVOR:="t15;tx16s;nv14;pl18;x9d;x9dp2019;x9e;xlite;xlites;x7;tpro;t20;f16"} +: ${FLAVOR:="t15;tx16s;nv14;pl18;x9d;x9dp2019;x9e;xlite;xlites;x7;tpro;t20;f16;gx12"} : ${SRCDIR:=$(dirname "$(pwd)/$0")/..} : ${COMMON_OPTIONS:="-DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_RULE_MESSAGES=OFF -Wno-dev -DDISABLE_COMPANION=YES -DCMAKE_MESSAGE_LOG_LEVEL=WARNING"} diff --git a/tools/msys2_fetch_and_build_all.sh b/tools/msys2_fetch_and_build_all.sh index a40cc454f1b..56571573cbb 100644 --- a/tools/msys2_fetch_and_build_all.sh +++ b/tools/msys2_fetch_and_build_all.sh @@ -9,7 +9,7 @@ # ----------------------------------------------------------------------------- export BRANCH_NAME="main" # main|2.9|... -export RADIO_TYPE="tx16s" # tx16s|x10|x10express|x12s|x9d|x9dp|x9lite|x9lites|x7|x7access|t12|t12max|tx12|tx12mk2|mt12|boxer|t8|zorro|pocket|tlite|tpro|t20|t20v2|t14|lr3pro|xlite|xlites|x9dp2019|x9e|x9e-hall|t15|t16|t18|nv14|commando8 +export RADIO_TYPE="tx16s" # tx16s|x10|x10express|x12s|x9d|x9dp|x9lite|x9lites|x7|x7access|t12|t12max|tx12|tx12mk2|mt12|gx12|boxer|t8|zorro|pocket|tlite|tpro|t20|t20v2|t14|lr3pro|xlite|xlites|x9dp2019|x9e|x9e-hall|t15|t16|t18|nv14|commando8 export BUILD_OPTIONS="-DDEFAULT_MODE=2 -DGVARS=YES" @@ -33,6 +33,9 @@ case $RADIO_TYPE in mt12) BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=MT12 -DINTERNAL_MODULE_MULTI=ON" ;; + gx12) + BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=GX12 -DINTERNAL_MODULE_MULTI=ON" + ;; tx12) BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=TX12" ;;