From 48a59e711f1dd06f59acae246b0c6341a996392d Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sat, 29 Jul 2023 10:02:44 +0200 Subject: [PATCH 01/34] initial commit --- radio/src/dataconstants.h | 8 ++ radio/src/datastructs_private.h | 5 + radio/src/gui/colorlcd/LvglWrapper.cpp | 22 +++- radio/src/gui/colorlcd/radio_setup.cpp | 9 +- radio/src/gui/colorlcd/tabsgroup.cpp | 4 +- radio/src/gui/colorlcd/view_main.cpp | 4 +- radio/src/keys.cpp | 110 ++++++++++++++++-- radio/src/lua/api_general.cpp | 2 +- radio/src/lua/interface.cpp | 6 +- radio/src/main.cpp | 28 +++++ .../storage/yaml/yaml_datastructs_nv14.cpp | 2 +- .../common/arm/stm32/bootloader/boot.cpp | 4 +- radio/src/targets/nv14/hal.h | 3 + radio/src/translations.cpp | 8 ++ radio/src/translations.h | 7 ++ radio/src/translations/cn.h | 7 ++ radio/src/translations/cz.h | 7 ++ radio/src/translations/da.h | 7 ++ radio/src/translations/de.h | 7 ++ radio/src/translations/en.h | 7 ++ radio/src/translations/es.h | 7 ++ radio/src/translations/fi.h | 7 ++ radio/src/translations/fr.h | 7 ++ radio/src/translations/he.h | 7 ++ radio/src/translations/it.h | 7 ++ radio/src/translations/jp.h | 7 ++ radio/src/translations/nl.h | 7 ++ radio/src/translations/pl.h | 7 ++ radio/src/translations/pt.h | 7 ++ radio/src/translations/se.h | 7 ++ radio/src/translations/tw.h | 7 ++ 31 files changed, 309 insertions(+), 25 deletions(-) diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 9dadcc0f6db..1b6ab3c1c8b 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -657,6 +657,14 @@ enum BluetoothModes { #endif }; +#if defined(USE_TRIMS_AS_BUTTONS) +enum enumHatsMode { + HATS_MODE_TRIMS_ONLY, + HATS_MODE_BUTTONS_ONLY, + HATS_MODE_BOTH +}; +#endif + enum UartSampleModes { UART_SAMPLE_MODE_NORMAL = 0, UART_SAMPLE_MODE_ONEBIT, diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index 0dd13401e08..f5621566bfe 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -939,7 +939,12 @@ PACK(struct RadioData { char ownerRegistrationID[PXX2_LEN_REGISTRATION_ID]; CUST_ATTR(rotEncDirection, r_rotEncDirection, nullptr); + +#if defined(USE_TRIMS_AS_BUTTONS) + NOBACKUP(uint8_t hatsMode:2); +#else NOBACKUP(uint8_t rotEncMode:2); +#endif NOBACKUP(int8_t uartSampleMode:2); // See UartSampleModes diff --git a/radio/src/gui/colorlcd/LvglWrapper.cpp b/radio/src/gui/colorlcd/LvglWrapper.cpp index 6c7109feb51..7d496a9694c 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.cpp +++ b/radio/src/gui/colorlcd/LvglWrapper.cpp @@ -235,7 +235,27 @@ extern "C" void touchDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data) #endif } -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(USE_TRIMS_AS_BUTTONS) + +int16_t getEmuRotaryData(); + +static void rotaryDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data) +{ + int16_t diff = getEmuRotaryData(); + + if(diff != 0) { + reset_inactivity(); + audioKeyPress(); + + data->enc_diff = diff; + data->state = LV_INDEV_STATE_RELEASED; + } +} + +// libopenui_depends.h +int8_t rotaryEncoderGetAccel() { return 0; } + +#elif defined(ROTARY_ENCODER_NAVIGATION) extern volatile uint32_t rotencDt; static int8_t _rotary_enc_accel = 0; diff --git a/radio/src/gui/colorlcd/radio_setup.cpp b/radio/src/gui/colorlcd/radio_setup.cpp index e81e7823bcb..6a6ce0abc6d 100644 --- a/radio/src/gui/colorlcd/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio_setup.cpp @@ -803,7 +803,7 @@ void RadioSetupPage::build(FormWindow * window) new Choice(line, rect_t{}, STR_USBMODES, USB_UNSELECTED_MODE, USB_MAX_MODE, GET_SET_DEFAULT(g_eeGeneral.USBMode)); -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) line = window->newLine(&grid); new StaticText(line, rect_t{}, STR_ROTARY_ENC_MODE, 0, COLOR_THEME_PRIMARY1); new Choice(line, rect_t{}, STR_ROTARY_ENC_OPT, ROTARY_ENCODER_MODE_NORMAL, @@ -811,6 +811,13 @@ void RadioSetupPage::build(FormWindow * window) GET_SET_DEFAULT(g_eeGeneral.rotEncMode)); #endif +#if defined(USE_TRIMS_AS_BUTTONS) + line = window->newLine(&grid); + new StaticText(line, rect_t{}, STR_HATS_MODE, 0, COLOR_THEME_PRIMARY1); + new Choice(line, rect_t{}, STR_HATS_OPT, HATS_MODE_TRIMS_ONLY, HATS_MODE_BOTH, + GET_SET_DEFAULT(g_eeGeneral.hatsMode)); +#endif + // RX channel order line = window->newLine(&grid); new StaticText(line, rect_t{}, STR_DEF_CHAN_ORD, 0, diff --git a/radio/src/gui/colorlcd/tabsgroup.cpp b/radio/src/gui/colorlcd/tabsgroup.cpp index b9be76edae3..affcf788cb5 100644 --- a/radio/src/gui/colorlcd/tabsgroup.cpp +++ b/radio/src/gui/colorlcd/tabsgroup.cpp @@ -273,7 +273,7 @@ void TabsGroup::onEvent(event_t event) #if defined(HARDWARE_KEYS) TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event); -#if defined(KEYS_GPIO_REG_PAGEUP) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) if (event == EVT_KEY_FIRST(KEY_PAGEDN)) { #else if (event == EVT_KEY_BREAK(KEY_PAGEDN)) { @@ -282,7 +282,7 @@ void TabsGroup::onEvent(event_t event) uint8_t current = header.carousel.getCurrentIndex() + 1; setCurrentTab(current >= tabs.size() ? 0 : current); } -#if defined(KEYS_GPIO_REG_PAGEUP) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) else if (event == EVT_KEY_FIRST(KEY_PAGEUP)) { #else else if (event == EVT_KEY_LONG(KEY_PAGEDN)) { diff --git a/radio/src/gui/colorlcd/view_main.cpp b/radio/src/gui/colorlcd/view_main.cpp index 9012faa7ab1..7a6409a196f 100644 --- a/radio/src/gui/colorlcd/view_main.cpp +++ b/radio/src/gui/colorlcd/view_main.cpp @@ -279,7 +279,7 @@ void ViewMain::onEvent(event_t event) new ScreenMenu(); break; -#if defined(KEYS_GPIO_REG_PAGEUP) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) case EVT_KEY_FIRST(KEY_PAGEDN): #else case EVT_KEY_BREAK(KEY_PAGEDN): @@ -292,7 +292,7 @@ void ViewMain::onEvent(event_t event) //TODO: these need to go away! // -> board code should map the keys as required -#if defined(KEYS_GPIO_REG_PAGEUP) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) case EVT_KEY_FIRST(KEY_PAGEUP): #else case EVT_KEY_LONG(KEY_PAGEDN): diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index f10af2cc84c..6eb231b1fec 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -18,6 +18,11 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ +#if !defined(BOOT) +#include "opentx.h" +#endif + +#include "debug.h" #include "keys.h" @@ -296,21 +301,101 @@ static bool _trims_as_buttons = false; void setTrimsAsButtons(bool val) { _trims_as_buttons = val; } bool getTrimsAsButtons() { return _trims_as_buttons; } -static uint32_t transpose_trims() +int16_t getEmuRotaryData() { + static bool rotaryTrimPressed = false; + static tmr10ms_t timePressed = 0; + + if(!getTrimsAsButtons()) + return 0; + + tmr10ms_t now = get_tmr10ms(); + + if(rotaryTrimPressed && (now > (timePressed + 10))) // 100ms repeat key update rate + rotaryTrimPressed = false; + + auto trims = readTrims(); + + if (trims & (1 << 4)) { + if(!rotaryTrimPressed) { + rotaryTrimPressed = true; + timePressed = now; + return 1; + } + } + + if (trims & (1 << 5)) { + if(!rotaryTrimPressed) { + rotaryTrimPressed = true; + timePressed = now; + return -1; + } + } + + return 0; +} + +static void transpose_trims(uint32_t *keys) { - uint32_t keys = 0; +#if defined(BOOT) auto trims = readTrims(); - if (trims & (1 << 0)) keys |= 1 << KEY_SYS; - if (trims & (1 << 1)) keys |= 1 << KEY_TELE; - if (trims & (1 << 2)) keys |= 1 << KEY_PAGEUP; - if (trims & (1 << 3)) keys |= 1 << KEY_PAGEDN; - if (trims & (1 << 4)) keys |= 1 << KEY_DOWN; - if (trims & (1 << 5)) keys |= 1 << KEY_UP; - if (trims & (1 << 6)) keys |= 1 << KEY_LEFT; - if (trims & (1 << 7)) keys |= 1 << KEY_RIGHT; + if (trims & (1 << 4)) *keys |= 1 << KEY_DOWN; // right hat, down 0x10 + if (trims & (1 << 5)) *keys |= 1 << KEY_UP; // right hat, up 0x20 +#else + static uint8_t state = 0; + + if(g_eeGeneral.hatsMode == HATS_MODE_BOTH) { + static bool lastExitState = false; + static bool lastEnterState = false; + + bool exitState = *keys & (1 << KEY_EXIT); // edge detection for EXIT and ENTER keys + bool enterState = *keys & (1 << KEY_ENTER); + + bool exitPressed = !lastExitState && exitState; + bool exitReleased = lastExitState && !exitState; + bool enterPressed = !lastEnterState && enterState; + + lastExitState = exitState; + lastEnterState = enterState; + + switch(state) { + case 0: // idle state waiting for EXIT or ENTER key + if(exitPressed) { + state = 1; + } + break; + + case 1: // state EXIT received + if(exitReleased) { // if exit released go back to idle state + state = 0; + break; + } + + if(enterPressed) { // ENTER received with EXIT still pressed + setTrimsAsButtons(!getTrimsAsButtons()); // change mode and don't forward EXIT and ENTER keys + killEvents(KEY_EXIT); + killEvents(KEY_ENTER); + state = 0; // go to for EXIT to be released + break; + } + break; + } + } else + state = 0; // state machine in idle if not in mode "BOTH" + + if(getTrimsAsButtons()) { // map hats to keys in button mode + auto trims = readTrims(); + + if (trims & (1 << 0)) *keys |= 1 << KEY_EXIT; // left hat, left 0x01 + if (trims & (1 << 1)) *keys |= 1 << KEY_MODEL; // left hat, right 0x02 + if (trims & (1 << 2)) *keys |= 1 << KEY_TELE; // left hat, down 0x04 + if (trims & (1 << 3)) *keys |= 1 << KEY_SYS; // left hat, up 0x08 + + if (trims & (1 << 6)) *keys |= 1 << KEY_PAGEUP; // rht, left 0x40 + if (trims & (1 << 7)) *keys |= 1 << KEY_PAGEDN; // rht, right 0x80 + } - return keys; +#endif } #endif @@ -320,8 +405,9 @@ bool keysPollingCycle() uint32_t keys_input = readKeys(); #if defined(USE_TRIMS_AS_BUTTONS) + transpose_trims(&keys_input); + if (getTrimsAsButtons()) { - keys_input |= transpose_trims(); trims_input = 0; } else { trims_input = readTrims(); diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 427486ad6af..b2588c55395 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -886,7 +886,7 @@ Return rotary encoder mode */ static int luaGetRotEncMode(lua_State * L) { -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) lua_pushunsigned(L, g_eeGeneral.rotEncMode); #else lua_pushunsigned(L, 0); diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index bd24e49ff1b..91d846a5b0a 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -253,7 +253,7 @@ void luaDisable() luaState = INTERPRETER_PANIC; #if defined(USE_TRIMS_AS_BUTTONS) - if (_is_standalone_script()) setTrimsAsButtons(false); + //if (_is_standalone_script()) setTrimsAsButtons(false); #endif } @@ -1254,7 +1254,7 @@ bool luaTask(event_t evt, bool allowLcdUsage) luaState = INTERPRETER_LOADING; #if defined(USE_TRIMS_AS_BUTTONS) - if (_is_standalone_script()) setTrimsAsButtons(false); + //if (_is_standalone_script()) setTrimsAsButtons(false); #endif case INTERPRETER_LOADING: @@ -1270,7 +1270,7 @@ bool luaTask(event_t evt, bool allowLcdUsage) luaState = INTERPRETER_RUNNING; #if defined(USE_TRIMS_AS_BUTTONS) - if (_is_standalone_script()) setTrimsAsButtons(true); + //if (_is_standalone_script()) setTrimsAsButtons(true); #endif case INTERPRETER_RUNNING: diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 0957794f4fc..65203052d31 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -266,6 +266,30 @@ void checkSpeakerVolume() } } +#if defined(USE_TRIMS_AS_BUTTONS) +void checkTrimsAsButtons() { + static bool oldHatsModeButtons = g_eeGeneral.hatsMode == HATS_MODE_BUTTONS_ONLY; + + if(g_eeGeneral.hatsMode == HATS_MODE_TRIMS_ONLY) { + setTrimsAsButtons(false); + } + + if(g_eeGeneral.hatsMode == HATS_MODE_BUTTONS_ONLY) { + setTrimsAsButtons(true); + } + + bool hatsModeButtons = getTrimsAsButtons(); + + if(hatsModeButtons == oldHatsModeButtons) + return; + + oldHatsModeButtons = !oldHatsModeButtons; + + audioKeyPress(); + POPUP_INFORMATION(hatsModeButtons ? STR_HATS_MODE_BUTTONS : STR_HATS_MODE_TRIMS); +} +#endif + #if defined(EEPROM) void checkEeprom() { @@ -525,6 +549,10 @@ void perMain() checkBacklight(); +#if defined(USE_TRIMS_AS_BUTTONS) + checkTrimsAsButtons(); +#endif + #if !defined(LIBOPENUI) event_t evt = getEvent(); #endif diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 7ea0b13d64d..c21c55c8134 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -379,7 +379,7 @@ static const struct YamlNode struct_RadioData[] = { YAML_STRUCT("themeData", 480, struct_EdgeTxTheme__PersistentData, NULL), YAML_STRING("ownerRegistrationID", 8), YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr), - YAML_UNSIGNED( "rotEncMode", 2 ), + YAML_UNSIGNED( "hatsMode", 2 ), YAML_SIGNED( "uartSampleMode", 2 ), YAML_UNSIGNED( "stickDeadZone", 3 ), YAML_UNSIGNED( "audioMuteEnable", 1 ), diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index 0839e8d7f4b..5012d5ad6b6 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -105,7 +105,7 @@ void interrupt10ms() keysPollingCycle(); -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) static rotenc_t rePreviousValue; rotenc_t reNewValue = rotaryEncoderGetValue(); @@ -288,7 +288,7 @@ void bootloaderInitApp() pwrOn(); -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) rotaryEncoderInit(); #endif diff --git a/radio/src/targets/nv14/hal.h b/radio/src/targets/nv14/hal.h index 8b50df5a51d..84a8d600c8e 100644 --- a/radio/src/targets/nv14/hal.h +++ b/radio/src/targets/nv14/hal.h @@ -516,6 +516,9 @@ #define BLUETOOTH_ON_GPIO GPIOI #define BLUETOOTH_ON_GPIO_PIN GPIO_Pin_8 // PI.8 +//ROTARY emulation for trims as buttons +#define ROTARY_ENCODER_NAVIGATION + // Bluetooth #define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOH) #define BT_RCC_APB1Periph (RCC_APB1Periph_USART3) diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index cbebc2aab84..4bf96010762 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -538,6 +538,14 @@ const char STR_DATE[] = TR_DATE; const char STR_CHANNELS_MONITOR[] = TR_CHANNELS_MONITOR; const char STR_ROTARY_ENCODER[] = TR_ROTARY_ENCODER; const char STR_ROTARY_ENC_MODE[] = TR_ROTARY_ENC_MODE; + +#if defined(USE_TRIMS_AS_BUTTONS) +const char STR_HATS_MODE[] = TR_HATS_MODE; +ISTR(HATS_OPT); +const char STR_HATS_MODE_TRIMS[] = TR_HATS_MODE_TRIMS; +const char STR_HATS_MODE_BUTTONS[] = TR_HATS_MODE_BUTTONS; +#endif + const char STR_MIXERS_MONITOR[] = TR_MIXERS_MONITOR; const char STR_PATH_TOO_LONG[] = TR_PATH_TOO_LONG; const char STR_VIEW_TEXT[] = TR_VIEW_TEXT; diff --git a/radio/src/translations.h b/radio/src/translations.h index 9b347768075..f70aad8d0b2 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -174,6 +174,13 @@ extern const char* const STR_CYC_VSRCRAW[]; extern const char* const STR_ROTARY_ENC_OPT[]; +#if defined(USE_TRIMS_AS_BUTTONS) +extern const char STR_HATS_MODE[]; +extern const char* const STR_HATS_OPT[]; +extern const char STR_HATS_MODE_TRIMS[]; +extern const char STR_HATS_MODE_BUTTONS[]; +#endif + extern const char* const STR_VTMRMODES[]; extern const char* const STR_VPERSISTENT[]; diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index 6a568344add..69bb89dd891 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -152,6 +152,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "正常","反向" #else diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index 77dc4dc6f01..dc1d9a201f2 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -164,6 +164,13 @@ #define TR_ON_ONE_SWITCHES "ZAP","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Invertován" #else diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 0c23636d2a1..1b33f61735b 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -160,6 +160,13 @@ #define TR_ON_ONE_SWITCHES "EN","En" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Invers" #else diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index 378e1b7a0ab..34d733d0821 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -154,6 +154,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Inverted" #else diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 80e6c1de38b..cc5393b137c 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -157,6 +157,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Inverted" #else diff --git a/radio/src/translations/es.h b/radio/src/translations/es.h index 876b77a3dee..0a67a7dfe88 100644 --- a/radio/src/translations/es.h +++ b/radio/src/translations/es.h @@ -152,6 +152,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Inverted" #else diff --git a/radio/src/translations/fi.h b/radio/src/translations/fi.h index c9437d12553..a29d2d144ea 100644 --- a/radio/src/translations/fi.h +++ b/radio/src/translations/fi.h @@ -163,6 +163,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Inverted" #else diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 38c1c0bfcea..8c2a5a72797 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -164,6 +164,13 @@ #define TR_ON_ONE_SWITCHES "ON","Un" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Inversé" #else diff --git a/radio/src/translations/he.h b/radio/src/translations/he.h index 736f9ed2956..8784f808c51 100644 --- a/radio/src/translations/he.h +++ b/radio/src/translations/he.h @@ -241,6 +241,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "רגיל","הפוך" #else diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index 5eca927a51d..e707df1495e 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -157,6 +157,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normale","Invertito" #else diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index f0aaed4915c..aef8aea0698 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -157,6 +157,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "標準","リバース" #else diff --git a/radio/src/translations/nl.h b/radio/src/translations/nl.h index d6404e5c6f5..7c791fddfb9 100644 --- a/radio/src/translations/nl.h +++ b/radio/src/translations/nl.h @@ -154,6 +154,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Inverted" #else diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index 776d9d201a5..a5f4c9ebb35 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -152,6 +152,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Inverted" #else diff --git a/radio/src/translations/pt.h b/radio/src/translations/pt.h index 19b4d0b51f7..38a74db9f56 100644 --- a/radio/src/translations/pt.h +++ b/radio/src/translations/pt.h @@ -160,6 +160,13 @@ #define TR_ON_ONE_SWITCHES "LIG","UM" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "Normal","Invert" #else diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index 2822c9e615f..5d0fe7cd63d 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -175,6 +175,13 @@ #define TR_ON_ONE_SWITCHES "PÅ","Ett" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(IMU) #define TR_IMU_VSRCRAW "TltX","TltY", #else diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index d7a63dde214..e7a0dfe51ca 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -157,6 +157,13 @@ #define TR_ON_ONE_SWITCHES "ON","One" +#if defined(USE_TRIMS_AS_BUTTONS) +#define TR_HATS_MODE "Hats mode" +#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_MODE_TRIMS "Hats mode: Trims" +#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#endif + #if defined(COLORLCD) #define TR_ROTARY_ENC_OPT "正常","反向" #else From ca2baee3747fcbded2272bcf778c9543ae7bab3a Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sat, 29 Jul 2023 20:47:19 +0200 Subject: [PATCH 02/34] Radio: cleanup Companion: integrated hast mode selection in radio setup --- .../firmwares/edgetx/yaml_generalsettings.cpp | 2 ++ companion/src/firmwares/generalsettings.h | 1 + companion/src/generaledit/generalsetup.cpp | 16 ++++++++++++ companion/src/generaledit/generalsetup.h | 1 + companion/src/translations/companion_cs.ts | 20 +++++++++++++++ companion/src/translations/companion_da.ts | 25 +++++++++++++++++++ companion/src/translations/companion_de.ts | 20 +++++++++++++++ companion/src/translations/companion_en.ts | 20 +++++++++++++++ companion/src/translations/companion_es.ts | 20 +++++++++++++++ companion/src/translations/companion_fi.ts | 20 +++++++++++++++ companion/src/translations/companion_fr.ts | 20 +++++++++++++++ companion/src/translations/companion_he.ts | 20 +++++++++++++++ companion/src/translations/companion_it.ts | 20 +++++++++++++++ companion/src/translations/companion_ja.ts | 20 +++++++++++++++ companion/src/translations/companion_nl.ts | 20 +++++++++++++++ companion/src/translations/companion_pl.ts | 20 +++++++++++++++ companion/src/translations/companion_pt.ts | 20 +++++++++++++++ companion/src/translations/companion_ru.ts | 20 +++++++++++++++ companion/src/translations/companion_sv.ts | 21 +++++++++++++++- companion/src/translations/companion_zh_CN.ts | 21 ++++++++++++++++ companion/src/translations/companion_zh_TW.ts | 20 +++++++++++++++ radio/src/keys.cpp | 4 +-- radio/src/targets/simu/opentxsimulator.cpp | 2 +- 23 files changed, 368 insertions(+), 5 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index 6e0cd4eee3c..81e727c2eeb 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -181,6 +181,7 @@ Node convert::encode(const GeneralSettings& rhs) node["disableAlarmWarning"] = (int)rhs.disableAlarmWarning; node["disableRssiPoweroffAlarm"] = (int)rhs.disableRssiPoweroffAlarm; node["USBMode"] = rhs.usbMode; + node["hatsMode"] = rhs.hatsMode; node["stickDeadZone"] = rhs.stickDeadZone; node["jackMode"] = rhs.jackMode; node["hapticMode"] = rhs.hapticMode; @@ -434,6 +435,7 @@ bool convert::decode(const Node& node, GeneralSettings& rhs) node["disableAlarmWarning"] >> rhs.disableAlarmWarning; node["disableRssiPoweroffAlarm"] >> rhs.disableRssiPoweroffAlarm; node["USBMode"] >> rhs.usbMode; + node["hatsMode"] >> rhs.hatsMode; node["stickDeadZone"] >> rhs.stickDeadZone; node["jackMode"] >> rhs.jackMode; node["hapticMode"] >> rhs.hapticMode; diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index f5b40e23ca2..3f979bb0b37 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -206,6 +206,7 @@ class GeneralSettings { bool disableAlarmWarning; bool disableRssiPoweroffAlarm; unsigned int usbMode; + unsigned int hatsMode; unsigned int stickDeadZone; unsigned int jackMode; bool sportPower; diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index 14ac57b23b7..b1a9df09c37 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -168,6 +168,14 @@ ui(new Ui::GeneralSetup) ui->usbModeCB->hide(); } + if (IS_FLYSKY_EL18(firmware->getBoard()) || IS_FLYSKY_NV14(firmware->getBoard())) { + ui->hatsModeCB->setCurrentIndex(generalSettings.hatsMode); + } + else { + ui->hatsModeLabel->hide(); + ui->hatsModeCB->hide(); + } + if (firmware->getCapability(HasSwitchableJack)) { ui->jackModeCB->setCurrentIndex(generalSettings.jackMode); } @@ -388,6 +396,14 @@ void GeneralSetupPanel::on_usbModeCB_currentIndexChanged(int index) } } +void GeneralSetupPanel::on_hatsModeCB_currentIndexChanged(int index) +{ + if (!lock) { + generalSettings.hatsMode = ui->hatsModeCB->currentIndex(); + emit modified(); + } +} + void GeneralSetupPanel::on_jackModeCB_currentIndexChanged(int index) { if (!lock) { diff --git a/companion/src/generaledit/generalsetup.h b/companion/src/generaledit/generalsetup.h index d3675a29538..3b66d26b3b4 100644 --- a/companion/src/generaledit/generalsetup.h +++ b/companion/src/generaledit/generalsetup.h @@ -60,6 +60,7 @@ class GeneralSetupPanel : public GeneralPanel void on_hapticLengthCB_currentIndexChanged(int index); void on_backlightswCB_currentIndexChanged(int index); void on_usbModeCB_currentIndexChanged(int index); + void on_hatsModeCB_currentIndexChanged(int index); void on_jackModeCB_currentIndexChanged(int index); void on_backlightColor_SL_valueChanged(); void on_mavbaud_CB_currentIndexChanged(int index); diff --git a/companion/src/translations/companion_cs.ts b/companion/src/translations/companion_cs.ts index 98ef6a8b1dc..244599552ec 100644 --- a/companion/src/translations/companion_cs.ts +++ b/companion/src/translations/companion_cs.ts @@ -5616,6 +5616,26 @@ Použitelné hodnoty jsou 5v..10v {3v?} {12v?} USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick Mode diff --git a/companion/src/translations/companion_da.ts b/companion/src/translations/companion_da.ts index 9d357050d84..4adc4dd3d94 100644 --- a/companion/src/translations/companion_da.ts +++ b/companion/src/translations/companion_da.ts @@ -6024,6 +6024,31 @@ Tilstand 4: USB Serial (CDC) Seriel USB (CDC) + + + Hats Mode + Joystik indstilling + + + + Trims only + Kun trim + + + + Keys only + Kun knap + + + + Switchable + Trim / Knap + + + + Global + Global + Owner Registration ID diff --git a/companion/src/translations/companion_de.ts b/companion/src/translations/companion_de.ts index 40dd05e003a..04b6cae1438 100644 --- a/companion/src/translations/companion_de.ts +++ b/companion/src/translations/companion_de.ts @@ -5591,6 +5591,26 @@ Werte liegen zwischen 5-10V {3v?} {12v?} USB Serial (CDC) USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick Mode diff --git a/companion/src/translations/companion_en.ts b/companion/src/translations/companion_en.ts index 97923578ee5..61ff6d4ee02 100644 --- a/companion/src/translations/companion_en.ts +++ b/companion/src/translations/companion_en.ts @@ -5346,6 +5346,26 @@ Mode 4: USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + <html><head/><body><p>Channel order</p><p><br/></p><p>Defines the order of the default mixes created on a new model.</p></body></html> diff --git a/companion/src/translations/companion_es.ts b/companion/src/translations/companion_es.ts index a7282c79e38..ec75c472bac 100644 --- a/companion/src/translations/companion_es.ts +++ b/companion/src/translations/companion_es.ts @@ -5665,6 +5665,26 @@ Los valores aceptables son 5v..10v {3v?} {12v?} USB Serial (CDC) USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick Mode diff --git a/companion/src/translations/companion_fi.ts b/companion/src/translations/companion_fi.ts index a7e9edf25f1..277d48b96f9 100644 --- a/companion/src/translations/companion_fi.ts +++ b/companion/src/translations/companion_fi.ts @@ -5644,6 +5644,26 @@ Hyväksytty arvo: 5v - 10v {3v?} {12v?} USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick Mode diff --git a/companion/src/translations/companion_fr.ts b/companion/src/translations/companion_fr.ts index 8c8b7bf01e8..734d37203bc 100644 --- a/companion/src/translations/companion_fr.ts +++ b/companion/src/translations/companion_fr.ts @@ -5643,6 +5643,26 @@ Plage de valeurs: 3v...12v USB Serial (CDC) Port série USB (Debug) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick Mode diff --git a/companion/src/translations/companion_he.ts b/companion/src/translations/companion_he.ts index 75e1f3346a5..a7867c987ae 100644 --- a/companion/src/translations/companion_he.ts +++ b/companion/src/translations/companion_he.ts @@ -5810,6 +5810,26 @@ p, li { white-space: pre-wrap; } USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Measurement Units diff --git a/companion/src/translations/companion_it.ts b/companion/src/translations/companion_it.ts index a86a155bdfd..8319b035c00 100644 --- a/companion/src/translations/companion_it.ts +++ b/companion/src/translations/companion_it.ts @@ -5609,6 +5609,26 @@ Mode 4: USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick Mode diff --git a/companion/src/translations/companion_ja.ts b/companion/src/translations/companion_ja.ts index 6f128f2bd35..2e0bfca3303 100644 --- a/companion/src/translations/companion_ja.ts +++ b/companion/src/translations/companion_ja.ts @@ -5972,6 +5972,26 @@ Mode 4: USB Serial (CDC) USBシリアル (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + GeneralSetupPanel diff --git a/companion/src/translations/companion_nl.ts b/companion/src/translations/companion_nl.ts index 43bcc05e72b..48b168a7c0f 100644 --- a/companion/src/translations/companion_nl.ts +++ b/companion/src/translations/companion_nl.ts @@ -5810,6 +5810,26 @@ p, li { white-space: pre-wrap; } USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Measurement Units diff --git a/companion/src/translations/companion_pl.ts b/companion/src/translations/companion_pl.ts index f0f2b9583ee..131b07a0f95 100644 --- a/companion/src/translations/companion_pl.ts +++ b/companion/src/translations/companion_pl.ts @@ -5944,6 +5944,26 @@ Dopuszczalne wartości 5v-10v {3v?} {12v?} USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick reverse diff --git a/companion/src/translations/companion_pt.ts b/companion/src/translations/companion_pt.ts index a32619941fe..c9829c1ce0c 100644 --- a/companion/src/translations/companion_pt.ts +++ b/companion/src/translations/companion_pt.ts @@ -5810,6 +5810,26 @@ p, li { white-space: pre-wrap; } USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Measurement Units diff --git a/companion/src/translations/companion_ru.ts b/companion/src/translations/companion_ru.ts index f1fdae5072d..b0a6dccd594 100644 --- a/companion/src/translations/companion_ru.ts +++ b/companion/src/translations/companion_ru.ts @@ -5868,6 +5868,26 @@ p, li { white-space: pre-wrap; } USB Serial (CDC) Последовательный порт + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Measurement Units diff --git a/companion/src/translations/companion_sv.ts b/companion/src/translations/companion_sv.ts index 8e8c9a620d6..a03999893b5 100644 --- a/companion/src/translations/companion_sv.ts +++ b/companion/src/translations/companion_sv.ts @@ -6021,7 +6021,26 @@ Mode 4: Seriell USB (CDC) - + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + + Owner Registration ID ID för ägarregistrering diff --git a/companion/src/translations/companion_zh_CN.ts b/companion/src/translations/companion_zh_CN.ts index f7ca8e5fa7a..2dadc596bb1 100644 --- a/companion/src/translations/companion_zh_CN.ts +++ b/companion/src/translations/companion_zh_CN.ts @@ -5677,6 +5677,7 @@ Acceptable values are 3v..12v Power Off Delay + @@ -5698,6 +5699,26 @@ Acceptable values are 3v..12v USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick Mode diff --git a/companion/src/translations/companion_zh_TW.ts b/companion/src/translations/companion_zh_TW.ts index e03316b5fd4..69470459b85 100644 --- a/companion/src/translations/companion_zh_TW.ts +++ b/companion/src/translations/companion_zh_TW.ts @@ -5698,6 +5698,26 @@ Acceptable values are 3v..12v USB Serial (CDC) + + + Hats Mode + + + + + Trims only + + + + + Keys only + + + + + Switchable + + Stick Mode diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index 6eb231b1fec..c57891368f4 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -18,12 +18,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ -#if !defined(BOOT) +#if !defined(BOOT) && defined(USE_TRIMS_AS_BUTTONS) #include "opentx.h" #endif -#include "debug.h" - #include "keys.h" #include "opentx_helpers.h" diff --git a/radio/src/targets/simu/opentxsimulator.cpp b/radio/src/targets/simu/opentxsimulator.cpp index d8e62917f53..bb8a29ce1f4 100644 --- a/radio/src/targets/simu/opentxsimulator.cpp +++ b/radio/src/targets/simu/opentxsimulator.cpp @@ -298,7 +298,7 @@ extern volatile uint32_t rotencDt; void OpenTxSimulator::rotaryEncoderEvent(int steps) { -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) static uint32_t last_tick = 0; if (steps != 0) { if (g_eeGeneral.rotEncMode >= ROTARY_ENCODER_MODE_INVERT_BOTH) steps *= -1; From 4f1f33d960904efc514a11758a67069e7402cd68 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sun, 30 Jul 2023 16:53:20 +0200 Subject: [PATCH 03/34] left hat left as spare key for future use --- radio/src/keys.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index c57891368f4..c7fe9a36781 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -384,7 +384,8 @@ static void transpose_trims(uint32_t *keys) if(getTrimsAsButtons()) { // map hats to keys in button mode auto trims = readTrims(); - if (trims & (1 << 0)) *keys |= 1 << KEY_EXIT; // left hat, left 0x01 + // spare key in buttons mode: left hat left + //if (trims & (1 << 0)) *keys |= 1 << tbd; // left hat, left 0x01 if (trims & (1 << 1)) *keys |= 1 << KEY_MODEL; // left hat, right 0x02 if (trims & (1 << 2)) *keys |= 1 << KEY_TELE; // left hat, down 0x04 if (trims & (1 << 3)) *keys |= 1 << KEY_SYS; // left hat, up 0x08 From ed503575939303b5e9a3db22ecec48db5b901060 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sun, 30 Jul 2023 21:23:23 +0200 Subject: [PATCH 04/34] code cleanup --- radio/src/keys.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index c7fe9a36781..bfe3c54e72c 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -294,6 +294,8 @@ uint8_t keysGetTrimState(uint8_t trim) } #if defined(USE_TRIMS_AS_BUTTONS) +#define ROTARY_EMU_KEY_REPEAT_RATE 12 // times 10 [ms] + static bool _trims_as_buttons = false; void setTrimsAsButtons(bool val) { _trims_as_buttons = val; } @@ -303,26 +305,25 @@ int16_t getEmuRotaryData() { static bool rotaryTrimPressed = false; static tmr10ms_t timePressed = 0; - if(!getTrimsAsButtons()) - return 0; + if(getTrimsAsButtons()) { + tmr10ms_t now = get_tmr10ms(); - tmr10ms_t now = get_tmr10ms(); + if(rotaryTrimPressed) { + if(now < (timePressed + ROTARY_EMU_KEY_REPEAT_RATE)) + return 0; - if(rotaryTrimPressed && (now > (timePressed + 10))) // 100ms repeat key update rate - rotaryTrimPressed = false; + rotaryTrimPressed = false; + } - auto trims = readTrims(); + auto trims = readTrims(); - if (trims & (1 << 4)) { - if(!rotaryTrimPressed) { + if(trims & (1 << 4)) { rotaryTrimPressed = true; timePressed = now; - return 1; + return 1; } - } - if (trims & (1 << 5)) { - if(!rotaryTrimPressed) { + if(trims & (1 << 5)) { rotaryTrimPressed = true; timePressed = now; return -1; From 0f3828ebd2745730056e8ea5fd2d59c74f94f303 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Mon, 31 Jul 2023 14:06:49 +0200 Subject: [PATCH 05/34] change direction for rotary events and trims used as keys --- radio/src/thirdparty/libopenui/src/numberedit.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/radio/src/thirdparty/libopenui/src/numberedit.cpp b/radio/src/thirdparty/libopenui/src/numberedit.cpp index d688625ecce..2ae88a460fb 100644 --- a/radio/src/thirdparty/libopenui/src/numberedit.cpp +++ b/radio/src/thirdparty/libopenui/src/numberedit.cpp @@ -66,7 +66,11 @@ void NumberEdit::onEvent(event_t event) auto step = getStep(); step += (rotaryEncoderGetAccel() * getAccelFactor()) / 8; do { +#if defined(USE_TRIMS_AS_BUTTONS) + value -= step; +#else value += step; +#endif } while (isValueAvailable && !isValueAvailable(value) && value <= vmax); if (value <= vmax) { setValue(value); @@ -83,7 +87,11 @@ void NumberEdit::onEvent(event_t event) auto step = getStep(); step += (rotaryEncoderGetAccel() * getAccelFactor()) / 8; do { +#if defined(USE_TRIMS_AS_BUTTONS) + value += step; +#else value -= step; +#endif } while (isValueAvailable && !isValueAvailable(value) && value >= vmin); if (value >= vmin) { setValue(value); From 897b4e766f0e37445d914e3a33bfb47756d71d59 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Mon, 31 Jul 2023 19:42:47 +0200 Subject: [PATCH 06/34] update key event definitions --- radio/src/lua/api_general.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index b2588c55395..a7d185b3155 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -3117,19 +3117,19 @@ LROT_BEGIN(etxcst, NULL, 0) KEY_EVENTS(MENU, KEY_MENU) #endif -#if defined(KEYS_GPIO_REG_RIGHT) && defined(COLORLCD) +#if defined(KEYS_GPIO_REG_RIGHT) && defined(COLORLCD) || defined(USE_TRIMS_AS_BUTTONS) KEY_EVENTS(TELEM, KEY_TELE) #elif defined(KEYS_GPIO_REG_RIGHT) KEY_EVENTS(RIGHT, KEY_RIGHT) #endif -#if defined(KEYS_GPIO_REG_UP) && defined(COLORLCD) +#if defined(KEYS_GPIO_REG_UP) && defined(COLORLCD) || defined(USE_TRIMS_AS_BUTTONS) KEY_EVENTS(MODEL, KEY_MODEL) #elif defined(KEYS_GPIO_REG_UP) KEY_EVENTS(UP, KEY_UP) #endif -#if defined(KEYS_GPIO_REG_LEFT) && defined(COLORLCD) +#if defined(KEYS_GPIO_REG_LEFT) && defined(COLORLCD) || defined(USE_TRIMS_AS_BUTTONS) KEY_EVENTS(SYS, KEY_SYS) #elif defined(KEYS_GPIO_REG_LEFT) KEY_EVENTS(LEFT, KEY_LEFT) @@ -3141,11 +3141,11 @@ LROT_BEGIN(etxcst, NULL, 0) KEY_EVENTS(DOWN, KEY_DOWN) #endif -#if defined(KEYS_GPIO_REG_PAGEUP) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) KEY_EVENTS(PAGEUP, KEY_PAGEUP) #endif -#if defined(KEYS_GPIO_REG_PAGEDN) +#if defined(KEYS_GPIO_REG_PAGEDN) || defined(USE_TRIMS_AS_BUTTONS) KEY_EVENTS(PAGEDN, KEY_PAGEDN) #endif From 8b8927d7955f2303a734974cfaee8871b21abb02 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Tue, 1 Aug 2023 11:35:41 +0200 Subject: [PATCH 07/34] enable forwarding trims as key events to LUA --- radio/src/keys.cpp | 13 +++++++++---- radio/src/keys.h | 2 ++ radio/src/lua/api_general.cpp | 16 ++++++++-------- radio/src/lua/interface.cpp | 6 +++--- radio/src/lua/lua_widget.cpp | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index bfe3c54e72c..2f4bd25f1d7 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -297,15 +297,19 @@ uint8_t keysGetTrimState(uint8_t trim) #define ROTARY_EMU_KEY_REPEAT_RATE 12 // times 10 [ms] static bool _trims_as_buttons = false; +static bool _trims_as_buttons_LUA = false; void setTrimsAsButtons(bool val) { _trims_as_buttons = val; } bool getTrimsAsButtons() { return _trims_as_buttons; } +void setTransposeTrimsForLUA(bool val) { _trims_as_buttons_LUA = val; } +bool getTransposeTrimsForLUA() { return _trims_as_buttons_LUA; } + int16_t getEmuRotaryData() { static bool rotaryTrimPressed = false; static tmr10ms_t timePressed = 0; - if(getTrimsAsButtons()) { + if(getTrimsAsButtons() || getTransposeTrimsForLUA()) { tmr10ms_t now = get_tmr10ms(); if(rotaryTrimPressed) { @@ -343,7 +347,7 @@ static void transpose_trims(uint32_t *keys) #else static uint8_t state = 0; - if(g_eeGeneral.hatsMode == HATS_MODE_BOTH) { + if(g_eeGeneral.hatsMode == HATS_MODE_BOTH && !getTransposeTrimsForLUA()) { static bool lastExitState = false; static bool lastEnterState = false; @@ -382,7 +386,8 @@ static void transpose_trims(uint32_t *keys) } else state = 0; // state machine in idle if not in mode "BOTH" - if(getTrimsAsButtons()) { // map hats to keys in button mode + if(getTrimsAsButtons() || // map hats to keys in button mode or LUA active + getTransposeTrimsForLUA()) { auto trims = readTrims(); // spare key in buttons mode: left hat left @@ -407,7 +412,7 @@ bool keysPollingCycle() #if defined(USE_TRIMS_AS_BUTTONS) transpose_trims(&keys_input); - if (getTrimsAsButtons()) { + if (getTrimsAsButtons() || getTransposeTrimsForLUA()) { trims_input = 0; } else { trims_input = readTrims(); diff --git a/radio/src/keys.h b/radio/src/keys.h index 406b442e730..1a50202a19d 100644 --- a/radio/src/keys.h +++ b/radio/src/keys.h @@ -183,6 +183,8 @@ bool rotaryEncoderPollingCycle(); #if defined(USE_TRIMS_AS_BUTTONS) void setTrimsAsButtons(bool val); bool getTrimsAsButtons(); +void setTransposeTrimsForLUA(bool val); +bool getTransposeTrimsForLUA(); #endif struct InactivityData diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index a7d185b3155..0fc232860e8 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -3030,7 +3030,7 @@ LROT_BEGIN(etxcst, NULL, 0) #endif // Virtual events -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) || defined(USE_TRIMS_AS_BUTTOS) LROT_NUMENTRY( EVT_VIRTUAL_PREV, EVT_ROTARY_LEFT ) LROT_NUMENTRY( EVT_VIRTUAL_NEXT, EVT_ROTARY_RIGHT ) LROT_NUMENTRY( EVT_VIRTUAL_DEC, EVT_ROTARY_LEFT ) @@ -3090,23 +3090,21 @@ LROT_BEGIN(etxcst, NULL, 0) LROT_NUMENTRY( EVT_VIRTUAL_ENTER_LONG, EVT_KEY_LONG(KEY_ENTER) ) LROT_NUMENTRY( EVT_VIRTUAL_EXIT, EVT_KEY_BREAK(KEY_EXIT) ) #elif defined(COLORLCD) -#if defined(KEYS_GPIO_REG_PAGEUP) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) LROT_NUMENTRY( EVT_VIRTUAL_PREV_PAGE, EVT_KEY_BREAK(KEY_PAGEUP) ) LROT_NUMENTRY( EVT_VIRTUAL_NEXT_PAGE, EVT_KEY_BREAK(KEY_PAGEDN) ) -#elif defined(PCBNV14) - LROT_NUMENTRY( EVT_VIRTUAL_PREV_PAGE, EVT_KEY_BREAK(KEY_LEFT) ) - LROT_NUMENTRY( EVT_VIRTUAL_NEXT_PAGE, EVT_KEY_BREAK(KEY_RIGHT) ) #else - LROT_NUMENTRY( EVT_VIRTUAL_PREV_PAGE, EVT_KEY_LONG(KEY_PAGEDN) ) + LROT_NUMENTRY( EVT_VIRTUAL_PREV_PAGE, EVT_KEY_LONG(KEY_PAGEDN) ) // do colorLCD radios with only PAGEDN HW key exist? LROT_NUMENTRY( EVT_VIRTUAL_NEXT_PAGE, EVT_KEY_BREAK(KEY_PAGEDN) ) #endif - LROT_NUMENTRY( EVT_VIRTUAL_MENU, EVT_KEY_BREAK(KEY_MODEL) ) + LROT_NUMENTRY( EVT_VIRTUAL_MENU, EVT_KEY_BREAK(KEY_MODEL) ) LROT_NUMENTRY( EVT_VIRTUAL_MENU_LONG, EVT_KEY_LONG(KEY_MODEL) ) LROT_NUMENTRY( EVT_VIRTUAL_ENTER, EVT_KEY_BREAK(KEY_ENTER) ) LROT_NUMENTRY( EVT_VIRTUAL_ENTER_LONG, EVT_KEY_LONG(KEY_ENTER) ) LROT_NUMENTRY( EVT_VIRTUAL_EXIT, EVT_KEY_BREAK(KEY_EXIT) ) #endif + // key events LROT_NUMENTRY( EVT_EXIT_BREAK, EVT_KEY_BREAK(KEY_EXIT) ) #if defined(KEYS_GPIO_REG_ENTER) @@ -3165,12 +3163,13 @@ LROT_BEGIN(etxcst, NULL, 0) KEY_EVENTS(MINUS, KEY_MINUS) #endif -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) || defined(USE_TRIMS_AS_BUTTONS) KEY_EVENTS(ROT, KEY_ENTER) LROT_NUMENTRY( EVT_ROT_LEFT, EVT_ROTARY_LEFT ) LROT_NUMENTRY( EVT_ROT_RIGHT, EVT_ROTARY_RIGHT ) #endif +// touch events #if defined(HARDWARE_TOUCH) LROT_NUMENTRY( EVT_TOUCH_FIRST, EVT_TOUCH_FIRST ) LROT_NUMENTRY( EVT_TOUCH_BREAK, EVT_TOUCH_BREAK ) @@ -3178,6 +3177,7 @@ LROT_BEGIN(etxcst, NULL, 0) LROT_NUMENTRY( EVT_TOUCH_TAP, EVT_TOUCH_TAP ) #endif +// misc definitions #if LCD_DEPTH > 1 && !defined(COLORLCD) LROT_NUMENTRY( FILL_WHITE, FILL_WHITE ) LROT_NUMENTRY( GREY_DEFAULT, GREY_DEFAULT ) diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index 91d846a5b0a..9c859e62e9b 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -253,7 +253,7 @@ void luaDisable() luaState = INTERPRETER_PANIC; #if defined(USE_TRIMS_AS_BUTTONS) - //if (_is_standalone_script()) setTrimsAsButtons(false); + if (_is_standalone_script()) setTransposeTrimsForLUA(false); #endif } @@ -1254,7 +1254,7 @@ bool luaTask(event_t evt, bool allowLcdUsage) luaState = INTERPRETER_LOADING; #if defined(USE_TRIMS_AS_BUTTONS) - //if (_is_standalone_script()) setTrimsAsButtons(false); + if (_is_standalone_script()) setTransposeTrimsForLUA(false); #endif case INTERPRETER_LOADING: @@ -1270,7 +1270,7 @@ bool luaTask(event_t evt, bool allowLcdUsage) luaState = INTERPRETER_RUNNING; #if defined(USE_TRIMS_AS_BUTTONS) - //if (_is_standalone_script()) setTrimsAsButtons(true); + if (_is_standalone_script()) setTransposeTrimsForLUA(true); #endif case INTERPRETER_RUNNING: diff --git a/radio/src/lua/lua_widget.cpp b/radio/src/lua/lua_widget.cpp index 4a7cc453047..306d2c32929 100644 --- a/radio/src/lua/lua_widget.cpp +++ b/radio/src/lua/lua_widget.cpp @@ -175,7 +175,7 @@ void LuaEventHandler::onEvent(event_t event) if (event == EVT_KEY_LONG(KEY_EXIT)) { killEvents(KEY_EXIT); } -#if !defined(KEYS_GPIO_REG_PAGEUP) +#if !defined(KEYS_GPIO_REG_PAGEUP) && !defined(USE_TRIMS_AS_BUTTONS) else if (event == EVT_KEY_LONG(KEY_PAGEDN)) { killEvents(KEY_PAGEDN); } From dbd480eca5f41b133ff240731b72ec34232d1117 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Tue, 1 Aug 2023 12:18:50 +0200 Subject: [PATCH 08/34] fix rebase --- companion/src/generaledit/generalsetup.ui | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index 68a514176b3..cce65dbf3cd 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -1682,6 +1682,32 @@ p, li { white-space: pre-wrap; } + + + + Hats Mode + + + + + + + + Trims only + + + + + Keys only + + + + + Switchable + + + + From ff209bde2d57ac881abb42bee20ed6166121d3e3 Mon Sep 17 00:00:00 2001 From: elecpower Date: Thu, 3 Aug 2023 21:14:18 +1000 Subject: [PATCH 09/34] add data funcs --- companion/src/firmwares/generalsettings.cpp | 34 +++++++++++++++++++++ companion/src/firmwares/generalsettings.h | 12 ++++++++ 2 files changed, 46 insertions(+) diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index 1e9b7958a10..0c9f804fb78 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -675,6 +675,40 @@ AbstractStaticItemModel * GeneralSettings::uartSampleModeItemModel() return mdl; } +QString GeneralSettings::hatsModeToString() const +{ + return hatsModeToString(hatsMode); +} + +// static +QString GeneralSettings::hatsModeToString(int value) +{ + switch(value) { + case HATS_MODE_TRIMS_ONLY: + return tr("Trims only"); + case HATS_MODE_BUTTONS_ONLY: + return tr("Keys only"); + case HATS_MODE_BOTH: + return tr("Switchable"); + default: + return CPN_STR_UNKNOWN_ITEM; + } +} + +// static +AbstractStaticItemModel * GeneralSettings::hatsModeItemModel() +{ + AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); + mdl->setName(AIM_GS_HATSMODE); + + for (int i = 0; i < HATS_MODE_COUNT; i++) { + mdl->appendToItemList(hatsModeToString(i), i); + } + + mdl->loadItemList(); + return mdl; +} + /* TrainerMix */ diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index 3f979bb0b37..a54b1c9cc87 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -42,6 +42,8 @@ constexpr char AIM_GS_SERIALMODE[] {"gs.serialmode"}; constexpr char AIM_GS_INTMODULEBAUDRATE[] {"gs.intmodulebaudrate"}; constexpr char AIM_GS_STICKDEADZONE[] {"gs.stickdeadzone"}; constexpr char AIM_GS_UARTSAMPLEMODE[] {"gs.uartsamplemode"}; +constexpr char AIM_GS_HATSMODE[] {"gs.hatsmode"}; + constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"}; constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"}; @@ -171,6 +173,13 @@ class GeneralSettings { UART_SAMPLE_MODE_COUNT }; + enum HatsMode { + HATS_MODE_TRIMS_ONLY, + HATS_MODE_BUTTONS_ONLY, + HATS_MODE_BOTH, + HATS_MODE_COUNT + }; + GeneralSettings() { clear(); } void clear(); void init(); @@ -314,6 +323,7 @@ class GeneralSettings { QString serialPortModeToString(int port_nr) const; QString internalModuleBaudrateToString() const; QString uartSampleModeToString() const; + QString hatsModeToString() const; static QString antennaModeToString(int value); static QString bluetoothModeToString(int value); @@ -322,6 +332,7 @@ class GeneralSettings { static FieldRange getPPM_MultiplierRange(); static FieldRange getTxCurrentCalibration(); static QString uartSampleModeToString(int value); + static QString hatsModeToString(int value); static AbstractStaticItemModel * antennaModeItemModel(bool model_setup = false); static AbstractStaticItemModel * bluetoothModeItemModel(); @@ -329,4 +340,5 @@ class GeneralSettings { static AbstractStaticItemModel * internalModuleBaudrateItemModel(); static AbstractStaticItemModel * stickDeadZoneItemModel(); static AbstractStaticItemModel * uartSampleModeItemModel(); + static AbstractStaticItemModel * hatsModeItemModel(); }; From 580bd6b8e324fba99d4ddd8449c692bb3454a15c Mon Sep 17 00:00:00 2001 From: elecpower Date: Thu, 3 Aug 2023 21:15:13 +1000 Subject: [PATCH 10/34] convert ui QComboBox to AutoComboBox --- companion/src/generaledit/generalsetup.cpp | 34 ++++++++++------------ companion/src/generaledit/generalsetup.h | 1 - companion/src/generaledit/generalsetup.ui | 23 ++++----------- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index b1a9df09c37..d6686564b68 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -20,6 +20,8 @@ #include "generalsetup.h" #include "ui_generalsetup.h" +#include "compounditemmodels.h" +#include "autocombobox.h" GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware): GeneralPanel(parent, generalSettings, firmware), @@ -27,10 +29,12 @@ ui(new Ui::GeneralSetup) { ui->setupUi(this); + Board::Type board = firmware->getBoard(); + QLabel *pmsl[] = {ui->ro_label, ui->ro1_label, ui->ro2_label, ui->ro3_label, ui->ro4_label, ui->ro5_label, ui->ro6_label, ui->ro7_label, ui->ro8_label, NULL}; QSlider *tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL}; - if (IS_TARANIS(firmware->getBoard())) { + if (IS_TARANIS(board)) { if (firmware->getId().contains("readonly")) { uint16_t switchstate = generalSettings.switchUnlockStates; ui->chkSA->setValue(switchstate & 0x3); @@ -153,14 +157,14 @@ ui(new Ui::GeneralSetup) ui->timezoneLE->setTime((generalSettings.timezone * 3600) + (generalSettings.timezoneMinutes/*quarter hours*/ * 15 * 60)); - if (IS_HORUS_OR_TARANIS(firmware->getBoard())) { + if (IS_HORUS_OR_TARANIS(board)) { ui->adjustRTC->setChecked(generalSettings.adjustRTC); } else { ui->adjustRTC->hide(); } - if (IS_STM32(firmware->getBoard())) { + if (IS_STM32(board)) { ui->usbModeCB->setCurrentIndex(generalSettings.usbMode); } else { @@ -168,8 +172,9 @@ ui(new Ui::GeneralSetup) ui->usbModeCB->hide(); } - if (IS_FLYSKY_EL18(firmware->getBoard()) || IS_FLYSKY_NV14(firmware->getBoard())) { - ui->hatsModeCB->setCurrentIndex(generalSettings.hatsMode); + if (IS_FLYSKY_EL18(board) || IS_FLYSKY_NV14(board)) { + ui->hatsModeCB->setModel(GeneralSettings::hatsModeItemModel()); + ui->hatsModeCB->setField(generalSettings.hatsMode, this); } else { ui->hatsModeLabel->hide(); @@ -208,13 +213,13 @@ ui(new Ui::GeneralSetup) ui->label_BLBright->hide(); } - if (!IS_FAMILY_HORUS_OR_T16(firmware->getBoard())) { + if (!IS_FAMILY_HORUS_OR_T16(board)) { ui->OFFBright_SB->hide(); ui->OFFBright_SB->setDisabled(true); ui->label_OFFBright->hide(); } - if (!IS_JUMPER_T18(firmware->getBoard())) { + if (!IS_JUMPER_T18(board)) { ui->keysBl_ChkB->hide(); ui->keysBl_ChkB->setDisabled(true); ui->label_KeysBl->hide(); @@ -270,7 +275,7 @@ ui(new Ui::GeneralSetup) ui->pwrOffDelayLabel->hide(); ui->pwrOffDelay->hide(); } - else if (!IS_TARANIS(firmware->getBoard())) { + else if (!IS_TARANIS(board)) { ui->pwrOnDelayLabel->hide(); ui->pwrOnDelay->hide(); } @@ -287,7 +292,7 @@ ui(new Ui::GeneralSetup) connect(tpmsld[i], SIGNAL(valueChanged(int)),this,SLOT(unlockSwitchEdited())); } - if (!IS_HORUS_OR_TARANIS(firmware->getBoard())) { + if (!IS_HORUS_OR_TARANIS(board)) { ui->stickReverse1->setChecked(generalSettings.stickReverse & (1 << 0)); ui->stickReverse2->setChecked(generalSettings.stickReverse & (1 << 1)); ui->stickReverse3->setChecked(generalSettings.stickReverse & (1 << 2)); @@ -305,7 +310,7 @@ ui(new Ui::GeneralSetup) ui->stickReverse4->hide(); } - if (IS_TARANIS_PLUS(firmware->getBoard())) { + if (IS_TARANIS_PLUS(board)) { ui->backlightColor_SL->setValue(generalSettings.backlightColor); } else { @@ -396,14 +401,6 @@ void GeneralSetupPanel::on_usbModeCB_currentIndexChanged(int index) } } -void GeneralSetupPanel::on_hatsModeCB_currentIndexChanged(int index) -{ - if (!lock) { - generalSettings.hatsMode = ui->hatsModeCB->currentIndex(); - emit modified(); - } -} - void GeneralSetupPanel::on_jackModeCB_currentIndexChanged(int index) { if (!lock) { @@ -412,7 +409,6 @@ void GeneralSetupPanel::on_jackModeCB_currentIndexChanged(int index) } } - void GeneralSetupPanel::on_backlightColor_SL_valueChanged() { if (!lock) { diff --git a/companion/src/generaledit/generalsetup.h b/companion/src/generaledit/generalsetup.h index 3b66d26b3b4..d3675a29538 100644 --- a/companion/src/generaledit/generalsetup.h +++ b/companion/src/generaledit/generalsetup.h @@ -60,7 +60,6 @@ class GeneralSetupPanel : public GeneralPanel void on_hapticLengthCB_currentIndexChanged(int index); void on_backlightswCB_currentIndexChanged(int index); void on_usbModeCB_currentIndexChanged(int index); - void on_hatsModeCB_currentIndexChanged(int index); void on_jackModeCB_currentIndexChanged(int index); void on_backlightColor_SL_valueChanged(); void on_mavbaud_CB_currentIndexChanged(int index); diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index cce65dbf3cd..50bd6d4cf70 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -1690,23 +1690,7 @@ p, li { white-space: pre-wrap; } - - - - Trims only - - - - - Keys only - - - - - Switchable - - - + @@ -2537,6 +2521,11 @@ p, li { white-space: pre-wrap; } QLineEdit
timezoneedit.h
+ + AutoComboBox + QComboBox +
autocombobox.h
+
From aeb2750b61c18f7829be3f369a807165a12d549e Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 3 Aug 2023 21:11:05 +0200 Subject: [PATCH 11/34] model level selection of hats mode in model settings / model setup / trims --- radio/src/dataconstants.h | 3 ++- radio/src/datastructs_private.h | 10 ++++------ radio/src/gui/colorlcd/trims_setup.cpp | 8 ++++++++ radio/src/main.cpp | 8 +++++--- radio/src/storage/yaml/yaml_datastructs_nv14.cpp | 8 ++++---- radio/src/translations/cn.h | 2 +- radio/src/translations/cz.h | 2 +- radio/src/translations/da.h | 2 +- radio/src/translations/de.h | 2 +- radio/src/translations/en.h | 2 +- radio/src/translations/es.h | 2 +- radio/src/translations/fi.h | 2 +- radio/src/translations/fr.h | 2 +- radio/src/translations/he.h | 2 +- radio/src/translations/it.h | 2 +- radio/src/translations/jp.h | 2 +- radio/src/translations/nl.h | 2 +- radio/src/translations/pl.h | 2 +- radio/src/translations/pt.h | 2 +- radio/src/translations/se.h | 2 +- radio/src/translations/tw.h | 2 +- 21 files changed, 39 insertions(+), 30 deletions(-) diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 1b6ab3c1c8b..129278c6a85 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -661,7 +661,8 @@ enum BluetoothModes { enum enumHatsMode { HATS_MODE_TRIMS_ONLY, HATS_MODE_BUTTONS_ONLY, - HATS_MODE_BOTH + HATS_MODE_BOTH, + HATS_MODE_GLOBAL }; #endif diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index f5621566bfe..1a13e9e6f1a 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -679,7 +679,8 @@ PACK(struct ModelData { uint8_t disableTelemetryWarning:1; uint8_t showInstanceIds:1; uint8_t checklistInteractive:1; - uint8_t spare3:4 SKIP; // padding to 8-bit aligment + uint8_t hatsMode:2; + uint8_t spare3:2 SKIP; // padding to 8-bit aligment int8_t customThrottleWarningPosition; BeepANACenter beepANACenter; MixData mixData[MAX_MIXERS] NO_IDX; @@ -851,7 +852,8 @@ PACK(struct RadioData { // Real attributes NOBACKUP(uint8_t manuallyEdited:1); int8_t timezoneMinutes:3; // -3 to +3 ==> (-45 to 45 minutes in 15 minute increments) - NOBACKUP(int8_t spare0:4 SKIP); + uint8_t hatsMode:2; + NOBACKUP(int8_t spare0:2 SKIP); CUST_ATTR(semver,nullptr,w_semver); CUST_ATTR(board,nullptr,w_board); CalibData calib[MAX_CALIB_ANALOG_INPUTS] NO_IDX; @@ -940,11 +942,7 @@ PACK(struct RadioData { CUST_ATTR(rotEncDirection, r_rotEncDirection, nullptr); -#if defined(USE_TRIMS_AS_BUTTONS) - NOBACKUP(uint8_t hatsMode:2); -#else NOBACKUP(uint8_t rotEncMode:2); -#endif NOBACKUP(int8_t uartSampleMode:2); // See UartSampleModes diff --git a/radio/src/gui/colorlcd/trims_setup.cpp b/radio/src/gui/colorlcd/trims_setup.cpp index 25df41ef811..ef956ff3b23 100644 --- a/radio/src/gui/colorlcd/trims_setup.cpp +++ b/radio/src/gui/colorlcd/trims_setup.cpp @@ -55,6 +55,14 @@ TrimsSetup::TrimsSetup() : Page(ICON_MODEL_SETUP) auto btn_obj = btn->getLvObj(); lv_obj_set_width(btn_obj, lv_pct(100)); +#if defined(USE_TRIMS_AS_BUTTONS) + // Hats mode for NV14/EL18 + line = body.newLine(&grid); + new StaticText(line, rect_t{}, STR_HATS_MODE, 0, COLOR_THEME_PRIMARY1); + new Choice(line, rect_t{}, STR_HATS_OPT, HATS_MODE_TRIMS_ONLY, HATS_MODE_GLOBAL, + GET_SET_DEFAULT(g_model.hatsMode)); +#endif + // Trim step line = body.newLine(&grid); new StaticText(line, rect_t{}, STR_TRIMINC, 0, diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 65203052d31..af3be04486f 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -268,13 +268,15 @@ void checkSpeakerVolume() #if defined(USE_TRIMS_AS_BUTTONS) void checkTrimsAsButtons() { - static bool oldHatsModeButtons = g_eeGeneral.hatsMode == HATS_MODE_BUTTONS_ONLY; + uint8_t hatsMode = g_model.hatsMode == HATS_MODE_GLOBAL ? g_eeGeneral.hatsMode : g_model.hatsMode; - if(g_eeGeneral.hatsMode == HATS_MODE_TRIMS_ONLY) { + static bool oldHatsModeButtons = hatsMode == HATS_MODE_BUTTONS_ONLY; + + if(hatsMode == HATS_MODE_TRIMS_ONLY) { setTrimsAsButtons(false); } - if(g_eeGeneral.hatsMode == HATS_MODE_BUTTONS_ONLY) { + if(hatsMode == HATS_MODE_BUTTONS_ONLY) { setTrimsAsButtons(true); } diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index c21c55c8134..9af10d99b0f 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -297,7 +297,8 @@ static const struct YamlNode struct_EdgeTxTheme__PersistentData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_UNSIGNED( "hatsMode", 2 ), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 22, struct_CalibData, NULL), @@ -379,7 +380,6 @@ static const struct YamlNode struct_RadioData[] = { YAML_STRUCT("themeData", 480, struct_EdgeTxTheme__PersistentData, NULL), YAML_STRING("ownerRegistrationID", 8), YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr), - YAML_UNSIGNED( "hatsMode", 2 ), YAML_SIGNED( "uartSampleMode", 2 ), YAML_UNSIGNED( "stickDeadZone", 3 ), YAML_UNSIGNED( "audioMuteEnable", 1 ), @@ -820,7 +820,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_UNSIGNED( "hatsMode", 2 ), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), @@ -899,4 +900,3 @@ const YamlNode* get_partialmodel_nodes() { return &__PartialModel_root_node; } - diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index 69bb89dd891..5157744d200 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -154,7 +154,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index dc1d9a201f2..dab6a21e81b 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -166,7 +166,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 1b33f61735b..104e4121200 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -162,7 +162,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index 34d733d0821..8b3eba4a5a7 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -156,7 +156,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index cc5393b137c..d599628319f 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -159,7 +159,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/es.h b/radio/src/translations/es.h index 0a67a7dfe88..ef22cd7a00d 100644 --- a/radio/src/translations/es.h +++ b/radio/src/translations/es.h @@ -154,7 +154,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/fi.h b/radio/src/translations/fi.h index a29d2d144ea..6c9ccedcccc 100644 --- a/radio/src/translations/fi.h +++ b/radio/src/translations/fi.h @@ -165,7 +165,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 8c2a5a72797..85c74aa0f68 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -166,7 +166,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/he.h b/radio/src/translations/he.h index 8784f808c51..994f9d109f4 100644 --- a/radio/src/translations/he.h +++ b/radio/src/translations/he.h @@ -243,7 +243,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index e707df1495e..6fee55353f2 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -159,7 +159,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index aef8aea0698..50414737428 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -159,7 +159,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/nl.h b/radio/src/translations/nl.h index 7c791fddfb9..3d826e98ae7 100644 --- a/radio/src/translations/nl.h +++ b/radio/src/translations/nl.h @@ -156,7 +156,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index a5f4c9ebb35..b821ca5c328 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -154,7 +154,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/pt.h b/radio/src/translations/pt.h index 38a74db9f56..abd0f984988 100644 --- a/radio/src/translations/pt.h +++ b/radio/src/translations/pt.h @@ -162,7 +162,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index 5d0fe7cd63d..6eccbdcc8eb 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -177,7 +177,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index e7a0dfe51ca..f65020482ab 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -159,7 +159,7 @@ #if defined(USE_TRIMS_AS_BUTTONS) #define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable" +#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" #define TR_HATS_MODE_TRIMS "Hats mode: Trims" #define TR_HATS_MODE_BUTTONS "Hats mode: Keys" #endif From c5c1fbc69bd10dab71ac8af511f091ece7174a38 Mon Sep 17 00:00:00 2001 From: elecpower Date: Fri, 4 Aug 2023 07:42:55 +1000 Subject: [PATCH 12/34] add global to hats mode and hide from list of available modes if radio setup --- companion/src/firmwares/generalsettings.cpp | 6 ++++-- companion/src/firmwares/generalsettings.h | 3 ++- companion/src/generaledit/generalsetup.cpp | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index 0c9f804fb78..ed576ef25b6 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -690,19 +690,21 @@ QString GeneralSettings::hatsModeToString(int value) return tr("Keys only"); case HATS_MODE_BOTH: return tr("Switchable"); + case HATS_MODE_GLOBAL: + return tr("Global"); default: return CPN_STR_UNKNOWN_ITEM; } } // static -AbstractStaticItemModel * GeneralSettings::hatsModeItemModel() +AbstractStaticItemModel * GeneralSettings::hatsModeItemModel(bool radio_setup) { AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); mdl->setName(AIM_GS_HATSMODE); for (int i = 0; i < HATS_MODE_COUNT; i++) { - mdl->appendToItemList(hatsModeToString(i), i); + mdl->appendToItemList(hatsModeToString(i), i, i == HATS_MODE_GLOBAL && radio_setup ? false : true); } mdl->loadItemList(); diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index a54b1c9cc87..e673954fb84 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -177,6 +177,7 @@ class GeneralSettings { HATS_MODE_TRIMS_ONLY, HATS_MODE_BUTTONS_ONLY, HATS_MODE_BOTH, + HATS_MODE_GLOBAL, HATS_MODE_COUNT }; @@ -340,5 +341,5 @@ class GeneralSettings { static AbstractStaticItemModel * internalModuleBaudrateItemModel(); static AbstractStaticItemModel * stickDeadZoneItemModel(); static AbstractStaticItemModel * uartSampleModeItemModel(); - static AbstractStaticItemModel * hatsModeItemModel(); + static AbstractStaticItemModel * hatsModeItemModel(bool radio_setup = true); }; diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index d6686564b68..f58c932d1c9 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -21,6 +21,7 @@ #include "generalsetup.h" #include "ui_generalsetup.h" #include "compounditemmodels.h" +#include "filtereditemmodels.h" #include "autocombobox.h" GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware): @@ -173,7 +174,7 @@ ui(new Ui::GeneralSetup) } if (IS_FLYSKY_EL18(board) || IS_FLYSKY_NV14(board)) { - ui->hatsModeCB->setModel(GeneralSettings::hatsModeItemModel()); + ui->hatsModeCB->setModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel())); ui->hatsModeCB->setField(generalSettings.hatsMode, this); } else { From fa28daaa4b25b8ef83456e725da5c7d958680a30 Mon Sep 17 00:00:00 2001 From: elecpower Date: Fri, 4 Aug 2023 07:56:44 +1000 Subject: [PATCH 13/34] add hats mode to model setup --- companion/src/modeledit/setup.cpp | 11 ++ companion/src/modeledit/setup.ui | 262 ++++++++++++++++-------------- 2 files changed, 147 insertions(+), 126 deletions(-) diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index cf5aaa0d42a..3efcb9eb663 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -1474,6 +1474,8 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge panelItemModels->registerItemModel(TimerData::persistentItemModel()); panelItemModels->registerItemModel(TimerData::modeItemModel()); panelItemModels->registerItemModel(TimerData::showElapsedItemModel()); + panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel(false))); + Board::Type board = firmware->getBoard(); memset(modules, 0, sizeof(modules)); @@ -1693,6 +1695,15 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge ui->trimsDisplay->setField(model.trimsDisplay, this); + if (IS_FLYSKY_EL18(board) || IS_FLYSKY_NV14(board)) { + ui->cboHatsMode->setModel(panelFilteredModels->getItemModel(AIM_GS_HATSMODE)); + ui->cboHatsMode->setField(model.hatsMode, this); + } + else { + ui->lblHatsMode->hide(); + ui->cboHatsMode->hide(); + } + if (Boards::getCapability(firmware->getBoard(), Board::FunctionSwitches) > 0) { funcswitches = new FunctionSwitchesPanel(this, model, generalSettings, firmware); ui->functionSwitchesLayout->addWidget(funcswitches); diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui index 9ff59393630..35aefb2d237 100644 --- a/companion/src/modeledit/setup.ui +++ b/companion/src/modeledit/setup.ui @@ -7,7 +7,7 @@ 0 0 1024 - 435 + 466 @@ -199,6 +199,13 @@
+ + + + Hats Mode + + + @@ -463,10 +470,83 @@ 6 - - + + + + Qt::LeftToRight + + + Throttle Trim Idle Only + + - + + + + + 0 + 0 + + + + Edit Checklist... + + + + + + + Qt::LeftToRight + + + Custom Throttle Warning + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::LeftToRight + + + Extended Trims + + + + + + + Qt::LeftToRight + + + Throttle Warning + + + + + + + + 0 + 0 + + + + + @@ -501,48 +581,33 @@ - - - - - 0 - 0 - + + + + Throttle trim switch - - - Never - - - - - On change - - - - - Always - - - - + + + + + Qt::LeftToRight - Throttle Warning + Extended Limits - - + + Qt::LeftToRight - Custom Throttle Warning + Display Checklist @@ -562,17 +627,48 @@ - - + + + + Reverse throttle operation. +If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well. + + + Qt::LeftToRight - Display Checklist + Reverse Throttle - + + + + + 0 + 0 + + + + + Never + + + + + On change + + + + + Always + + + + + Global Functions @@ -589,7 +685,7 @@ - + @@ -602,7 +698,7 @@ - + @@ -627,94 +723,8 @@ - - - - - 0 - 0 - - - - Edit Checklist... - - - - - - - Qt::LeftToRight - - - Throttle Trim Idle Only - - - - - - - Reverse throttle operation. -If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well. - - - - - Qt::LeftToRight - - - Reverse Throttle - - - - - - - Throttle trim switch - - - - - - - Qt::LeftToRight - - - Extended Trims - - - - - - - Qt::LeftToRight - - - Extended Limits - - - - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - + + From a5dbe764cc33fcf0fb347d5f92348cfef8b407bc Mon Sep 17 00:00:00 2001 From: elecpower Date: Fri, 4 Aug 2023 14:40:06 +1000 Subject: [PATCH 14/34] add hats mode to models --- companion/src/firmwares/modeldata.h | 1 + companion/src/modeledit/setup.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index 8df7a30f7c1..632fd4660ed 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -192,6 +192,7 @@ class ModelData { unsigned int view; char registrationId[8+1]; + unsigned int hatsMode; // Radio level tabs control (global settings) unsigned int radioThemesDisabled; diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 3efcb9eb663..4d9d144f790 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -36,6 +36,7 @@ constexpr char FIM_TIMERSWITCH[] {"Timer Switch"}; constexpr char FIM_THRSOURCE[] {"Throttle Source"}; constexpr char FIM_TRAINERMODE[] {"Trainer Mode"}; constexpr char FIM_ANTENNAMODE[] {"Antenna Mode"}; +constexpr char FIM_HATSMODE[] {"Hats Mode"}; TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus, FilteredItemModelFactory * panelFilteredModels, CompoundItemModelFactory * panelItemModels): @@ -1474,7 +1475,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge panelItemModels->registerItemModel(TimerData::persistentItemModel()); panelItemModels->registerItemModel(TimerData::modeItemModel()); panelItemModels->registerItemModel(TimerData::showElapsedItemModel()); - panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel(false))); + panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel(false)), FIM_HATSMODE); Board::Type board = firmware->getBoard(); @@ -1696,7 +1697,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge ui->trimsDisplay->setField(model.trimsDisplay, this); if (IS_FLYSKY_EL18(board) || IS_FLYSKY_NV14(board)) { - ui->cboHatsMode->setModel(panelFilteredModels->getItemModel(AIM_GS_HATSMODE)); + ui->cboHatsMode->setModel(panelFilteredModels->getItemModel(FIM_HATSMODE)); ui->cboHatsMode->setField(model.hatsMode, this); } else { From f341a758e4a7307191e3d1b486410c27446eccd9 Mon Sep 17 00:00:00 2001 From: elecpower Date: Fri, 4 Aug 2023 14:41:15 +1000 Subject: [PATCH 15/34] hats mode value as text in yaml files --- .../src/firmwares/edgetx/yaml_generalsettings.cpp | 10 ++++++++-- companion/src/firmwares/edgetx/yaml_modeldata.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index 81e727c2eeb..ef84b2499a4 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -117,6 +117,12 @@ const YamlLookupTable internalModuleLut = { { MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" }, }; +static const YamlLookupTable hatsModeLut = { + { GeneralSettings::HATS_MODE_TRIMS_ONLY, "TRIMS" }, + { GeneralSettings::HATS_MODE_BUTTONS_ONLY, "BUTTONS" }, + { GeneralSettings::HATS_MODE_BOTH, "BOTH" }, +}; + YamlTelemetryBaudrate::YamlTelemetryBaudrate( const unsigned int* moduleBaudrate) { @@ -181,7 +187,7 @@ Node convert::encode(const GeneralSettings& rhs) node["disableAlarmWarning"] = (int)rhs.disableAlarmWarning; node["disableRssiPoweroffAlarm"] = (int)rhs.disableRssiPoweroffAlarm; node["USBMode"] = rhs.usbMode; - node["hatsMode"] = rhs.hatsMode; + node["hatsMode"] = hatsModeLut << rhs.hatsMode; node["stickDeadZone"] = rhs.stickDeadZone; node["jackMode"] = rhs.jackMode; node["hapticMode"] = rhs.hapticMode; @@ -435,7 +441,7 @@ bool convert::decode(const Node& node, GeneralSettings& rhs) node["disableAlarmWarning"] >> rhs.disableAlarmWarning; node["disableRssiPoweroffAlarm"] >> rhs.disableRssiPoweroffAlarm; node["USBMode"] >> rhs.usbMode; - node["hatsMode"] >> rhs.hatsMode; + node["hatsMode"] >> hatsModeLut >> rhs.hatsMode; node["stickDeadZone"] >> rhs.stickDeadZone; node["jackMode"] >> rhs.jackMode; node["hapticMode"] >> rhs.hapticMode; diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 0059bc92141..c7e69f7566b 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -88,6 +88,13 @@ static const YamlLookupTable usbJoystickIfModeLut = { { 2, "MULTIAXIS" }, }; +static const YamlLookupTable hatsModeLut = { + { GeneralSettings::HATS_MODE_TRIMS_ONLY, "TRIMS" }, + { GeneralSettings::HATS_MODE_BUTTONS_ONLY, "BUTTONS" }, + { GeneralSettings::HATS_MODE_BOTH, "BOTH" }, + { GeneralSettings::HATS_MODE_GLOBAL, "GLOBAL" }, +}; + struct YamlTrim { int mode = 0; int ref = 0; @@ -1104,6 +1111,7 @@ Node convert::encode(const ModelData& rhs) } node["modelRegistrationID"] = rhs.registrationId; + node["hatsMode"] = hatsModeLut << rhs.hatsMode; if (Boards::getCapability(board, Board::FunctionSwitches)) { node["functionSwitchConfig"] = rhs.functionSwitchConfig; @@ -1342,6 +1350,7 @@ bool convert::decode(const Node& node, ModelData& rhs) node["view"] >> rhs.view; node["modelRegistrationID"] >> rhs.registrationId; + node["hatsMode"] >> hatsModeLut >> rhs.hatsMode; node["functionSwitchConfig"] >> rhs.functionSwitchConfig; node["functionSwitchGroup"] >> rhs.functionSwitchGroup; From 013818bfb2942d828c3e53d1c28f29f647c23929 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Fri, 4 Aug 2023 17:59:03 +0200 Subject: [PATCH 16/34] harmonized radio and companion yaml tags and id's code cleanup and some renaming --- .../src/firmwares/edgetx/yaml_generalsettings.cpp | 6 +++--- companion/src/firmwares/edgetx/yaml_modeldata.cpp | 8 ++++---- companion/src/firmwares/generalsettings.cpp | 10 +++++----- companion/src/firmwares/generalsettings.h | 8 ++++---- radio/src/dataconstants.h | 10 +++++----- radio/src/datastructs_private.h | 4 ++-- radio/src/gui/colorlcd/radio_setup.cpp | 2 +- radio/src/gui/colorlcd/trims_setup.cpp | 2 +- radio/src/keys.cpp | 2 +- radio/src/main.cpp | 8 ++++---- radio/src/storage/yaml/yaml_datastructs_nv14.cpp | 12 ++++++++++-- 11 files changed, 40 insertions(+), 32 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index ef84b2499a4..14502b5939c 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -118,9 +118,9 @@ const YamlLookupTable internalModuleLut = { }; static const YamlLookupTable hatsModeLut = { - { GeneralSettings::HATS_MODE_TRIMS_ONLY, "TRIMS" }, - { GeneralSettings::HATS_MODE_BUTTONS_ONLY, "BUTTONS" }, - { GeneralSettings::HATS_MODE_BOTH, "BOTH" }, + { GeneralSettings::MODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { GeneralSettings::MODE_KEYS_ONLY, "KEYS_ONLY" }, + { GeneralSettings::MODE_SWITCHABLE, "SWITCHABLE" }, }; YamlTelemetryBaudrate::YamlTelemetryBaudrate( diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index c7e69f7566b..1fb3fb1bc73 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -89,10 +89,10 @@ static const YamlLookupTable usbJoystickIfModeLut = { }; static const YamlLookupTable hatsModeLut = { - { GeneralSettings::HATS_MODE_TRIMS_ONLY, "TRIMS" }, - { GeneralSettings::HATS_MODE_BUTTONS_ONLY, "BUTTONS" }, - { GeneralSettings::HATS_MODE_BOTH, "BOTH" }, - { GeneralSettings::HATS_MODE_GLOBAL, "GLOBAL" }, + { GeneralSettings::MODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { GeneralSettings::MODE_KEYS_ONLY, "KEYS_ONLY" }, + { GeneralSettings::MODE_SWITCHABLE, "SWITCHABLE" }, + { GeneralSettings::MODE_GLOBAL, "GLOBAL" }, }; struct YamlTrim { diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index ed576ef25b6..fa258c614de 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -684,13 +684,13 @@ QString GeneralSettings::hatsModeToString() const QString GeneralSettings::hatsModeToString(int value) { switch(value) { - case HATS_MODE_TRIMS_ONLY: + case MODE_TRIMS_ONLY: return tr("Trims only"); - case HATS_MODE_BUTTONS_ONLY: + case MODE_KEYS_ONLY: return tr("Keys only"); - case HATS_MODE_BOTH: + case MODE_SWITCHABLE: return tr("Switchable"); - case HATS_MODE_GLOBAL: + case MODE_GLOBAL: return tr("Global"); default: return CPN_STR_UNKNOWN_ITEM; @@ -704,7 +704,7 @@ AbstractStaticItemModel * GeneralSettings::hatsModeItemModel(bool radio_setup) mdl->setName(AIM_GS_HATSMODE); for (int i = 0; i < HATS_MODE_COUNT; i++) { - mdl->appendToItemList(hatsModeToString(i), i, i == HATS_MODE_GLOBAL && radio_setup ? false : true); + mdl->appendToItemList(hatsModeToString(i), i, i == MODE_GLOBAL && radio_setup ? false : true); } mdl->loadItemList(); diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index e673954fb84..6bfd481d75a 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -174,10 +174,10 @@ class GeneralSettings { }; enum HatsMode { - HATS_MODE_TRIMS_ONLY, - HATS_MODE_BUTTONS_ONLY, - HATS_MODE_BOTH, - HATS_MODE_GLOBAL, + MODE_TRIMS_ONLY, + MODE_KEYS_ONLY, + MODE_SWITCHABLE, + MODE_GLOBAL, HATS_MODE_COUNT }; diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 129278c6a85..9789a8269e4 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -658,11 +658,11 @@ enum BluetoothModes { }; #if defined(USE_TRIMS_AS_BUTTONS) -enum enumHatsMode { - HATS_MODE_TRIMS_ONLY, - HATS_MODE_BUTTONS_ONLY, - HATS_MODE_BOTH, - HATS_MODE_GLOBAL +enum HatsMode { + MODE_TRIMS_ONLY, + MODE_KEYS_ONLY, + MODE_SWITCHABLE, + MODE_GLOBAL }; #endif diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index 1a13e9e6f1a..1f328db1cbf 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -679,7 +679,7 @@ PACK(struct ModelData { uint8_t disableTelemetryWarning:1; uint8_t showInstanceIds:1; uint8_t checklistInteractive:1; - uint8_t hatsMode:2; + NOBACKUP(uint8_t hatsMode:2 ENUM(HatsMode)); uint8_t spare3:2 SKIP; // padding to 8-bit aligment int8_t customThrottleWarningPosition; BeepANACenter beepANACenter; @@ -852,7 +852,7 @@ PACK(struct RadioData { // Real attributes NOBACKUP(uint8_t manuallyEdited:1); int8_t timezoneMinutes:3; // -3 to +3 ==> (-45 to 45 minutes in 15 minute increments) - uint8_t hatsMode:2; + NOBACKUP(uint8_t hatsMode:2 ENUM(HatsMode)); NOBACKUP(int8_t spare0:2 SKIP); CUST_ATTR(semver,nullptr,w_semver); CUST_ATTR(board,nullptr,w_board); diff --git a/radio/src/gui/colorlcd/radio_setup.cpp b/radio/src/gui/colorlcd/radio_setup.cpp index 6a6ce0abc6d..282d9a8c533 100644 --- a/radio/src/gui/colorlcd/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio_setup.cpp @@ -814,7 +814,7 @@ void RadioSetupPage::build(FormWindow * window) #if defined(USE_TRIMS_AS_BUTTONS) line = window->newLine(&grid); new StaticText(line, rect_t{}, STR_HATS_MODE, 0, COLOR_THEME_PRIMARY1); - new Choice(line, rect_t{}, STR_HATS_OPT, HATS_MODE_TRIMS_ONLY, HATS_MODE_BOTH, + new Choice(line, rect_t{}, STR_HATS_OPT, MODE_TRIMS_ONLY, MODE_SWITCHABLE, GET_SET_DEFAULT(g_eeGeneral.hatsMode)); #endif diff --git a/radio/src/gui/colorlcd/trims_setup.cpp b/radio/src/gui/colorlcd/trims_setup.cpp index ef956ff3b23..3e5d25879d2 100644 --- a/radio/src/gui/colorlcd/trims_setup.cpp +++ b/radio/src/gui/colorlcd/trims_setup.cpp @@ -59,7 +59,7 @@ TrimsSetup::TrimsSetup() : Page(ICON_MODEL_SETUP) // Hats mode for NV14/EL18 line = body.newLine(&grid); new StaticText(line, rect_t{}, STR_HATS_MODE, 0, COLOR_THEME_PRIMARY1); - new Choice(line, rect_t{}, STR_HATS_OPT, HATS_MODE_TRIMS_ONLY, HATS_MODE_GLOBAL, + new Choice(line, rect_t{}, STR_HATS_OPT, MODE_TRIMS_ONLY, MODE_GLOBAL, GET_SET_DEFAULT(g_model.hatsMode)); #endif diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index 2f4bd25f1d7..dbb5a5fd658 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -347,7 +347,7 @@ static void transpose_trims(uint32_t *keys) #else static uint8_t state = 0; - if(g_eeGeneral.hatsMode == HATS_MODE_BOTH && !getTransposeTrimsForLUA()) { + if(g_eeGeneral.hatsMode == MODE_SWITCHABLE && !getTransposeTrimsForLUA()) { static bool lastExitState = false; static bool lastEnterState = false; diff --git a/radio/src/main.cpp b/radio/src/main.cpp index af3be04486f..8cf56709cc1 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -268,15 +268,15 @@ void checkSpeakerVolume() #if defined(USE_TRIMS_AS_BUTTONS) void checkTrimsAsButtons() { - uint8_t hatsMode = g_model.hatsMode == HATS_MODE_GLOBAL ? g_eeGeneral.hatsMode : g_model.hatsMode; + uint8_t hatsMode = g_model.hatsMode == MODE_GLOBAL ? g_eeGeneral.hatsMode : g_model.hatsMode; - static bool oldHatsModeButtons = hatsMode == HATS_MODE_BUTTONS_ONLY; + static bool oldHatsModeButtons = hatsMode == MODE_KEYS_ONLY; - if(hatsMode == HATS_MODE_TRIMS_ONLY) { + if(hatsMode == MODE_TRIMS_ONLY) { setTrimsAsButtons(false); } - if(hatsMode == HATS_MODE_BUTTONS_ONLY) { + if(hatsMode == MODE_KEYS_ONLY) { setTrimsAsButtons(true); } diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 9af10d99b0f..0adfd28850a 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -4,6 +4,14 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { MODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { MODE_KEYS_ONLY, "KEYS_ONLY" }, + { MODE_SWITCHABLE, "SWITCHABLE " }, + { MODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; + const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -297,7 +305,7 @@ static const struct YamlNode struct_EdgeTxTheme__PersistentData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_UNSIGNED( "hatsMode", 2 ), + YAML_ENUM( "hatsMode", 2, enum_HatsMode ), YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), @@ -820,7 +828,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "hatsMode", 2 ), + YAML_ENUM( "hatsMode", 2, enum_HatsMode ), YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), From 6b57eba8ad7ce05582d1ffddb370c1d048788ccc Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Fri, 4 Aug 2023 20:24:07 +0200 Subject: [PATCH 17/34] updated logic for allowing hats mode switching --- radio/src/keys.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index dbb5a5fd658..7e9da666d13 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -347,7 +347,12 @@ static void transpose_trims(uint32_t *keys) #else static uint8_t state = 0; - if(g_eeGeneral.hatsMode == MODE_SWITCHABLE && !getTransposeTrimsForLUA()) { + bool allowModeSwitch = + ((g_model.hatsMode == MODE_GLOBAL && g_eeGeneral.hatsMode == MODE_SWITCHABLE) || + (g_model.hatsMode == MODE_SWITCHABLE)) && + !getTransposeTrimsForLUA(); + + if(allowModeSwitch) { static bool lastExitState = false; static bool lastEnterState = false; From c89beaac158c6e5ddcf8dcfe2e53900585c0cf71 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sat, 5 Aug 2023 14:03:56 +0200 Subject: [PATCH 18/34] changed hats mode enum names to have prefix HATS_ --- .../src/firmwares/edgetx/yaml_generalsettings.cpp | 6 +++--- companion/src/firmwares/edgetx/yaml_modeldata.cpp | 8 ++++---- companion/src/firmwares/generalsettings.cpp | 10 +++++----- companion/src/firmwares/generalsettings.h | 8 ++++---- radio/src/dataconstants.h | 8 ++++---- radio/src/gui/colorlcd/radio_setup.cpp | 2 +- radio/src/gui/colorlcd/trims_setup.cpp | 2 +- radio/src/keys.cpp | 4 ++-- radio/src/main.cpp | 8 ++++---- radio/src/storage/yaml/yaml_datastructs_nv14.cpp | 8 ++++---- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index 14502b5939c..a3448e65c6a 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -118,9 +118,9 @@ const YamlLookupTable internalModuleLut = { }; static const YamlLookupTable hatsModeLut = { - { GeneralSettings::MODE_TRIMS_ONLY, "TRIMS_ONLY" }, - { GeneralSettings::MODE_KEYS_ONLY, "KEYS_ONLY" }, - { GeneralSettings::MODE_SWITCHABLE, "SWITCHABLE" }, + { GeneralSettings::HATS_MODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { GeneralSettings::HATS_MODE_KEYS_ONLY, "KEYS_ONLY" }, + { GeneralSettings::HATS_MODE_SWITCHABLE, "SWITCHABLE" }, }; YamlTelemetryBaudrate::YamlTelemetryBaudrate( diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 1fb3fb1bc73..f07044dd6e6 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -89,10 +89,10 @@ static const YamlLookupTable usbJoystickIfModeLut = { }; static const YamlLookupTable hatsModeLut = { - { GeneralSettings::MODE_TRIMS_ONLY, "TRIMS_ONLY" }, - { GeneralSettings::MODE_KEYS_ONLY, "KEYS_ONLY" }, - { GeneralSettings::MODE_SWITCHABLE, "SWITCHABLE" }, - { GeneralSettings::MODE_GLOBAL, "GLOBAL" }, + { GeneralSettings::HATS_MODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { GeneralSettings::HATS_MODE_KEYS_ONLY, "KEYS_ONLY" }, + { GeneralSettings::HATS_MODE_SWITCHABLE, "SWITCHABLE" }, + { GeneralSettings::HATS_MODE_GLOBAL, "GLOBAL" }, }; struct YamlTrim { diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index fa258c614de..8bd485cbf94 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -684,13 +684,13 @@ QString GeneralSettings::hatsModeToString() const QString GeneralSettings::hatsModeToString(int value) { switch(value) { - case MODE_TRIMS_ONLY: + case HATS_MODE_TRIMS_ONLY: return tr("Trims only"); - case MODE_KEYS_ONLY: + case HATS_MODE_KEYS_ONLY: return tr("Keys only"); - case MODE_SWITCHABLE: + case HATS_MODE_SWITCHABLE: return tr("Switchable"); - case MODE_GLOBAL: + case HATS_MODE_GLOBAL: return tr("Global"); default: return CPN_STR_UNKNOWN_ITEM; @@ -704,7 +704,7 @@ AbstractStaticItemModel * GeneralSettings::hatsModeItemModel(bool radio_setup) mdl->setName(AIM_GS_HATSMODE); for (int i = 0; i < HATS_MODE_COUNT; i++) { - mdl->appendToItemList(hatsModeToString(i), i, i == MODE_GLOBAL && radio_setup ? false : true); + mdl->appendToItemList(hatsModeToString(i), i, i == HATS_MODE_GLOBAL && radio_setup ? false : true); } mdl->loadItemList(); diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index 6bfd481d75a..60fac66f35d 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -174,10 +174,10 @@ class GeneralSettings { }; enum HatsMode { - MODE_TRIMS_ONLY, - MODE_KEYS_ONLY, - MODE_SWITCHABLE, - MODE_GLOBAL, + HATS_MODE_TRIMS_ONLY, + HATS_MODE_KEYS_ONLY, + HATS_MODE_SWITCHABLE, + HATS_MODE_GLOBAL, HATS_MODE_COUNT }; diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 9789a8269e4..91e5ad77bec 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -659,10 +659,10 @@ enum BluetoothModes { #if defined(USE_TRIMS_AS_BUTTONS) enum HatsMode { - MODE_TRIMS_ONLY, - MODE_KEYS_ONLY, - MODE_SWITCHABLE, - MODE_GLOBAL + HATS_MODE_TRIMS_ONLY, + HATS_MODE_KEYS_ONLY, + HATS_MODE_SWITCHABLE, + HATS_MODE_GLOBAL }; #endif diff --git a/radio/src/gui/colorlcd/radio_setup.cpp b/radio/src/gui/colorlcd/radio_setup.cpp index 282d9a8c533..7c3aeb22981 100644 --- a/radio/src/gui/colorlcd/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio_setup.cpp @@ -814,7 +814,7 @@ void RadioSetupPage::build(FormWindow * window) #if defined(USE_TRIMS_AS_BUTTONS) line = window->newLine(&grid); new StaticText(line, rect_t{}, STR_HATS_MODE, 0, COLOR_THEME_PRIMARY1); - new Choice(line, rect_t{}, STR_HATS_OPT, MODE_TRIMS_ONLY, MODE_SWITCHABLE, + new Choice(line, rect_t{}, STR_HATS_OPT, HATS_MODE_TRIMS_ONLY, HATS_MODE_SWITCHABLE, GET_SET_DEFAULT(g_eeGeneral.hatsMode)); #endif diff --git a/radio/src/gui/colorlcd/trims_setup.cpp b/radio/src/gui/colorlcd/trims_setup.cpp index 3e5d25879d2..ef956ff3b23 100644 --- a/radio/src/gui/colorlcd/trims_setup.cpp +++ b/radio/src/gui/colorlcd/trims_setup.cpp @@ -59,7 +59,7 @@ TrimsSetup::TrimsSetup() : Page(ICON_MODEL_SETUP) // Hats mode for NV14/EL18 line = body.newLine(&grid); new StaticText(line, rect_t{}, STR_HATS_MODE, 0, COLOR_THEME_PRIMARY1); - new Choice(line, rect_t{}, STR_HATS_OPT, MODE_TRIMS_ONLY, MODE_GLOBAL, + new Choice(line, rect_t{}, STR_HATS_OPT, HATS_MODE_TRIMS_ONLY, HATS_MODE_GLOBAL, GET_SET_DEFAULT(g_model.hatsMode)); #endif diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index 7e9da666d13..72c8f246eeb 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -348,8 +348,8 @@ static void transpose_trims(uint32_t *keys) static uint8_t state = 0; bool allowModeSwitch = - ((g_model.hatsMode == MODE_GLOBAL && g_eeGeneral.hatsMode == MODE_SWITCHABLE) || - (g_model.hatsMode == MODE_SWITCHABLE)) && + ((g_model.hatsMode == HATS_MODE_GLOBAL && g_eeGeneral.hatsMode == HATS_MODE_SWITCHABLE) || + (g_model.hatsMode == HATS_MODE_SWITCHABLE)) && !getTransposeTrimsForLUA(); if(allowModeSwitch) { diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 8cf56709cc1..6cb94f256ec 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -268,15 +268,15 @@ void checkSpeakerVolume() #if defined(USE_TRIMS_AS_BUTTONS) void checkTrimsAsButtons() { - uint8_t hatsMode = g_model.hatsMode == MODE_GLOBAL ? g_eeGeneral.hatsMode : g_model.hatsMode; + uint8_t hatsMode = g_model.hatsMode == HATS_MODE_GLOBAL ? g_eeGeneral.hatsMode : g_model.hatsMode; - static bool oldHatsModeButtons = hatsMode == MODE_KEYS_ONLY; + static bool oldHatsModeButtons = hatsMode == HATS_MODE_KEYS_ONLY; - if(hatsMode == MODE_TRIMS_ONLY) { + if(hatsMode == HATS_MODE_TRIMS_ONLY) { setTrimsAsButtons(false); } - if(hatsMode == MODE_KEYS_ONLY) { + if(hatsMode == HATS_MODE_KEYS_ONLY) { setTrimsAsButtons(true); } diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 0adfd28850a..5eafca3fac8 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -5,10 +5,10 @@ // const struct YamlIdStr enum_HatsMode[] = { - { MODE_TRIMS_ONLY, "TRIMS_ONLY" }, - { MODE_KEYS_ONLY, "KEYS_ONLY" }, - { MODE_SWITCHABLE, "SWITCHABLE " }, - { MODE_GLOBAL, "GLOBAL" }, + { HATS_MODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATS_MODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATS_MODE_SWITCHABLE, "SWITCHABLE" }, + { HATS_MODE_GLOBAL, "GLOBAL" }, { 0, NULL } }; From 300ab30456c97b430cc275cd535ca6c46518398f Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sat, 5 Aug 2023 14:46:10 +0200 Subject: [PATCH 19/34] code cleanup --- radio/src/dataconstants.h | 2 - radio/src/gui/colorlcd/popups.cpp | 36 +++++++++++++++++ radio/src/gui/colorlcd/popups.h | 3 +- .../src/gui/colorlcd/themes/etx_lv_theme.cpp | 40 ++++++++++++++++++- radio/src/main.cpp | 2 +- .../thirdparty/libopenui/src/mainwindow.cpp | 9 ++++- .../libopenui/src/widgets/etx_obj_create.h | 3 +- radio/src/thirdparty/libopenui/src/window.h | 4 +- 8 files changed, 90 insertions(+), 9 deletions(-) diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 91e5ad77bec..ff75e0c1cf1 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -657,14 +657,12 @@ enum BluetoothModes { #endif }; -#if defined(USE_TRIMS_AS_BUTTONS) enum HatsMode { HATS_MODE_TRIMS_ONLY, HATS_MODE_KEYS_ONLY, HATS_MODE_SWITCHABLE, HATS_MODE_GLOBAL }; -#endif enum UartSampleModes { UART_SAMPLE_MODE_NORMAL = 0, diff --git a/radio/src/gui/colorlcd/popups.cpp b/radio/src/gui/colorlcd/popups.cpp index 2aaf51f4da3..2ebfdf820a6 100644 --- a/radio/src/gui/colorlcd/popups.cpp +++ b/radio/src/gui/colorlcd/popups.cpp @@ -111,3 +111,39 @@ void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info, bool wait } } } + +class BubbleDialog : public Window +{ + public: + BubbleDialog(const char* message, int timeout) : + Window(MainWindow::instance(), rect_t{50, LCD_H - 100, LCD_W - 100, 50}, OPAQUE, 0, etx_bubble_popup_create) + { + lv_obj_set_parent(lvobj, lv_layer_top()); + + auto label = lv_label_create(lvobj); + lv_label_set_text(label, message); + lv_obj_center(label); + lv_obj_set_width(label, lv_pct(100)); + lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0); + lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP); + + endTime = RTOS_GET_MS() + timeout; + } + + bool isBubblePopup() override { return true; } + + void checkEvents() override + { + if (RTOS_GET_MS() >= endTime) { + deleteLater(); + } + } + + protected: + uint32_t endTime; +}; + +void POPUP_BUBBLE(const char* message, uint32_t timeout) +{ + new BubbleDialog(message, timeout); +} \ No newline at end of file diff --git a/radio/src/gui/colorlcd/popups.h b/radio/src/gui/colorlcd/popups.h index 7cc4b9e8920..8e2254ab854 100644 --- a/radio/src/gui/colorlcd/popups.h +++ b/radio/src/gui/colorlcd/popups.h @@ -28,5 +28,6 @@ typedef std::function ProgressHandle void POPUP_INFORMATION(const char * message); void POPUP_WARNING(const char * message, const char * info = nullptr); void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info = nullptr, bool waitForClose = true); +void POPUP_BUBBLE(const char * message, uint32_t timeout); -void show_ui_popup(); +void show_ui_popup(); \ No newline at end of file diff --git a/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp b/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp index c47ace5a4a5..100eee3d7fd 100644 --- a/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp +++ b/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp @@ -107,6 +107,8 @@ typedef struct { lv_style_t cb_marker; lv_style_t cb_marker_checked; + // Bubble popup + lv_style_t bubble_popup; } my_theme_styles_t; /********************** @@ -327,6 +329,14 @@ static void style_init(void) lv_style_init(&styles.cb_marker_checked); lv_style_set_bg_img_src(&styles.cb_marker_checked, LV_SYMBOL_OK); lv_style_set_text_font(&styles.cb_marker_checked, theme.font_small); + + // Bubble popup + lv_style_init(&styles.bubble_popup); + lv_style_set_bg_opa(&styles.bubble_popup, LV_OPA_COVER); + lv_style_set_pad_all(&styles.bubble_popup, 4); + lv_style_set_border_opa(&styles.bubble_popup, LV_OPA_COVER); + lv_style_set_border_width(&styles.bubble_popup, 3); + lv_style_set_radius(&styles.bubble_popup, 10); } // Always update colors in case theme changes @@ -395,6 +405,10 @@ static void style_init(void) lv_style_set_border_color(&styles.cb_marker_checked, makeLvColor(COLOR_THEME_SECONDARY1)); lv_style_set_bg_color(&styles.cb_marker_checked, makeLvColor(COLOR_THEME_SECONDARY1)); lv_style_set_text_color(&styles.cb_marker_checked, makeLvColor(COLOR_THEME_PRIMARY2)); + + lv_style_set_bg_color(&styles.bubble_popup, makeLvColor(COLOR2FLAGS(WHITE))); + lv_style_set_border_color(&styles.bubble_popup, makeLvColor(COLOR2FLAGS(BLACK))); + lv_style_set_text_color(&styles.bubble_popup, makeLvColor(COLOR2FLAGS(BLACK))); } /********************** @@ -598,8 +612,12 @@ void etx_checkbox_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_obj_add_style(obj, &styles.disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); } +void bubble_popup_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) +{ + lv_obj_add_style(obj, &styles.bubble_popup, 0); } + // Object classes const lv_obj_class_t input_mix_line_class = { .base_class = &lv_btn_class, @@ -796,6 +814,21 @@ const lv_obj_class_t etx_checkbox_class = { .instance_size = sizeof(lv_checkbox_t), }; + +const lv_obj_class_t etx_bubble_popup_class = { + .base_class = &window_base_class, + .constructor_cb = bubble_popup_constructor, + .destructor_cb = nullptr, + .user_data = nullptr, + .event_cb = nullptr, + .width_def = LV_DPI_DEF, + .height_def = LV_DPI_DEF, + .editable = LV_OBJ_CLASS_EDITABLE_FALSE, + .group_def = LV_OBJ_CLASS_GROUP_DEF_FALSE, + .instance_size = sizeof(lv_obj_t) +}; + + // Event handlers static void field_edit_event(const lv_obj_class_t* class_p, lv_event_t* e) { @@ -913,6 +946,11 @@ lv_obj_t* etx_choice_create(lv_obj_t* parent) return etx_create(&etx_choice_class, parent); } +lv_obj_t* etx_bubble_popup_create(lv_obj_t* parent) +{ + return etx_create(&etx_bubble_popup_class, parent); +} + lv_obj_t* etx_bar_create(lv_obj_t* parent) { return etx_create(&etx_bar_class, parent); @@ -948,4 +986,4 @@ lv_obj_t* etx_modal_title_create(lv_obj_t* parent) lv_obj_add_style(obj, &styles.modal_title, 0); return obj; -} +} \ No newline at end of file diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 6cb94f256ec..234dbf9ed9e 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -288,7 +288,7 @@ void checkTrimsAsButtons() { oldHatsModeButtons = !oldHatsModeButtons; audioKeyPress(); - POPUP_INFORMATION(hatsModeButtons ? STR_HATS_MODE_BUTTONS : STR_HATS_MODE_TRIMS); + POPUP_BUBBLE(hatsModeButtons ? STR_HATS_MODE_BUTTONS : STR_HATS_MODE_TRIMS, 2000); } #endif diff --git a/radio/src/thirdparty/libopenui/src/mainwindow.cpp b/radio/src/thirdparty/libopenui/src/mainwindow.cpp index 939e57eeb3e..b925b16986d 100644 --- a/radio/src/thirdparty/libopenui/src/mainwindow.cpp +++ b/radio/src/thirdparty/libopenui/src/mainwindow.cpp @@ -43,6 +43,13 @@ void MainWindow::run(bool trash) auto opaque = Layer::getFirstOpaque(); if (opaque) opaque->checkEvents(); + auto copy = children; + for (auto child: copy) { + if (!child->deleted() && child->isBubblePopup()) { + child->checkEvents(); + } + } + if (trash) emptyTrash(); auto delta = ticksNow() - start; @@ -50,4 +57,4 @@ void MainWindow::run(bool trash) TRACE_WINDOWS("MainWindow::run took %dms", (ticksNow() - start) / SYSTEM_TICKS_1MS); } -} +} \ No newline at end of file diff --git a/radio/src/thirdparty/libopenui/src/widgets/etx_obj_create.h b/radio/src/thirdparty/libopenui/src/widgets/etx_obj_create.h index e7c2902ee0c..f8957f11df5 100644 --- a/radio/src/thirdparty/libopenui/src/widgets/etx_obj_create.h +++ b/radio/src/thirdparty/libopenui/src/widgets/etx_obj_create.h @@ -41,6 +41,7 @@ lv_obj_t* etx_modal_content_create(lv_obj_t* parent); lv_obj_t* etx_modal_title_create(lv_obj_t* parent); lv_obj_t* etx_bar_create(lv_obj_t* parent); lv_obj_t* etx_checkbox_create(lv_obj_t* parent); +lv_obj_t* etx_bubble_popup_create(lv_obj_t* parent); lv_obj_t* input_mix_line_create(lv_obj_t* parent); -lv_obj_t* input_mix_group_create(lv_obj_t* parent); +lv_obj_t* input_mix_group_create(lv_obj_t* parent); \ No newline at end of file diff --git a/radio/src/thirdparty/libopenui/src/window.h b/radio/src/thirdparty/libopenui/src/window.h index 0eb72d082b9..33a253c8bf0 100644 --- a/radio/src/thirdparty/libopenui/src/window.h +++ b/radio/src/thirdparty/libopenui/src/window.h @@ -203,6 +203,7 @@ class Window virtual bool isTopBar() { return false; } virtual bool isWidgetsContainer() { return false; } + virtual bool isBubblePopup() { return false; } protected: static std::list trash; @@ -228,5 +229,4 @@ class Window void removeChild(Window * window); virtual void invalidate(const rect_t & rect); -}; - +}; \ No newline at end of file From 8af7e86e9f41ccb3ce64514b25ea25b862ecb390 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sat, 5 Aug 2023 21:49:41 +0200 Subject: [PATCH 20/34] code cleanup with harmonizing variable and define names --- .../firmwares/edgetx/yaml_generalsettings.cpp | 6 ++-- .../src/firmwares/edgetx/yaml_modeldata.cpp | 8 ++--- companion/src/firmwares/generalsettings.cpp | 12 ++++---- companion/src/firmwares/generalsettings.h | 10 +++---- radio/src/dataconstants.h | 8 ++--- radio/src/gui/colorlcd/LvglWrapper.cpp | 2 +- .../colorlcd/radio_ghost_module_config.cpp | 6 ++-- radio/src/gui/colorlcd/radio_setup.cpp | 8 ++--- radio/src/gui/colorlcd/tabsgroup.cpp | 4 +-- radio/src/gui/colorlcd/trims_setup.cpp | 8 ++--- radio/src/gui/colorlcd/view_main.cpp | 4 +-- radio/src/keys.cpp | 30 +++++++++---------- radio/src/keys.h | 10 +++---- radio/src/lua/api_general.cpp | 16 +++++----- radio/src/lua/interface.cpp | 12 ++++---- radio/src/lua/lua_widget.cpp | 2 +- radio/src/main.cpp | 28 ++++++++--------- .../storage/yaml/yaml_datastructs_nv14.cpp | 8 ++--- .../common/arm/stm32/bootloader/boot.cpp | 4 +-- radio/src/targets/nv14/CMakeLists.txt | 2 +- .../src/targets/nv14/bootloader/boot_menu.cpp | 2 +- radio/src/targets/simu/opentxsimulator.cpp | 2 +- radio/src/targets/simu/simpgmspace.cpp | 4 +-- .../thirdparty/libopenui/src/numberedit.cpp | 4 +-- radio/src/translations.cpp | 10 +++---- radio/src/translations.h | 10 +++---- radio/src/translations/cn.h | 10 +++---- radio/src/translations/cz.h | 10 +++---- radio/src/translations/da.h | 10 +++---- radio/src/translations/de.h | 10 +++---- radio/src/translations/en.h | 10 +++---- radio/src/translations/es.h | 10 +++---- radio/src/translations/fi.h | 10 +++---- radio/src/translations/fr.h | 10 +++---- radio/src/translations/he.h | 10 +++---- radio/src/translations/it.h | 10 +++---- radio/src/translations/jp.h | 10 +++---- radio/src/translations/nl.h | 10 +++---- radio/src/translations/pl.h | 10 +++---- radio/src/translations/pt.h | 10 +++---- radio/src/translations/se.h | 10 +++---- radio/src/translations/tw.h | 10 +++---- 42 files changed, 190 insertions(+), 190 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index a3448e65c6a..2f1667f328c 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -118,9 +118,9 @@ const YamlLookupTable internalModuleLut = { }; static const YamlLookupTable hatsModeLut = { - { GeneralSettings::HATS_MODE_TRIMS_ONLY, "TRIMS_ONLY" }, - { GeneralSettings::HATS_MODE_KEYS_ONLY, "KEYS_ONLY" }, - { GeneralSettings::HATS_MODE_SWITCHABLE, "SWITCHABLE" }, + { GeneralSettings::HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { GeneralSettings::HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { GeneralSettings::HATSMODE_SWITCHABLE, "SWITCHABLE" }, }; YamlTelemetryBaudrate::YamlTelemetryBaudrate( diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index f07044dd6e6..cc210f261d6 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -89,10 +89,10 @@ static const YamlLookupTable usbJoystickIfModeLut = { }; static const YamlLookupTable hatsModeLut = { - { GeneralSettings::HATS_MODE_TRIMS_ONLY, "TRIMS_ONLY" }, - { GeneralSettings::HATS_MODE_KEYS_ONLY, "KEYS_ONLY" }, - { GeneralSettings::HATS_MODE_SWITCHABLE, "SWITCHABLE" }, - { GeneralSettings::HATS_MODE_GLOBAL, "GLOBAL" }, + { GeneralSettings::HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { GeneralSettings::HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { GeneralSettings::HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { GeneralSettings::HATSMODE_GLOBAL, "GLOBAL" }, }; struct YamlTrim { diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index 8bd485cbf94..710e5079771 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -684,13 +684,13 @@ QString GeneralSettings::hatsModeToString() const QString GeneralSettings::hatsModeToString(int value) { switch(value) { - case HATS_MODE_TRIMS_ONLY: + case HATSMODE_TRIMS_ONLY: return tr("Trims only"); - case HATS_MODE_KEYS_ONLY: + case HATSMODE_KEYS_ONLY: return tr("Keys only"); - case HATS_MODE_SWITCHABLE: + case HATSMODE_SWITCHABLE: return tr("Switchable"); - case HATS_MODE_GLOBAL: + case HATSMODE_GLOBAL: return tr("Global"); default: return CPN_STR_UNKNOWN_ITEM; @@ -703,8 +703,8 @@ AbstractStaticItemModel * GeneralSettings::hatsModeItemModel(bool radio_setup) AbstractStaticItemModel * mdl = new AbstractStaticItemModel(); mdl->setName(AIM_GS_HATSMODE); - for (int i = 0; i < HATS_MODE_COUNT; i++) { - mdl->appendToItemList(hatsModeToString(i), i, i == HATS_MODE_GLOBAL && radio_setup ? false : true); + for (int i = 0; i < HATSMODE_COUNT; i++) { + mdl->appendToItemList(hatsModeToString(i), i, i == HATSMODE_GLOBAL && radio_setup ? false : true); } mdl->loadItemList(); diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index 60fac66f35d..6e237d5f40b 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -174,11 +174,11 @@ class GeneralSettings { }; enum HatsMode { - HATS_MODE_TRIMS_ONLY, - HATS_MODE_KEYS_ONLY, - HATS_MODE_SWITCHABLE, - HATS_MODE_GLOBAL, - HATS_MODE_COUNT + HATSMODE_TRIMS_ONLY, + HATSMODE_KEYS_ONLY, + HATSMODE_SWITCHABLE, + HATSMODE_GLOBAL, + HATSMODE_COUNT }; GeneralSettings() { clear(); } diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index ff75e0c1cf1..b98aa3240af 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -658,10 +658,10 @@ enum BluetoothModes { }; enum HatsMode { - HATS_MODE_TRIMS_ONLY, - HATS_MODE_KEYS_ONLY, - HATS_MODE_SWITCHABLE, - HATS_MODE_GLOBAL + HATSMODE_TRIMS_ONLY, + HATSMODE_KEYS_ONLY, + HATSMODE_SWITCHABLE, + HATSMODE_GLOBAL }; enum UartSampleModes { diff --git a/radio/src/gui/colorlcd/LvglWrapper.cpp b/radio/src/gui/colorlcd/LvglWrapper.cpp index 7d496a9694c..cd27aa238cf 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.cpp +++ b/radio/src/gui/colorlcd/LvglWrapper.cpp @@ -235,7 +235,7 @@ extern "C" void touchDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data) #endif } -#if defined(USE_TRIMS_AS_BUTTONS) +#if defined(USE_HATS_AS_KEYS) int16_t getEmuRotaryData(); diff --git a/radio/src/gui/colorlcd/radio_ghost_module_config.cpp b/radio/src/gui/colorlcd/radio_ghost_module_config.cpp index a328687ef3a..f5976861f1c 100644 --- a/radio/src/gui/colorlcd/radio_ghost_module_config.cpp +++ b/radio/src/gui/colorlcd/radio_ghost_module_config.cpp @@ -130,7 +130,7 @@ RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) : lv_group_set_editing(lv_group_get_default(), true); lv_obj_add_event_cb(lvobj, ghostmoduleconfig_cb, LV_EVENT_KEY, this); #if defined(TRIMS_EMULATE_BUTTONS) - setTrimsAsButtons(true); // Use trim joysticks to operate menu (e.g. on NV14) + setHatsAsKeys(true); // Use trim joysticks to operate menu (e.g. on NV14) #endif } @@ -156,7 +156,7 @@ void RadioGhostModuleConfig::onEvent(event_t event) RTOS_WAIT_MS(10); Page::onEvent(event); #if defined(TRIMS_EMULATE_BUTTONS) - setTrimsAsButtons(false); // switch trims back to normal + setHatsAsKeys(false); // switch trims back to normal #endif break; } @@ -175,7 +175,7 @@ void RadioGhostModuleConfig::checkEvents() RTOS_WAIT_MS(10); deleteLater(); #if defined(TRIMS_EMULATE_BUTTONS) - setTrimsAsButtons(false); // switch trims back to normal + setHatsAsKeys(false); // switch trims back to normal #endif } } diff --git a/radio/src/gui/colorlcd/radio_setup.cpp b/radio/src/gui/colorlcd/radio_setup.cpp index 7c3aeb22981..49b907401aa 100644 --- a/radio/src/gui/colorlcd/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio_setup.cpp @@ -803,7 +803,7 @@ void RadioSetupPage::build(FormWindow * window) new Choice(line, rect_t{}, STR_USBMODES, USB_UNSELECTED_MODE, USB_MAX_MODE, GET_SET_DEFAULT(g_eeGeneral.USBMode)); -#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS) line = window->newLine(&grid); new StaticText(line, rect_t{}, STR_ROTARY_ENC_MODE, 0, COLOR_THEME_PRIMARY1); new Choice(line, rect_t{}, STR_ROTARY_ENC_OPT, ROTARY_ENCODER_MODE_NORMAL, @@ -811,10 +811,10 @@ void RadioSetupPage::build(FormWindow * window) GET_SET_DEFAULT(g_eeGeneral.rotEncMode)); #endif -#if defined(USE_TRIMS_AS_BUTTONS) +#if defined(USE_HATS_AS_KEYS) line = window->newLine(&grid); - new StaticText(line, rect_t{}, STR_HATS_MODE, 0, COLOR_THEME_PRIMARY1); - new Choice(line, rect_t{}, STR_HATS_OPT, HATS_MODE_TRIMS_ONLY, HATS_MODE_SWITCHABLE, + new StaticText(line, rect_t{}, STR_HATSMODE, 0, COLOR_THEME_PRIMARY1); + new Choice(line, rect_t{}, STR_HATSOPT, HATSMODE_TRIMS_ONLY, HATSMODE_SWITCHABLE, GET_SET_DEFAULT(g_eeGeneral.hatsMode)); #endif diff --git a/radio/src/gui/colorlcd/tabsgroup.cpp b/radio/src/gui/colorlcd/tabsgroup.cpp index affcf788cb5..611fe826539 100644 --- a/radio/src/gui/colorlcd/tabsgroup.cpp +++ b/radio/src/gui/colorlcd/tabsgroup.cpp @@ -273,7 +273,7 @@ void TabsGroup::onEvent(event_t event) #if defined(HARDWARE_KEYS) TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event); -#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS) if (event == EVT_KEY_FIRST(KEY_PAGEDN)) { #else if (event == EVT_KEY_BREAK(KEY_PAGEDN)) { @@ -282,7 +282,7 @@ void TabsGroup::onEvent(event_t event) uint8_t current = header.carousel.getCurrentIndex() + 1; setCurrentTab(current >= tabs.size() ? 0 : current); } -#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS) else if (event == EVT_KEY_FIRST(KEY_PAGEUP)) { #else else if (event == EVT_KEY_LONG(KEY_PAGEDN)) { diff --git a/radio/src/gui/colorlcd/trims_setup.cpp b/radio/src/gui/colorlcd/trims_setup.cpp index ef956ff3b23..d355bc1b979 100644 --- a/radio/src/gui/colorlcd/trims_setup.cpp +++ b/radio/src/gui/colorlcd/trims_setup.cpp @@ -55,12 +55,12 @@ TrimsSetup::TrimsSetup() : Page(ICON_MODEL_SETUP) auto btn_obj = btn->getLvObj(); lv_obj_set_width(btn_obj, lv_pct(100)); -#if defined(USE_TRIMS_AS_BUTTONS) +#if defined(USE_HATS_AS_KEYS) // Hats mode for NV14/EL18 line = body.newLine(&grid); - new StaticText(line, rect_t{}, STR_HATS_MODE, 0, COLOR_THEME_PRIMARY1); - new Choice(line, rect_t{}, STR_HATS_OPT, HATS_MODE_TRIMS_ONLY, HATS_MODE_GLOBAL, - GET_SET_DEFAULT(g_model.hatsMode)); + new StaticText(line, rect_t{}, STR_HATSMODE, 0, COLOR_THEME_PRIMARY1); + new Choice(line, rect_t{}, STR_HATSOPT, HATSMODE_TRIMS_ONLY, HATSMODE_GLOBAL, + GET_SET_DEFAULT(g_model.hatsMode)); #endif // Trim step diff --git a/radio/src/gui/colorlcd/view_main.cpp b/radio/src/gui/colorlcd/view_main.cpp index 7a6409a196f..9e882f6c2af 100644 --- a/radio/src/gui/colorlcd/view_main.cpp +++ b/radio/src/gui/colorlcd/view_main.cpp @@ -279,7 +279,7 @@ void ViewMain::onEvent(event_t event) new ScreenMenu(); break; -#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS) case EVT_KEY_FIRST(KEY_PAGEDN): #else case EVT_KEY_BREAK(KEY_PAGEDN): @@ -292,7 +292,7 @@ void ViewMain::onEvent(event_t event) //TODO: these need to go away! // -> board code should map the keys as required -#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS) case EVT_KEY_FIRST(KEY_PAGEUP): #else case EVT_KEY_LONG(KEY_PAGEDN): diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index 72c8f246eeb..9c12aa10cb7 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -18,7 +18,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ -#if !defined(BOOT) && defined(USE_TRIMS_AS_BUTTONS) +#if !defined(BOOT) && defined(USE_HATS_AS_KEYS) #include "opentx.h" #endif @@ -293,23 +293,23 @@ uint8_t keysGetTrimState(uint8_t trim) return trim_keys[trim].pressed(); } -#if defined(USE_TRIMS_AS_BUTTONS) +#if defined(USE_HATS_AS_KEYS) #define ROTARY_EMU_KEY_REPEAT_RATE 12 // times 10 [ms] static bool _trims_as_buttons = false; static bool _trims_as_buttons_LUA = false; -void setTrimsAsButtons(bool val) { _trims_as_buttons = val; } -bool getTrimsAsButtons() { return _trims_as_buttons; } +void setHatsAsKeys(bool val) { _trims_as_buttons = val; } +bool getHatsAsKeys() { return _trims_as_buttons; } -void setTransposeTrimsForLUA(bool val) { _trims_as_buttons_LUA = val; } -bool getTransposeTrimsForLUA() { return _trims_as_buttons_LUA; } +void setTransposeHatsForLUA(bool val) { _trims_as_buttons_LUA = val; } +bool getTransposeHatsForLUA() { return _trims_as_buttons_LUA; } int16_t getEmuRotaryData() { static bool rotaryTrimPressed = false; static tmr10ms_t timePressed = 0; - if(getTrimsAsButtons() || getTransposeTrimsForLUA()) { + if(getHatsAsKeys() || getTransposeHatsForLUA()) { tmr10ms_t now = get_tmr10ms(); if(rotaryTrimPressed) { @@ -348,9 +348,9 @@ static void transpose_trims(uint32_t *keys) static uint8_t state = 0; bool allowModeSwitch = - ((g_model.hatsMode == HATS_MODE_GLOBAL && g_eeGeneral.hatsMode == HATS_MODE_SWITCHABLE) || - (g_model.hatsMode == HATS_MODE_SWITCHABLE)) && - !getTransposeTrimsForLUA(); + ((g_model.hatsMode == HATSMODE_GLOBAL && g_eeGeneral.hatsMode == HATSMODE_SWITCHABLE) || + (g_model.hatsMode == HATSMODE_SWITCHABLE)) && + !getTransposeHatsForLUA(); if(allowModeSwitch) { static bool lastExitState = false; @@ -380,7 +380,7 @@ static void transpose_trims(uint32_t *keys) } if(enterPressed) { // ENTER received with EXIT still pressed - setTrimsAsButtons(!getTrimsAsButtons()); // change mode and don't forward EXIT and ENTER keys + setHatsAsKeys(!getHatsAsKeys()); // change mode and don't forward EXIT and ENTER keys killEvents(KEY_EXIT); killEvents(KEY_ENTER); state = 0; // go to for EXIT to be released @@ -391,8 +391,8 @@ static void transpose_trims(uint32_t *keys) } else state = 0; // state machine in idle if not in mode "BOTH" - if(getTrimsAsButtons() || // map hats to keys in button mode or LUA active - getTransposeTrimsForLUA()) { + if(getHatsAsKeys() || // map hats to keys in button mode or LUA active + getTransposeHatsForLUA()) { auto trims = readTrims(); // spare key in buttons mode: left hat left @@ -414,10 +414,10 @@ bool keysPollingCycle() uint32_t trims_input; uint32_t keys_input = readKeys(); -#if defined(USE_TRIMS_AS_BUTTONS) +#if defined(USE_HATS_AS_KEYS) transpose_trims(&keys_input); - if (getTrimsAsButtons() || getTransposeTrimsForLUA()) { + if (getHatsAsKeys() || getTransposeHatsForLUA()) { trims_input = 0; } else { trims_input = readTrims(); diff --git a/radio/src/keys.h b/radio/src/keys.h index 1a50202a19d..a2c6619f0e5 100644 --- a/radio/src/keys.h +++ b/radio/src/keys.h @@ -180,11 +180,11 @@ uint8_t keysGetTrimState(uint8_t trim); bool keysPollingCycle(); bool rotaryEncoderPollingCycle(); -#if defined(USE_TRIMS_AS_BUTTONS) -void setTrimsAsButtons(bool val); -bool getTrimsAsButtons(); -void setTransposeTrimsForLUA(bool val); -bool getTransposeTrimsForLUA(); +#if defined(USE_HATS_AS_KEYS) +void setHatsAsKeys(bool val); +bool getHatsAsKeys(); +void setTransposeHatsForLUA(bool val); +bool getTransposeHatsForLUA(); #endif struct InactivityData diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 0fc232860e8..082f7bd6145 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -886,7 +886,7 @@ Return rotary encoder mode */ static int luaGetRotEncMode(lua_State * L) { -#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS) lua_pushunsigned(L, g_eeGeneral.rotEncMode); #else lua_pushunsigned(L, 0); @@ -3090,7 +3090,7 @@ LROT_BEGIN(etxcst, NULL, 0) LROT_NUMENTRY( EVT_VIRTUAL_ENTER_LONG, EVT_KEY_LONG(KEY_ENTER) ) LROT_NUMENTRY( EVT_VIRTUAL_EXIT, EVT_KEY_BREAK(KEY_EXIT) ) #elif defined(COLORLCD) -#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS) LROT_NUMENTRY( EVT_VIRTUAL_PREV_PAGE, EVT_KEY_BREAK(KEY_PAGEUP) ) LROT_NUMENTRY( EVT_VIRTUAL_NEXT_PAGE, EVT_KEY_BREAK(KEY_PAGEDN) ) #else @@ -3115,19 +3115,19 @@ LROT_BEGIN(etxcst, NULL, 0) KEY_EVENTS(MENU, KEY_MENU) #endif -#if defined(KEYS_GPIO_REG_RIGHT) && defined(COLORLCD) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_RIGHT) && defined(COLORLCD) || defined(USE_HATS_AS_KEYS) KEY_EVENTS(TELEM, KEY_TELE) #elif defined(KEYS_GPIO_REG_RIGHT) KEY_EVENTS(RIGHT, KEY_RIGHT) #endif -#if defined(KEYS_GPIO_REG_UP) && defined(COLORLCD) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_UP) && defined(COLORLCD) || defined(USE_HATS_AS_KEYS) KEY_EVENTS(MODEL, KEY_MODEL) #elif defined(KEYS_GPIO_REG_UP) KEY_EVENTS(UP, KEY_UP) #endif -#if defined(KEYS_GPIO_REG_LEFT) && defined(COLORLCD) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_LEFT) && defined(COLORLCD) || defined(USE_HATS_AS_KEYS) KEY_EVENTS(SYS, KEY_SYS) #elif defined(KEYS_GPIO_REG_LEFT) KEY_EVENTS(LEFT, KEY_LEFT) @@ -3139,11 +3139,11 @@ LROT_BEGIN(etxcst, NULL, 0) KEY_EVENTS(DOWN, KEY_DOWN) #endif -#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_PAGEUP) || defined(USE_HATS_AS_KEYS) KEY_EVENTS(PAGEUP, KEY_PAGEUP) #endif -#if defined(KEYS_GPIO_REG_PAGEDN) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(KEYS_GPIO_REG_PAGEDN) || defined(USE_HATS_AS_KEYS) KEY_EVENTS(PAGEDN, KEY_PAGEDN) #endif @@ -3163,7 +3163,7 @@ LROT_BEGIN(etxcst, NULL, 0) KEY_EVENTS(MINUS, KEY_MINUS) #endif -#if defined(ROTARY_ENCODER_NAVIGATION) || defined(USE_TRIMS_AS_BUTTONS) +#if defined(ROTARY_ENCODER_NAVIGATION) || defined(USE_HATS_AS_KEYS) KEY_EVENTS(ROT, KEY_ENTER) LROT_NUMENTRY( EVT_ROT_LEFT, EVT_ROTARY_LEFT ) LROT_NUMENTRY( EVT_ROT_RIGHT, EVT_ROTARY_RIGHT ) diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index 9c859e62e9b..8894f6864e5 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -252,8 +252,8 @@ void luaDisable() POPUP_WARNING("Lua disabled!"); luaState = INTERPRETER_PANIC; -#if defined(USE_TRIMS_AS_BUTTONS) - if (_is_standalone_script()) setTransposeTrimsForLUA(false); +#if defined(USE_HATS_AS_KEYS) + if (_is_standalone_script()) setTransposeHatsForLUA(false); #endif } @@ -1253,8 +1253,8 @@ bool luaTask(event_t evt, bool allowLcdUsage) init = true; luaState = INTERPRETER_LOADING; -#if defined(USE_TRIMS_AS_BUTTONS) - if (_is_standalone_script()) setTransposeTrimsForLUA(false); +#if defined(USE_HATS_AS_KEYS) + if (_is_standalone_script()) setTransposeHatsForLUA(false); #endif case INTERPRETER_LOADING: @@ -1269,8 +1269,8 @@ bool luaTask(event_t evt, bool allowLcdUsage) init = true; luaState = INTERPRETER_RUNNING; -#if defined(USE_TRIMS_AS_BUTTONS) - if (_is_standalone_script()) setTransposeTrimsForLUA(true); +#if defined(USE_HATS_AS_KEYS) + if (_is_standalone_script()) setTransposeHatsForLUA(true); #endif case INTERPRETER_RUNNING: diff --git a/radio/src/lua/lua_widget.cpp b/radio/src/lua/lua_widget.cpp index 306d2c32929..dee0855961e 100644 --- a/radio/src/lua/lua_widget.cpp +++ b/radio/src/lua/lua_widget.cpp @@ -175,7 +175,7 @@ void LuaEventHandler::onEvent(event_t event) if (event == EVT_KEY_LONG(KEY_EXIT)) { killEvents(KEY_EXIT); } -#if !defined(KEYS_GPIO_REG_PAGEUP) && !defined(USE_TRIMS_AS_BUTTONS) +#if !defined(KEYS_GPIO_REG_PAGEUP) && !defined(USE_HATS_AS_KEYS) else if (event == EVT_KEY_LONG(KEY_PAGEDN)) { killEvents(KEY_PAGEDN); } diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 234dbf9ed9e..2560e2bc37e 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -266,29 +266,29 @@ void checkSpeakerVolume() } } -#if defined(USE_TRIMS_AS_BUTTONS) -void checkTrimsAsButtons() { - uint8_t hatsMode = g_model.hatsMode == HATS_MODE_GLOBAL ? g_eeGeneral.hatsMode : g_model.hatsMode; +#if defined(USE_HATS_AS_KEYS) +void checkHatsAsKeys() { + uint8_t hatsMode = g_model.hatsMode == HATSMODE_GLOBAL ? g_eeGeneral.hatsMode : g_model.hatsMode; - static bool oldHatsModeButtons = hatsMode == HATS_MODE_KEYS_ONLY; + static bool oldHatsModeKeys = hatsMode == HATSMODE_KEYS_ONLY; - if(hatsMode == HATS_MODE_TRIMS_ONLY) { - setTrimsAsButtons(false); + if(hatsMode == HATSMODE_TRIMS_ONLY) { + setHatsAsKeys(false); } - if(hatsMode == HATS_MODE_KEYS_ONLY) { - setTrimsAsButtons(true); + if(hatsMode == HATSMODE_KEYS_ONLY) { + setHatsAsKeys(true); } - bool hatsModeButtons = getTrimsAsButtons(); + bool hatsModeKeys = getHatsAsKeys(); - if(hatsModeButtons == oldHatsModeButtons) + if(hatsModeKeys == oldHatsModeKeys) return; - oldHatsModeButtons = !oldHatsModeButtons; + oldHatsModeKeys = !oldHatsModeKeys; audioKeyPress(); - POPUP_BUBBLE(hatsModeButtons ? STR_HATS_MODE_BUTTONS : STR_HATS_MODE_TRIMS, 2000); + POPUP_BUBBLE(hatsModeKeys ? STR_HATSMODE_KEYS : STR_HATSMODE_TRIMS, 2000); } #endif @@ -551,8 +551,8 @@ void perMain() checkBacklight(); -#if defined(USE_TRIMS_AS_BUTTONS) - checkTrimsAsButtons(); +#if defined(USE_HATS_AS_KEYS) + checkHatsAsKeys(); #endif #if !defined(LIBOPENUI) diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 5eafca3fac8..e996b22370e 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -5,10 +5,10 @@ // const struct YamlIdStr enum_HatsMode[] = { - { HATS_MODE_TRIMS_ONLY, "TRIMS_ONLY" }, - { HATS_MODE_KEYS_ONLY, "KEYS_ONLY" }, - { HATS_MODE_SWITCHABLE, "SWITCHABLE" }, - { HATS_MODE_GLOBAL, "GLOBAL" }, + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, { 0, NULL } }; diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index 5012d5ad6b6..67e7b22237d 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -105,7 +105,7 @@ void interrupt10ms() keysPollingCycle(); -#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS) static rotenc_t rePreviousValue; rotenc_t reNewValue = rotaryEncoderGetValue(); @@ -288,7 +288,7 @@ void bootloaderInitApp() pwrOn(); -#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS) rotaryEncoderInit(); #endif diff --git a/radio/src/targets/nv14/CMakeLists.txt b/radio/src/targets/nv14/CMakeLists.txt index 14d07b8d9c3..1092f1c7f42 100644 --- a/radio/src/targets/nv14/CMakeLists.txt +++ b/radio/src/targets/nv14/CMakeLists.txt @@ -39,7 +39,7 @@ set(PCB_RF_BAUD 921600 CACHE STRING "INTERNAL_MODULE_BAUDRATE: ${RF_BAUD_RATE}") set_property(CACHE PCB_RF_BAUD PROPERTY STRINGS ${RF_BAUD_RATE}) add_definitions(-DPCBNV14 -DPCBFLYSKY -DAFHDS2_BAUDRATE=${PCB_RF_BAUD}) -add_definitions(-DBATTERY_CHARGE -DUSE_TRIMS_AS_BUTTONS) +add_definitions(-DBATTERY_CHARGE -DUSE_HATS_AS_KEYS) if (PCBREV STREQUAL EL18) set(FLAVOUR el18) diff --git a/radio/src/targets/nv14/bootloader/boot_menu.cpp b/radio/src/targets/nv14/bootloader/boot_menu.cpp index 492538563c5..590b276aea6 100644 --- a/radio/src/targets/nv14/bootloader/boot_menu.cpp +++ b/radio/src/targets/nv14/bootloader/boot_menu.cpp @@ -70,7 +70,7 @@ void bootloaderInitScreen() lcdInitDisplayDriver(); backlightInit(); backlightEnable(100); - setTrimsAsButtons(true); + setHatsAsKeys(true); } static void bootloaderDrawTitle(const char* text) diff --git a/radio/src/targets/simu/opentxsimulator.cpp b/radio/src/targets/simu/opentxsimulator.cpp index bb8a29ce1f4..5cb3cc8696e 100644 --- a/radio/src/targets/simu/opentxsimulator.cpp +++ b/radio/src/targets/simu/opentxsimulator.cpp @@ -298,7 +298,7 @@ extern volatile uint32_t rotencDt; void OpenTxSimulator::rotaryEncoderEvent(int steps) { -#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_TRIMS_AS_BUTTONS) +#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS) static uint32_t last_tick = 0; if (steps != 0) { if (g_eeGeneral.rotEncMode >= ROTARY_ENCODER_MODE_INVERT_BOTH) steps *= -1; diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index 01720aa5145..28af76c634e 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -448,9 +448,9 @@ void SET_POWER_REASON(uint32_t value) {} #if defined(TRIMS_EMULATE_BUTTONS) bool trimsAsButtons = false; -void setTrimsAsButtons(bool val) { trimsAsButtons = val; } +void setHatsAsKeys(bool val) { trimsAsButtons = val; } -bool getTrimsAsButtons() +bool getHatsAsKeys() { bool lua = false; #if defined(LUA) diff --git a/radio/src/thirdparty/libopenui/src/numberedit.cpp b/radio/src/thirdparty/libopenui/src/numberedit.cpp index 2ae88a460fb..960aed636a6 100644 --- a/radio/src/thirdparty/libopenui/src/numberedit.cpp +++ b/radio/src/thirdparty/libopenui/src/numberedit.cpp @@ -66,7 +66,7 @@ void NumberEdit::onEvent(event_t event) auto step = getStep(); step += (rotaryEncoderGetAccel() * getAccelFactor()) / 8; do { -#if defined(USE_TRIMS_AS_BUTTONS) +#if defined(USE_HATS_AS_KEYS) value -= step; #else value += step; @@ -87,7 +87,7 @@ void NumberEdit::onEvent(event_t event) auto step = getStep(); step += (rotaryEncoderGetAccel() * getAccelFactor()) / 8; do { -#if defined(USE_TRIMS_AS_BUTTONS) +#if defined(USE_HATS_AS_KEYS) value += step; #else value -= step; diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 4bf96010762..e9fb0146683 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -539,11 +539,11 @@ const char STR_CHANNELS_MONITOR[] = TR_CHANNELS_MONITOR; const char STR_ROTARY_ENCODER[] = TR_ROTARY_ENCODER; const char STR_ROTARY_ENC_MODE[] = TR_ROTARY_ENC_MODE; -#if defined(USE_TRIMS_AS_BUTTONS) -const char STR_HATS_MODE[] = TR_HATS_MODE; -ISTR(HATS_OPT); -const char STR_HATS_MODE_TRIMS[] = TR_HATS_MODE_TRIMS; -const char STR_HATS_MODE_BUTTONS[] = TR_HATS_MODE_BUTTONS; +#if defined(USE_HATS_AS_KEYS) +const char STR_HATSMODE[] = TR_HATSMODE; +ISTR(HATSOPT); +const char STR_HATSMODE_TRIMS[] = TR_HATSMODE_TRIMS; +const char STR_HATSMODE_KEYS[] = TR_HATSMODE_KEYS; #endif const char STR_MIXERS_MONITOR[] = TR_MIXERS_MONITOR; diff --git a/radio/src/translations.h b/radio/src/translations.h index f70aad8d0b2..454400781f5 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -174,11 +174,11 @@ extern const char* const STR_CYC_VSRCRAW[]; extern const char* const STR_ROTARY_ENC_OPT[]; -#if defined(USE_TRIMS_AS_BUTTONS) -extern const char STR_HATS_MODE[]; -extern const char* const STR_HATS_OPT[]; -extern const char STR_HATS_MODE_TRIMS[]; -extern const char STR_HATS_MODE_BUTTONS[]; +#if defined(USE_HATS_AS_KEYS) +extern const char STR_HATSMODE[]; +extern const char* const STR_HATSOPT[]; +extern const char STR_HATSMODE_TRIMS[]; +extern const char STR_HATSMODE_KEYS[]; #endif extern const char* const STR_VTMRMODES[]; diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index 5157744d200..b495e629a54 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -152,11 +152,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index dab6a21e81b..deeb77b1246 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -164,11 +164,11 @@ #define TR_ON_ONE_SWITCHES "ZAP","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 104e4121200..aff6220925e 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -160,11 +160,11 @@ #define TR_ON_ONE_SWITCHES "EN","En" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index 8b3eba4a5a7..0ef501f01c1 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -154,11 +154,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index d599628319f..1ba038ed588 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -157,11 +157,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/es.h b/radio/src/translations/es.h index ef22cd7a00d..2471f5ec35a 100644 --- a/radio/src/translations/es.h +++ b/radio/src/translations/es.h @@ -152,11 +152,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/fi.h b/radio/src/translations/fi.h index 6c9ccedcccc..54a36eb5572 100644 --- a/radio/src/translations/fi.h +++ b/radio/src/translations/fi.h @@ -163,11 +163,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 85c74aa0f68..5683947299e 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -164,11 +164,11 @@ #define TR_ON_ONE_SWITCHES "ON","Un" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/he.h b/radio/src/translations/he.h index 994f9d109f4..844a70f51d6 100644 --- a/radio/src/translations/he.h +++ b/radio/src/translations/he.h @@ -241,11 +241,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index 6fee55353f2..2b84503ee30 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -157,11 +157,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index 50414737428..cda0293f069 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -157,11 +157,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/nl.h b/radio/src/translations/nl.h index 3d826e98ae7..bcce3d82d71 100644 --- a/radio/src/translations/nl.h +++ b/radio/src/translations/nl.h @@ -154,11 +154,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index b821ca5c328..3fd2aa8b7c1 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -152,11 +152,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/pt.h b/radio/src/translations/pt.h index abd0f984988..102840c6493 100644 --- a/radio/src/translations/pt.h +++ b/radio/src/translations/pt.h @@ -160,11 +160,11 @@ #define TR_ON_ONE_SWITCHES "LIG","UM" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index 6eccbdcc8eb..b51fd2f0969 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -175,11 +175,11 @@ #define TR_ON_ONE_SWITCHES "PÅ","Ett" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(IMU) diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index f65020482ab..9afa9c84dc2 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -157,11 +157,11 @@ #define TR_ON_ONE_SWITCHES "ON","One" -#if defined(USE_TRIMS_AS_BUTTONS) -#define TR_HATS_MODE "Hats mode" -#define TR_HATS_OPT "Trims only","Keys only","Switchable","Global" -#define TR_HATS_MODE_TRIMS "Hats mode: Trims" -#define TR_HATS_MODE_BUTTONS "Hats mode: Keys" +#if defined(USE_HATS_AS_KEYS) +#define TR_HATSMODE "Hats mode" +#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" +#define TR_HATSMODE_TRIMS "Hats mode: Trims" +#define TR_HATSMODE_KEYS "Hats mode: Keys" #endif #if defined(COLORLCD) From d42e9241c9b7f2c692c1d03b95db4010a951f531 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sun, 6 Aug 2023 15:28:34 +0200 Subject: [PATCH 21/34] hats mode default settings: - radio settings: Trims only - model settings: Global --- companion/src/firmwares/modeldata.cpp | 2 ++ radio/src/model_init.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/companion/src/firmwares/modeldata.cpp b/companion/src/firmwares/modeldata.cpp index 669ce84ea0a..b8a7ee96b94 100644 --- a/companion/src/firmwares/modeldata.cpp +++ b/companion/src/firmwares/modeldata.cpp @@ -181,6 +181,8 @@ void ModelData::clear() const char * layoutId = "Layout2P1"; // currently all using same default though might change for NV14 RadioLayout::init(layoutId, customScreens); + + hatsMode = GeneralSettings::HATSMODE_GLOBAL; } bool ModelData::isEmpty() const diff --git a/radio/src/model_init.cpp b/radio/src/model_init.cpp index 4eebb733009..f13a9337562 100644 --- a/radio/src/model_init.cpp +++ b/radio/src/model_init.cpp @@ -132,8 +132,11 @@ void applyDefaultTemplate() g_model.switchWarningState |= (1 << (3 * i)); } #endif + + g_model.hatsMode = HATSMODE_GLOBAL; } + void setModelDefaults(uint8_t id) { memset(&g_model, 0, sizeof(g_model)); @@ -147,7 +150,7 @@ void setModelDefaults(uint8_t id) #endif strAppendUnsigned(strAppend(g_model.header.name, STR_MODEL), id, 2); -#if defined(LUA) && defined(PCBTARANIS) +#if defined(LUA) && defined(PCBTARANIS) // Horus uses menuModelWizard() for wizard if (isFileAvailable(WIZARD_PATH "/" WIZARD_NAME)) { f_chdir(WIZARD_PATH); luaExec(WIZARD_NAME); From 3fa5cae9d8ed24b43c0f2a7c66213d62b527adcb Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Mon, 7 Aug 2023 11:01:51 +0200 Subject: [PATCH 22/34] default hatsMode on radio.yml/modelxx.yml creation: - radio: Switchable (power on default in hats mode Switchable is always Trims) - model: Global --- companion/src/firmwares/generalsettings.cpp | 2 ++ radio/src/opentx.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index 710e5079771..60826f1e00f 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -129,6 +129,8 @@ void GeneralSettings::init() backlightDelay = 2; // 2 * 5 = 10 secs inactivityTimer = 10; + hatsMode = HATSMODE_SWITCHABLE; + // backlightBright = 0; // 0 = 100% if (IS_FAMILY_HORUS_OR_T16(board)) { diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 725b328fee6..ceefc052f77 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -356,6 +356,8 @@ void generalDefault() // disable Custom Script g_eeGeneral.modelCustomScriptsDisabled = true; + g_eeGeneral.hatsMode = HATSMODE_SWITCHABLE; + g_eeGeneral.chkSum = 0xFFFF; } From 1ac2bbd2cae1f3350f8405c8257626c64e0d7580 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Sun, 13 Aug 2023 15:53:25 +0200 Subject: [PATCH 23/34] radio and cpn: update translations PL, SE, JP, IT, HE, FR, DE, DA , CZ, TW, CN --- companion/src/translations/companion_cs.ts | 13 +++++++++---- companion/src/translations/companion_de.ts | 13 +++++++++---- companion/src/translations/companion_fr.ts | 13 +++++++++---- companion/src/translations/companion_he.ts | 13 +++++++++---- companion/src/translations/companion_it.ts | 13 +++++++++---- companion/src/translations/companion_ja.ts | 13 +++++++++---- companion/src/translations/companion_pl.ts | 13 +++++++++---- companion/src/translations/companion_sv.ts | 13 +++++++++---- companion/src/translations/companion_zh_CN.ts | 13 +++++++++---- companion/src/translations/companion_zh_TW.ts | 13 +++++++++---- radio/src/translations/cn.h | 8 ++++---- radio/src/translations/cz.h | 8 ++++---- radio/src/translations/da.h | 8 ++++---- radio/src/translations/de.h | 8 ++++---- radio/src/translations/fr.h | 8 ++++---- radio/src/translations/he.h | 8 ++++---- radio/src/translations/it.h | 8 ++++---- radio/src/translations/jp.h | 8 ++++---- radio/src/translations/pl.h | 8 ++++---- radio/src/translations/se.h | 8 ++++---- radio/src/translations/tw.h | 8 ++++---- 21 files changed, 134 insertions(+), 84 deletions(-) diff --git a/companion/src/translations/companion_cs.ts b/companion/src/translations/companion_cs.ts index 244599552ec..0440a8cb91b 100644 --- a/companion/src/translations/companion_cs.ts +++ b/companion/src/translations/companion_cs.ts @@ -5619,22 +5619,27 @@ Použitelné hodnoty jsou 5v..10v {3v?} {12v?} Hats Mode - + Režim kloboučků Trims only - + Pouze trimy Keys only - + Pouze tlačítka Switchable - + Přepinatelné + + + + Global + Globální diff --git a/companion/src/translations/companion_de.ts b/companion/src/translations/companion_de.ts index 04b6cae1438..ef4b5e161b9 100644 --- a/companion/src/translations/companion_de.ts +++ b/companion/src/translations/companion_de.ts @@ -5594,22 +5594,27 @@ Werte liegen zwischen 5-10V {3v?} {12v?} Hats Mode - + Joystick Modus Trims only - + Nur Trimmung Keys only - + Nur Tasten Switchable - + Umschaltbar + + + + Global + Global diff --git a/companion/src/translations/companion_fr.ts b/companion/src/translations/companion_fr.ts index 734d37203bc..62da574e774 100644 --- a/companion/src/translations/companion_fr.ts +++ b/companion/src/translations/companion_fr.ts @@ -5646,22 +5646,27 @@ Plage de valeurs: 3v...12v Hats Mode - + Mode chapeaux Trims only - + Trims uniquement Keys only - + Touches uniquement Switchable - + Permutable + + + + Global + Global diff --git a/companion/src/translations/companion_he.ts b/companion/src/translations/companion_he.ts index a7867c987ae..e2fc6a2c86f 100644 --- a/companion/src/translations/companion_he.ts +++ b/companion/src/translations/companion_he.ts @@ -5813,22 +5813,27 @@ p, li { white-space: pre-wrap; } Hats Mode - + מצב כובעונים Trims only - + קיזוזים בלבד Keys only - + ניווט בלבד Switchable - + משולב + + + + Global + גלובאלי diff --git a/companion/src/translations/companion_it.ts b/companion/src/translations/companion_it.ts index 8319b035c00..2177b8a2326 100644 --- a/companion/src/translations/companion_it.ts +++ b/companion/src/translations/companion_it.ts @@ -5612,22 +5612,27 @@ Mode 4: Hats Mode - + Modo joystick Trims only - + Solo trims Keys only - + Solo keys Switchable - + Commutabile + + + + Global + Globale diff --git a/companion/src/translations/companion_ja.ts b/companion/src/translations/companion_ja.ts index 2e0bfca3303..7d87f319e88 100644 --- a/companion/src/translations/companion_ja.ts +++ b/companion/src/translations/companion_ja.ts @@ -5975,22 +5975,27 @@ Mode 4: Hats Mode - + アナログスティック Trims only - + トリムのみ Keys only - + キーのみ Switchable - + スイッチ + + + + Global + すべて
diff --git a/companion/src/translations/companion_pl.ts b/companion/src/translations/companion_pl.ts index 131b07a0f95..5c41ce9feb3 100644 --- a/companion/src/translations/companion_pl.ts +++ b/companion/src/translations/companion_pl.ts @@ -5947,22 +5947,27 @@ Dopuszczalne wartości 5v-10v {3v?} {12v?} Hats Mode - + Tryb grzybków Trims only - + Tylko trymy Keys only - + Tylko przyciski Switchable - + Przełączane + + + + Global + Globalne diff --git a/companion/src/translations/companion_sv.ts b/companion/src/translations/companion_sv.ts index a03999893b5..588d1795633 100644 --- a/companion/src/translations/companion_sv.ts +++ b/companion/src/translations/companion_sv.ts @@ -6023,22 +6023,27 @@ Mode 4: Hats Mode - + Hattläge Trims only - + Endast trimm Keys only - + Endast knapp Switchable - + Ändringsbar + + + + Global + Global Owner Registration ID diff --git a/companion/src/translations/companion_zh_CN.ts b/companion/src/translations/companion_zh_CN.ts index 2dadc596bb1..1573e112eb3 100644 --- a/companion/src/translations/companion_zh_CN.ts +++ b/companion/src/translations/companion_zh_CN.ts @@ -5702,22 +5702,27 @@ Acceptable values are 3v..12v Hats Mode - + 按键帽模式 Trims only - + 微调 Keys only - + 导航键 Switchable - + 可切换 + + + + Global + 全局 diff --git a/companion/src/translations/companion_zh_TW.ts b/companion/src/translations/companion_zh_TW.ts index 69470459b85..470c98905df 100644 --- a/companion/src/translations/companion_zh_TW.ts +++ b/companion/src/translations/companion_zh_TW.ts @@ -5701,22 +5701,27 @@ Acceptable values are 3v..12v Hats Mode - + 按鍵帽模式 Trims only - + 微調 Keys only - + 導航鍵 Switchable - + 可切換 + + + + Global + 全局 diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index b495e629a54..f8b8f4b6f85 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -153,10 +153,10 @@ #define TR_ON_ONE_SWITCHES "ON","One" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "按键帽模式" +#define TR_HATSOPT "微调","导航键","可切换","全局" +#define TR_HATSMODE_TRIMS "按键帽: 微调" +#define TR_HATSMODE_KEYS "按键帽: 导航键" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index deeb77b1246..41b3a47a913 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -165,10 +165,10 @@ #define TR_ON_ONE_SWITCHES "ZAP","One" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "Režim kloboučků" +#define TR_HATSOPT "Pouze trimy","Pouze tlačítka","Přepinatelné","Globální" +#define TR_HATSMODE_TRIMS "Režim kloboučků: Trimy" +#define TR_HATSMODE_KEYS "Režim kloboučků: Tlačítka" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index aff6220925e..d43a5457904 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -161,10 +161,10 @@ #define TR_ON_ONE_SWITCHES "EN","En" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "Joystik indstilling" +#define TR_HATSOPT "Kun trim","Kun knap","Trim / Knap", "Global" +#define TR_HATSMODE_TRIMS "Joystik: Trim" +#define TR_HATSMODE_KEYS "Joystik: Knap" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index 0ef501f01c1..05bf935107b 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -155,10 +155,10 @@ #define TR_ON_ONE_SWITCHES "ON","One" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "Joystick Modus" +#define TR_HATSOPT "Nur Trimmung","Nur Tasten","Umschaltbar","Global" +#define TR_HATSMODE_TRIMS "Joystick Modus: Trimmung" +#define TR_HATSMODE_KEYS "Joystick Modus: Tasten" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 5683947299e..00af1b44566 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -165,10 +165,10 @@ #define TR_ON_ONE_SWITCHES "ON","Un" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "Mode chapeaux" +#define TR_HATSOPT "Trims uniquement","Touches uniquement","Permutable","Global" +#define TR_HATSMODE_TRIMS "Mode chapeaux: Trims" +#define TR_HATSMODE_KEYS "Mode chapeaux: Touches" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/he.h b/radio/src/translations/he.h index 844a70f51d6..d445a8bb358 100644 --- a/radio/src/translations/he.h +++ b/radio/src/translations/he.h @@ -242,10 +242,10 @@ #define TR_ON_ONE_SWITCHES "ON","One" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "מצב כובעונים" +#define TR_HATSOPT "קיזוזים בלבד","ניווט בלבד","משולב","גלובאלי" +#define TR_HATSMODE_TRIMS "מצב כובעונים: קיזוזים" +#define TR_HATSMODE_KEYS "מצב כובעונים: ניווט" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index 2b84503ee30..69260df17a4 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -158,10 +158,10 @@ #define TR_ON_ONE_SWITCHES "ON","One" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "Modo joystick" +#define TR_HATSOPT "Solo trims","Solo keys","Commutabile","Globale" +#define TR_HATSMODE_TRIMS "Modo joystick: trims" +#define TR_HATSMODE_KEYS "Modo joystick: keys" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index cda0293f069..80dfbf0a5a9 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -158,10 +158,10 @@ #define TR_ON_ONE_SWITCHES "ON","One" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "アナログスティック" +#define TR_HATSOPT "トリムのみ","キーのみ","スイッチ","すべて" +#define TR_HATSMODE_TRIMS "アナログスティック: トリム" +#define TR_HATSMODE_KEYS "アナログスティック: キー" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index 3fd2aa8b7c1..067937842ae 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -153,10 +153,10 @@ #define TR_ON_ONE_SWITCHES "ON","One" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "Tryb grzybków" +#define TR_HATSOPT "Tylko trymy","Tylko przyciski","Przełączane","Globalne" +#define TR_HATSMODE_TRIMS "Tryb grzybków: trymy" +#define TR_HATSMODE_KEYS "Tryb grzybków: przyciski" #endif #if defined(COLORLCD) diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index b51fd2f0969..337b921a6c1 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -176,10 +176,10 @@ #define TR_ON_ONE_SWITCHES "PÅ","Ett" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "Hattläge" +#define TR_HATSOPT "Endast trimm","Endast knapp","Ändringsbar","Global" +#define TR_HATSMODE_TRIMS "Hattläge: Trimmar" +#define TR_HATSMODE_KEYS "Hattläge: Knappar" #endif #if defined(IMU) diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index 9afa9c84dc2..979f2176d8d 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -158,10 +158,10 @@ #define TR_ON_ONE_SWITCHES "ON","One" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Hats mode" -#define TR_HATSOPT "Trims only","Keys only","Switchable","Global" -#define TR_HATSMODE_TRIMS "Hats mode: Trims" -#define TR_HATSMODE_KEYS "Hats mode: Keys" +#define TR_HATSMODE "按鍵帽模式" +#define TR_HATSOPT "微調","導航鍵","可切換","全局" +#define TR_HATSMODE_TRIMS "按鍵帽: 微調" +#define TR_HATSMODE_KEYS "按鍵帽: 導航鍵" #endif #if defined(COLORLCD) From cdb9ca35fce727b5f205d564190b6aab92c2cf49 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Tue, 15 Aug 2023 10:23:24 +0200 Subject: [PATCH 24/34] updated FR language translations --- companion/src/translations/companion_fr.ts | 4 ++-- radio/src/translations/fr.h | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/companion/src/translations/companion_fr.ts b/companion/src/translations/companion_fr.ts index 62da574e774..40295c4de4a 100644 --- a/companion/src/translations/companion_fr.ts +++ b/companion/src/translations/companion_fr.ts @@ -5646,7 +5646,7 @@ Plage de valeurs: 3v...12v Hats Mode - Mode chapeaux + Mode joystick @@ -5661,7 +5661,7 @@ Plage de valeurs: 3v...12v Switchable - Permutable + Commutable diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 00af1b44566..1a410611ac1 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -165,10 +165,11 @@ #define TR_ON_ONE_SWITCHES "ON","Un" #if defined(USE_HATS_AS_KEYS) -#define TR_HATSMODE "Mode chapeaux" -#define TR_HATSOPT "Trims uniquement","Touches uniquement","Permutable","Global" -#define TR_HATSMODE_TRIMS "Mode chapeaux: Trims" -#define TR_HATSMODE_KEYS "Mode chapeaux: Touches" +#define TR_HATSMODE "Mode joystick" +#define TR_HATSOPT "Trims uniquement","Touches uniquement","Commutable","Global" +#define TR_HATSMODE_TRIMS "Mode joystick: trims" +#define TR_HATSMODE_KEYS "Mode joystick: touches" + #endif #if defined(COLORLCD) From 7d88b33010472ce33d969e89815e85e88e430c89 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Tue, 29 Aug 2023 22:01:02 +0200 Subject: [PATCH 25/34] fix rebase --- radio/src/gui/colorlcd/themes/etx_lv_theme.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp b/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp index 100eee3d7fd..4279c0fc3b0 100644 --- a/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp +++ b/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp @@ -611,12 +611,13 @@ void etx_checkbox_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_obj_add_style(obj, &styles.focussed, LV_PART_INDICATOR | LV_STATE_FOCUSED); lv_obj_add_style(obj, &styles.disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); } - void bubble_popup_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { lv_obj_add_style(obj, &styles.bubble_popup, 0); } +} + // Object classes const lv_obj_class_t input_mix_line_class = { From 5d168f5961bbe4795032326b8278cde9739c4e59 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 31 Aug 2023 11:19:44 +0200 Subject: [PATCH 26/34] fix rebase --- radio/src/storage/yaml/yaml_datastructs_nv14.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index e996b22370e..dd5efbb9608 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -388,6 +388,7 @@ static const struct YamlNode struct_RadioData[] = { YAML_STRUCT("themeData", 480, struct_EdgeTxTheme__PersistentData, NULL), YAML_STRING("ownerRegistrationID", 8), YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr), + YAML_UNSIGNED( "rotEncMode", 2 ), YAML_SIGNED( "uartSampleMode", 2 ), YAML_UNSIGNED( "stickDeadZone", 3 ), YAML_UNSIGNED( "audioMuteEnable", 1 ), From afd59a7bba961ec36ecbbe2a33e9cfe201471234 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 31 Aug 2023 13:32:27 +0200 Subject: [PATCH 27/34] fix rebase --- companion/src/generaledit/generalsetup.ui | 5 - companion/src/modeledit/setup.ui | 272 +++++++++++----------- 2 files changed, 136 insertions(+), 141 deletions(-) diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index 50bd6d4cf70..c151b300b2c 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -2521,11 +2521,6 @@ p, li { white-space: pre-wrap; } QLineEdit
timezoneedit.h
- - AutoComboBox - QComboBox -
autocombobox.h
-
diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui index 35aefb2d237..f828efdaa00 100644 --- a/companion/src/modeledit/setup.ui +++ b/companion/src/modeledit/setup.ui @@ -7,7 +7,7 @@ 0 0 1024 - 466 + 435 @@ -199,13 +199,6 @@ - - - - Hats Mode - - - @@ -470,83 +463,10 @@ 6 - - - - Qt::LeftToRight - - - Throttle Trim Idle Only - - - - - - - - 0 - 0 - - - - Edit Checklist... - - - - - - - Qt::LeftToRight - - - Custom Throttle Warning - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::LeftToRight - - - Extended Trims - - - - - - - Qt::LeftToRight - - - Throttle Warning - - - - - - - - 0 - 0 - - - + + - + @@ -581,33 +501,48 @@ - - - - Throttle trim switch + + + + + 0 + 0 + + + + Never + + + + + On change + + + + + Always + + - - - - - + + Qt::LeftToRight - Extended Limits + Throttle Warning - - + + Qt::LeftToRight - Display Checklist + Custom Throttle Warning @@ -627,48 +562,17 @@ - - - - Reverse throttle operation. -If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well. - - - + + Qt::LeftToRight - Reverse Throttle - - - - - - - - 0 - 0 - + Display Checklist - - - Never - - - - - On change - - - - - Always - - - + Global Functions @@ -685,7 +589,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - + @@ -698,7 +602,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - + @@ -723,9 +627,105 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - + + + + + + 0 + 0 + + + + Edit Checklist... + + + + + + + Qt::LeftToRight + + + Throttle Trim Idle Only + + + + + + + Reverse throttle operation. +If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well. + + + + + Qt::LeftToRight + + + Reverse Throttle + + + + + + + Throttle trim switch + + + + + + + Hats Mode + + + + + + + Qt::LeftToRight + + + Extended Trims + + + + + + + Qt::LeftToRight + + + Extended Limits + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -774,4 +774,4 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - + \ No newline at end of file From 60534a44f50d5ea9150cb19b923d8248842f5649 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 21 Sep 2023 12:53:36 +0200 Subject: [PATCH 28/34] fixed overlaying label and cb - courtesy @pfeerick --- companion/src/modeledit/setup.ui | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui index f828efdaa00..de0498958ab 100644 --- a/companion/src/modeledit/setup.ui +++ b/companion/src/modeledit/setup.ui @@ -184,7 +184,7 @@ - + 50 @@ -192,7 +192,7 @@ - + Hats Mode Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -675,13 +675,6 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi Throttle trim switch - - - - - Hats Mode - - @@ -774,4 +767,4 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - \ No newline at end of file + From b65edbc1dced03d45dd6a4575e3f62329b9abe8a Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 21 Sep 2023 13:30:55 +0200 Subject: [PATCH 29/34] empty commit From 0f2904e023344e9cbb4557e38e19a5ee6372be7b Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 21 Sep 2023 14:03:50 +0200 Subject: [PATCH 30/34] fix merge error --- radio/src/thirdparty/libopenui/src/window.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/window.h b/radio/src/thirdparty/libopenui/src/window.h index a21d5550b54..241d76584eb 100644 --- a/radio/src/thirdparty/libopenui/src/window.h +++ b/radio/src/thirdparty/libopenui/src/window.h @@ -203,8 +203,7 @@ class Window virtual bool isTopBar() { return false; } virtual bool isWidgetsContainer() { return false; } - virtual bool isBubblePopup() { return false; } - + virtual bool isBubblePopup() { return false; } protected: From a813da7b1d1713b6d5ef72eb2ebc1a040a395ba3 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 21 Sep 2023 14:12:31 +0200 Subject: [PATCH 31/34] weird stuff after merge --- radio/src/lua/interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index 615c74224cf..33aabea37c1 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -79,7 +79,7 @@ struct our_longjmp * global_lj = 0; uint32_t luaExtraMemoryUsage = 0; #endif -#if defined(USE_TRIMS_AS_BUTTONS) +#if defined(USE_HATS_AS_KEYS) static bool _is_standalone_script() { return scriptInternalData[0].reference == SCRIPT_STANDALONE; From b8c956a69934766f5aeb96e0e20072f1ce4b0ef8 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sun, 24 Sep 2023 13:36:35 +1000 Subject: [PATCH 32/34] chore: Remove unnecessary edits, formatting --- companion/src/firmwares/generalsettings.h | 1 - companion/src/translations/companion_zh_CN.ts | 1 - radio/src/datastructs_private.h | 1 - radio/src/gui/colorlcd/popups.cpp | 2 +- radio/src/gui/colorlcd/popups.h | 2 +- .../src/gui/colorlcd/themes/etx_lv_theme.cpp | 6 +- radio/src/keys.cpp | 90 ++++++++++--------- radio/src/lua/api_general.cpp | 4 +- radio/src/main.cpp | 17 ++-- radio/src/model_init.cpp | 3 +- .../thirdparty/libopenui/src/mainwindow.cpp | 2 +- .../libopenui/src/widgets/etx_obj_create.h | 2 +- radio/src/thirdparty/libopenui/src/window.h | 4 +- radio/src/translations/fr.h | 1 - 14 files changed, 66 insertions(+), 70 deletions(-) diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index db43ee0b21b..794067ebd0c 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -43,7 +43,6 @@ constexpr char AIM_GS_INTMODULEBAUDRATE[] {"gs.intmodulebaudrate"}; constexpr char AIM_GS_STICKDEADZONE[] {"gs.stickdeadzone"}; constexpr char AIM_GS_UARTSAMPLEMODE[] {"gs.uartsamplemode"}; constexpr char AIM_GS_HATSMODE[] {"gs.hatsmode"}; - constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"}; constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"}; diff --git a/companion/src/translations/companion_zh_CN.ts b/companion/src/translations/companion_zh_CN.ts index beebfd11f03..ff1ec6c1554 100644 --- a/companion/src/translations/companion_zh_CN.ts +++ b/companion/src/translations/companion_zh_CN.ts @@ -5682,7 +5682,6 @@ Acceptable values are 3v..12v Power Off Delay
- diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index 8b0ebb17323..b10efab5afe 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -929,7 +929,6 @@ PACK(struct RadioData { char ownerRegistrationID[PXX2_LEN_REGISTRATION_ID]; CUST_ATTR(rotEncDirection, r_rotEncDirection, nullptr); - NOBACKUP(uint8_t rotEncMode:2); NOBACKUP(int8_t uartSampleMode:2); // See UartSampleModes diff --git a/radio/src/gui/colorlcd/popups.cpp b/radio/src/gui/colorlcd/popups.cpp index 2ebfdf820a6..3a35b8c0783 100644 --- a/radio/src/gui/colorlcd/popups.cpp +++ b/radio/src/gui/colorlcd/popups.cpp @@ -146,4 +146,4 @@ class BubbleDialog : public Window void POPUP_BUBBLE(const char* message, uint32_t timeout) { new BubbleDialog(message, timeout); -} \ No newline at end of file +} diff --git a/radio/src/gui/colorlcd/popups.h b/radio/src/gui/colorlcd/popups.h index 8e2254ab854..028a67018ad 100644 --- a/radio/src/gui/colorlcd/popups.h +++ b/radio/src/gui/colorlcd/popups.h @@ -30,4 +30,4 @@ void POPUP_WARNING(const char * message, const char * info = nullptr); void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info = nullptr, bool waitForClose = true); void POPUP_BUBBLE(const char * message, uint32_t timeout); -void show_ui_popup(); \ No newline at end of file +void show_ui_popup(); diff --git a/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp b/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp index 4279c0fc3b0..99bff6ba2a6 100644 --- a/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp +++ b/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp @@ -611,6 +611,7 @@ void etx_checkbox_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_obj_add_style(obj, &styles.focussed, LV_PART_INDICATOR | LV_STATE_FOCUSED); lv_obj_add_style(obj, &styles.disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); } + void bubble_popup_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { lv_obj_add_style(obj, &styles.bubble_popup, 0); @@ -618,7 +619,6 @@ void bubble_popup_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) } - // Object classes const lv_obj_class_t input_mix_line_class = { .base_class = &lv_btn_class, @@ -815,7 +815,6 @@ const lv_obj_class_t etx_checkbox_class = { .instance_size = sizeof(lv_checkbox_t), }; - const lv_obj_class_t etx_bubble_popup_class = { .base_class = &window_base_class, .constructor_cb = bubble_popup_constructor, @@ -829,7 +828,6 @@ const lv_obj_class_t etx_bubble_popup_class = { .instance_size = sizeof(lv_obj_t) }; - // Event handlers static void field_edit_event(const lv_obj_class_t* class_p, lv_event_t* e) { @@ -987,4 +985,4 @@ lv_obj_t* etx_modal_title_create(lv_obj_t* parent) lv_obj_add_style(obj, &styles.modal_title, 0); return obj; -} \ No newline at end of file +} diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index 9c12aa10cb7..f169a8b23ac 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -294,7 +294,7 @@ uint8_t keysGetTrimState(uint8_t trim) } #if defined(USE_HATS_AS_KEYS) -#define ROTARY_EMU_KEY_REPEAT_RATE 12 // times 10 [ms] +#define ROTARY_EMU_KEY_REPEAT_RATE 12 // times 10 [ms] static bool _trims_as_buttons = false; static bool _trims_as_buttons_LUA = false; @@ -305,29 +305,29 @@ bool getHatsAsKeys() { return _trims_as_buttons; } void setTransposeHatsForLUA(bool val) { _trims_as_buttons_LUA = val; } bool getTransposeHatsForLUA() { return _trims_as_buttons_LUA; } -int16_t getEmuRotaryData() { +int16_t getEmuRotaryData() +{ static bool rotaryTrimPressed = false; static tmr10ms_t timePressed = 0; - if(getHatsAsKeys() || getTransposeHatsForLUA()) { + if (getHatsAsKeys() || getTransposeHatsForLUA()) { tmr10ms_t now = get_tmr10ms(); - if(rotaryTrimPressed) { - if(now < (timePressed + ROTARY_EMU_KEY_REPEAT_RATE)) - return 0; + if (rotaryTrimPressed) { + if (now < (timePressed + ROTARY_EMU_KEY_REPEAT_RATE)) return 0; rotaryTrimPressed = false; } auto trims = readTrims(); - if(trims & (1 << 4)) { + if (trims & (1 << 4)) { rotaryTrimPressed = true; timePressed = now; - return 1; + return 1; } - if(trims & (1 << 5)) { + if (trims & (1 << 5)) { rotaryTrimPressed = true; timePressed = now; return -1; @@ -342,67 +342,69 @@ static void transpose_trims(uint32_t *keys) #if defined(BOOT) auto trims = readTrims(); - if (trims & (1 << 4)) *keys |= 1 << KEY_DOWN; // right hat, down 0x10 - if (trims & (1 << 5)) *keys |= 1 << KEY_UP; // right hat, up 0x20 + if (trims & (1 << 4)) *keys |= 1 << KEY_DOWN; // right hat, down 0x10 + if (trims & (1 << 5)) *keys |= 1 << KEY_UP; // right hat, up 0x20 #else static uint8_t state = 0; - bool allowModeSwitch = - ((g_model.hatsMode == HATSMODE_GLOBAL && g_eeGeneral.hatsMode == HATSMODE_SWITCHABLE) || - (g_model.hatsMode == HATSMODE_SWITCHABLE)) && - !getTransposeHatsForLUA(); + bool allowModeSwitch = ((g_model.hatsMode == HATSMODE_GLOBAL && + g_eeGeneral.hatsMode == HATSMODE_SWITCHABLE) || + (g_model.hatsMode == HATSMODE_SWITCHABLE)) && + !getTransposeHatsForLUA(); - if(allowModeSwitch) { - static bool lastExitState = false; + if (allowModeSwitch) { + static bool lastExitState = false; static bool lastEnterState = false; - bool exitState = *keys & (1 << KEY_EXIT); // edge detection for EXIT and ENTER keys + bool exitState = + *keys & (1 << KEY_EXIT); // edge detection for EXIT and ENTER keys bool enterState = *keys & (1 << KEY_ENTER); - bool exitPressed = !lastExitState && exitState; - bool exitReleased = lastExitState && !exitState; + bool exitPressed = !lastExitState && exitState; + bool exitReleased = lastExitState && !exitState; bool enterPressed = !lastEnterState && enterState; - lastExitState = exitState; + lastExitState = exitState; lastEnterState = enterState; - switch(state) { - case 0: // idle state waiting for EXIT or ENTER key - if(exitPressed) { + switch (state) { + case 0: // idle state waiting for EXIT or ENTER key + if (exitPressed) { state = 1; } break; - - case 1: // state EXIT received - if(exitReleased) { // if exit released go back to idle state + + case 1: // state EXIT received + if (exitReleased) { // if exit released go back to idle state state = 0; break; } - - if(enterPressed) { // ENTER received with EXIT still pressed - setHatsAsKeys(!getHatsAsKeys()); // change mode and don't forward EXIT and ENTER keys + + if (enterPressed) { // ENTER received with EXIT still pressed + setHatsAsKeys(!getHatsAsKeys()); // change mode and don't forward + // EXIT and ENTER keys killEvents(KEY_EXIT); killEvents(KEY_ENTER); - state = 0; // go to for EXIT to be released + state = 0; // go to for EXIT to be released break; } break; } } else - state = 0; // state machine in idle if not in mode "BOTH" + state = 0; // state machine in idle if not in mode "BOTH" - if(getHatsAsKeys() || // map hats to keys in button mode or LUA active - getTransposeHatsForLUA()) { + if (getHatsAsKeys() || // map hats to keys in button mode or LUA active + getTransposeHatsForLUA()) { auto trims = readTrims(); - - // spare key in buttons mode: left hat left - //if (trims & (1 << 0)) *keys |= 1 << tbd; // left hat, left 0x01 - if (trims & (1 << 1)) *keys |= 1 << KEY_MODEL; // left hat, right 0x02 - if (trims & (1 << 2)) *keys |= 1 << KEY_TELE; // left hat, down 0x04 - if (trims & (1 << 3)) *keys |= 1 << KEY_SYS; // left hat, up 0x08 - - if (trims & (1 << 6)) *keys |= 1 << KEY_PAGEUP; // rht, left 0x40 - if (trims & (1 << 7)) *keys |= 1 << KEY_PAGEDN; // rht, right 0x80 + + // spare key in buttons mode: left hat left + // if (trims & (1 << 0)) *keys |= 1 << tbd; // left hat, left 0x01 + if (trims & (1 << 1)) *keys |= 1 << KEY_MODEL; // left hat, right 0x02 + if (trims & (1 << 2)) *keys |= 1 << KEY_TELE; // left hat, down 0x04 + if (trims & (1 << 3)) *keys |= 1 << KEY_SYS; // left hat, up 0x08 + + if (trims & (1 << 6)) *keys |= 1 << KEY_PAGEUP; // rht, left 0x40 + if (trims & (1 << 7)) *keys |= 1 << KEY_PAGEDN; // rht, right 0x80 } #endif @@ -416,7 +418,7 @@ bool keysPollingCycle() #if defined(USE_HATS_AS_KEYS) transpose_trims(&keys_input); - + if (getHatsAsKeys() || getTransposeHatsForLUA()) { trims_input = 0; } else { diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 082f7bd6145..f6d9b9560d6 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -3094,10 +3094,10 @@ LROT_BEGIN(etxcst, NULL, 0) LROT_NUMENTRY( EVT_VIRTUAL_PREV_PAGE, EVT_KEY_BREAK(KEY_PAGEUP) ) LROT_NUMENTRY( EVT_VIRTUAL_NEXT_PAGE, EVT_KEY_BREAK(KEY_PAGEDN) ) #else - LROT_NUMENTRY( EVT_VIRTUAL_PREV_PAGE, EVT_KEY_LONG(KEY_PAGEDN) ) // do colorLCD radios with only PAGEDN HW key exist? + LROT_NUMENTRY( EVT_VIRTUAL_PREV_PAGE, EVT_KEY_LONG(KEY_PAGEDN) ) LROT_NUMENTRY( EVT_VIRTUAL_NEXT_PAGE, EVT_KEY_BREAK(KEY_PAGEDN) ) #endif - LROT_NUMENTRY( EVT_VIRTUAL_MENU, EVT_KEY_BREAK(KEY_MODEL) ) + LROT_NUMENTRY( EVT_VIRTUAL_MENU, EVT_KEY_BREAK(KEY_MODEL) ) LROT_NUMENTRY( EVT_VIRTUAL_MENU_LONG, EVT_KEY_LONG(KEY_MODEL) ) LROT_NUMENTRY( EVT_VIRTUAL_ENTER, EVT_KEY_BREAK(KEY_ENTER) ) LROT_NUMENTRY( EVT_VIRTUAL_ENTER_LONG, EVT_KEY_LONG(KEY_ENTER) ) diff --git a/radio/src/main.cpp b/radio/src/main.cpp index ae0b631d5a0..2171cbd649f 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -268,24 +268,25 @@ void checkSpeakerVolume() } #if defined(USE_HATS_AS_KEYS) -void checkHatsAsKeys() { - uint8_t hatsMode = g_model.hatsMode == HATSMODE_GLOBAL ? g_eeGeneral.hatsMode : g_model.hatsMode; +void checkHatsAsKeys() +{ + uint8_t hatsMode = g_model.hatsMode == HATSMODE_GLOBAL ? g_eeGeneral.hatsMode + : g_model.hatsMode; static bool oldHatsModeKeys = hatsMode == HATSMODE_KEYS_ONLY; - if(hatsMode == HATSMODE_TRIMS_ONLY) { + if (hatsMode == HATSMODE_TRIMS_ONLY) { setHatsAsKeys(false); } - - if(hatsMode == HATSMODE_KEYS_ONLY) { + + if (hatsMode == HATSMODE_KEYS_ONLY) { setHatsAsKeys(true); } bool hatsModeKeys = getHatsAsKeys(); - if(hatsModeKeys == oldHatsModeKeys) - return; - + if (hatsModeKeys == oldHatsModeKeys) return; + oldHatsModeKeys = !oldHatsModeKeys; audioKeyPress(); diff --git a/radio/src/model_init.cpp b/radio/src/model_init.cpp index f13a9337562..757668e5e48 100644 --- a/radio/src/model_init.cpp +++ b/radio/src/model_init.cpp @@ -136,7 +136,6 @@ void applyDefaultTemplate() g_model.hatsMode = HATSMODE_GLOBAL; } - void setModelDefaults(uint8_t id) { memset(&g_model, 0, sizeof(g_model)); @@ -150,7 +149,7 @@ void setModelDefaults(uint8_t id) #endif strAppendUnsigned(strAppend(g_model.header.name, STR_MODEL), id, 2); -#if defined(LUA) && defined(PCBTARANIS) // Horus uses menuModelWizard() for wizard +#if defined(LUA) && defined(PCBTARANIS) if (isFileAvailable(WIZARD_PATH "/" WIZARD_NAME)) { f_chdir(WIZARD_PATH); luaExec(WIZARD_NAME); diff --git a/radio/src/thirdparty/libopenui/src/mainwindow.cpp b/radio/src/thirdparty/libopenui/src/mainwindow.cpp index b925b16986d..da340e14001 100644 --- a/radio/src/thirdparty/libopenui/src/mainwindow.cpp +++ b/radio/src/thirdparty/libopenui/src/mainwindow.cpp @@ -57,4 +57,4 @@ void MainWindow::run(bool trash) TRACE_WINDOWS("MainWindow::run took %dms", (ticksNow() - start) / SYSTEM_TICKS_1MS); } -} \ No newline at end of file +} diff --git a/radio/src/thirdparty/libopenui/src/widgets/etx_obj_create.h b/radio/src/thirdparty/libopenui/src/widgets/etx_obj_create.h index f8957f11df5..ba71c6a80bd 100644 --- a/radio/src/thirdparty/libopenui/src/widgets/etx_obj_create.h +++ b/radio/src/thirdparty/libopenui/src/widgets/etx_obj_create.h @@ -44,4 +44,4 @@ lv_obj_t* etx_checkbox_create(lv_obj_t* parent); lv_obj_t* etx_bubble_popup_create(lv_obj_t* parent); lv_obj_t* input_mix_line_create(lv_obj_t* parent); -lv_obj_t* input_mix_group_create(lv_obj_t* parent); \ No newline at end of file +lv_obj_t* input_mix_group_create(lv_obj_t* parent); diff --git a/radio/src/thirdparty/libopenui/src/window.h b/radio/src/thirdparty/libopenui/src/window.h index 241d76584eb..b3439bba9fb 100644 --- a/radio/src/thirdparty/libopenui/src/window.h +++ b/radio/src/thirdparty/libopenui/src/window.h @@ -203,7 +203,7 @@ class Window virtual bool isTopBar() { return false; } virtual bool isWidgetsContainer() { return false; } - + virtual bool isBubblePopup() { return false; } protected: @@ -230,4 +230,4 @@ class Window void removeChild(Window * window); virtual void invalidate(const rect_t & rect); -}; \ No newline at end of file +}; diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index fe3f75a89b9..6beffa1a2c2 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -170,7 +170,6 @@ #define TR_HATSOPT "Trims uniquement","Touches uniquement","Commutable","Global" #define TR_HATSMODE_TRIMS "Mode joystick: trims" #define TR_HATSMODE_KEYS "Mode joystick: touches" - #endif #if defined(COLORLCD) From cb105436c750da7047e7efcf769acb0f3e6adb90 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sun, 24 Sep 2023 13:38:52 +1000 Subject: [PATCH 33/34] chore: Run generate-yaml as someone clearly hasn't --- .../src/storage/yaml/yaml_datastructs_128x64.cpp | 13 +++++++++++-- radio/src/storage/yaml/yaml_datastructs_nv14.cpp | 16 ++++++++-------- radio/src/storage/yaml/yaml_datastructs_t20.cpp | 13 +++++++++++-- radio/src/storage/yaml/yaml_datastructs_tpro.cpp | 13 +++++++++++-- radio/src/storage/yaml/yaml_datastructs_x10.cpp | 13 +++++++++++-- radio/src/storage/yaml/yaml_datastructs_x12s.cpp | 13 +++++++++++-- radio/src/storage/yaml/yaml_datastructs_x9d.cpp | 13 +++++++++++-- radio/src/storage/yaml/yaml_datastructs_x9e.cpp | 13 +++++++++++-- .../src/storage/yaml/yaml_datastructs_x9lite.cpp | 13 +++++++++++-- .../src/storage/yaml/yaml_datastructs_xlites.cpp | 13 +++++++++++-- 10 files changed, 107 insertions(+), 26 deletions(-) diff --git a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp index 48660a06e04..b1a214daefd 100644 --- a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -267,7 +274,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 12, struct_CalibData, NULL), @@ -791,7 +799,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 6afaf11904a..20caa171ccb 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -5,13 +5,12 @@ // const struct YamlIdStr enum_HatsMode[] = { - { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, - { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, - { HATSMODE_SWITCHABLE, "SWITCHABLE" }, - { HATSMODE_GLOBAL, "GLOBAL" }, - { 0, NULL } + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } }; - const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -286,7 +285,7 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_ENUM( "hatsMode", 2, enum_HatsMode ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), @@ -823,7 +822,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_ENUM( "hatsMode", 2, enum_HatsMode ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), @@ -903,3 +902,4 @@ const YamlNode* get_partialmodel_nodes() { return &__PartialModel_root_node; } + diff --git a/radio/src/storage/yaml/yaml_datastructs_t20.cpp b/radio/src/storage/yaml/yaml_datastructs_t20.cpp index d62ea630724..dc4c3701427 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t20.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t20.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -267,7 +274,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 12, struct_CalibData, NULL), @@ -789,7 +797,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp index 1bbd825dcd6..21d19838917 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -267,7 +274,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 12, struct_CalibData, NULL), @@ -789,7 +797,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x10.cpp b/radio/src/storage/yaml/yaml_datastructs_x10.cpp index 25e150d391a..eeb89c5bf9f 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x10.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x10.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -286,7 +293,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 22, struct_CalibData, NULL), @@ -822,7 +830,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp index 25e150d391a..eeb89c5bf9f 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -286,7 +293,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 22, struct_CalibData, NULL), @@ -822,7 +830,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp index a7538158f29..4c144a6bbdd 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -267,7 +274,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 12, struct_CalibData, NULL), @@ -792,7 +800,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp index 1ec97e579f2..ba2ea2741f3 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -267,7 +274,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 12, struct_CalibData, NULL), @@ -792,7 +800,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp index b251c8042f1..8a15f0fb445 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -267,7 +274,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 12, struct_CalibData, NULL), @@ -789,7 +797,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp index feda9fec8c5..246d8f399b9 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp @@ -4,6 +4,13 @@ // Enums first // +const struct YamlIdStr enum_HatsMode[] = { + { HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" }, + { HATSMODE_KEYS_ONLY, "KEYS_ONLY" }, + { HATSMODE_SWITCHABLE, "SWITCHABLE" }, + { HATSMODE_GLOBAL, "GLOBAL" }, + { 0, NULL } +}; const struct YamlIdStr enum_BacklightMode[] = { { e_backlight_mode_off, "backlight_mode_off" }, { e_backlight_mode_keys, "backlight_mode_keys" }, @@ -269,7 +276,8 @@ static const struct YamlNode struct_CustomFunctionData[] = { static const struct YamlNode struct_RadioData[] = { YAML_UNSIGNED( "manuallyEdited", 1 ), YAML_SIGNED( "timezoneMinutes", 3 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_CUSTOM("semver",nullptr,w_semver), YAML_CUSTOM("board",nullptr,w_board), YAML_ARRAY("calib", 48, 12, struct_CalibData, NULL), @@ -795,7 +803,8 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "disableTelemetryWarning", 1 ), YAML_UNSIGNED( "showInstanceIds", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_PADDING( 4 ), + YAML_ENUM("hatsMode", 2, enum_HatsMode), + YAML_PADDING( 2 ), YAML_SIGNED( "customThrottleWarningPosition", 8 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), From 6493e3f200e212faf2678b3a2e5895d2f0b12758 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sun, 24 Sep 2023 14:08:56 +1000 Subject: [PATCH 34/34] chore: Also show hats status in model printer --- companion/src/modelprinter.cpp | 20 ++++++++++++++++++++ companion/src/modelprinter.h | 1 + 2 files changed, 21 insertions(+) diff --git a/companion/src/modelprinter.cpp b/companion/src/modelprinter.cpp index 64113fc95f2..5501340990f 100644 --- a/companion/src/modelprinter.cpp +++ b/companion/src/modelprinter.cpp @@ -840,6 +840,10 @@ QString ModelPrinter::printSettingsTrim() str << printLabelValue(tr("Step"), printTrimIncrementMode()); str << printLabelValue(tr("Display"), printTrimsDisplayMode()); str << printLabelValue(tr("Extended"), printBoolean(model.extendedTrims, BOOLEAN_YESNO)); + Board::Type board = firmware->getBoard(); + if (IS_FLYSKY_EL18(board) || IS_FLYSKY_NV14(board)) { + str << printLabelValue(tr("Hats Mode"), printHatsMode()); + } return str.join(" "); } @@ -869,6 +873,22 @@ QString ModelPrinter::printTrimsDisplayMode() } } +QString ModelPrinter::printHatsMode() +{ + switch (model.hatsMode) { + case GeneralSettings::HATSMODE_TRIMS_ONLY: + return tr("Trims only"); + case GeneralSettings::HATSMODE_KEYS_ONLY: + return tr("Keys only"); + case GeneralSettings::HATSMODE_SWITCHABLE: + return tr("Switchable"); + case GeneralSettings::HATSMODE_GLOBAL: + return tr("Global"); + default: + return CPN_STR_UNKNOWN_ITEM; + } +} + QString ModelPrinter::printModuleType(int idx) { return ModuleData::indexToString(idx, firmware); diff --git a/companion/src/modelprinter.h b/companion/src/modelprinter.h index e101d24b612..a9aae03bf67 100644 --- a/companion/src/modelprinter.h +++ b/companion/src/modelprinter.h @@ -79,6 +79,7 @@ class ModelPrinter: public QObject QString printModuleType(int idx); QString printThrottleSource(int idx); QString printTrimsDisplayMode(); + QString printHatsMode(); QString printSettingsTrim(); QString printSwitchWarnings(); QString printPotWarnings();