From 7b8f4d197782f54e15b855b385cb38bbae8e8796 Mon Sep 17 00:00:00 2001 From: Richard Li Date: Fri, 6 Oct 2023 16:38:47 +0800 Subject: [PATCH] Fixed rebase problems due to changes in PR #3894. --- radio/src/gui/colorlcd/radio_diagkeys.cpp | 4 ++-- radio/src/storage/yaml/yaml_datastructs_pl18.cpp | 13 +++++++++++-- radio/src/targets/pl18/CMakeLists.txt | 2 +- radio/src/targets/pl18/bootloader/boot_menu.cpp | 2 +- radio/src/targets/pl18/hal.h | 2 ++ radio/src/targets/pl18/key_driver.cpp | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/radio/src/gui/colorlcd/radio_diagkeys.cpp b/radio/src/gui/colorlcd/radio_diagkeys.cpp index de41b812f44..aa2a5d8b82a 100644 --- a/radio/src/gui/colorlcd/radio_diagkeys.cpp +++ b/radio/src/gui/colorlcd/radio_diagkeys.cpp @@ -96,7 +96,7 @@ class RadioKeyDiagsWindow : public Window dc->drawText(TRIM_MINUS_COLUMN, 1, "-", COLOR_THEME_PRIMARY1); dc->drawText(TRIM_PLUS_COLUMN, 1, "+", COLOR_THEME_PRIMARY1); -#if !defined(PCBNV14) +#if !(defined(PCBNV14) || defined(PCBPL18)) // KEYS coord_t y = 1; for (uint8_t i = 0; i < keysGetMaxKeys(); i++) { @@ -110,7 +110,7 @@ class RadioKeyDiagsWindow : public Window dc->drawText(KEY_COLUMN, y, STR_ROTARY_ENCODER, COLOR_THEME_PRIMARY1); dc->drawNumber(70, y, rotaryEncoderGetValue(), COLOR_THEME_PRIMARY1); #endif -#else // PCBNV14 does NOT have physical keys, only remapped trim keys +#else // PCBNV14 and PCBPL18 does NOT have physical keys, only remapped trim keys { coord_t y = 1; dc->drawText(KEY_COLUMN, y, keysGetLabel(KEY_ENTER), COLOR_THEME_PRIMARY1); diff --git a/radio/src/storage/yaml/yaml_datastructs_pl18.cpp b/radio/src/storage/yaml/yaml_datastructs_pl18.cpp index b330a845a9e..1bc5aa32205 100644 --- a/radio/src/storage/yaml/yaml_datastructs_pl18.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_pl18.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" }, @@ -284,7 +291,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), @@ -820,7 +828,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/targets/pl18/CMakeLists.txt b/radio/src/targets/pl18/CMakeLists.txt index 78b5806e436..9e53807485e 100644 --- a/radio/src/targets/pl18/CMakeLists.txt +++ b/radio/src/targets/pl18/CMakeLists.txt @@ -56,7 +56,7 @@ add_definitions( -DSTM32F429_439xx -DSTM32F429xx -DSDRAM -DCOLORLCD -DLIBOPENUI -DHARDWARE_TOUCH -DHARDWARE_KEYS - -DSOFTWARE_KEYBOARD -DUSE_TRIMS_AS_BUTTONS) + -DSOFTWARE_KEYBOARD -DUSE_HATS_AS_KEYS) set(SDRAM ON) diff --git a/radio/src/targets/pl18/bootloader/boot_menu.cpp b/radio/src/targets/pl18/bootloader/boot_menu.cpp index 1848732b404..951796ef37d 100644 --- a/radio/src/targets/pl18/bootloader/boot_menu.cpp +++ b/radio/src/targets/pl18/bootloader/boot_menu.cpp @@ -63,7 +63,7 @@ void bootloaderInitScreen() lcdInitDisplayDriver(); backlightInit(); backlightEnable(100); - setTrimsAsButtons(true); + setHatsAsKeys(true); } static void bootloaderDrawTitle(const char* text) diff --git a/radio/src/targets/pl18/hal.h b/radio/src/targets/pl18/hal.h index 85f1ba6db79..3c8dcbee05d 100644 --- a/radio/src/targets/pl18/hal.h +++ b/radio/src/targets/pl18/hal.h @@ -619,6 +619,8 @@ #define TRAINER_GPIO_AF LL_GPIO_AF_2 #define TRAINER_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1) +//ROTARY emulation for trims as buttons +#define ROTARY_ENCODER_NAVIGATION //BLUETOOTH #define BLUETOOTH_ON_RCC_AHB1Periph RCC_AHB1Periph_GPIOI diff --git a/radio/src/targets/pl18/key_driver.cpp b/radio/src/targets/pl18/key_driver.cpp index 7c768fe6ddf..cd09c374d71 100644 --- a/radio/src/targets/pl18/key_driver.cpp +++ b/radio/src/targets/pl18/key_driver.cpp @@ -191,7 +191,7 @@ uint32_t readKeys() { uint32_t result = 0; - if (getTrimsAsButtons()) { + if (getHatsAsKeys()) { uint32_t mkeys = _readKeyMatrix(); if (mkeys & (1 << TR4D)) result |= 1 << KEY_ENTER; if (mkeys & (1 << TR4U)) result |= 1 << KEY_EXIT;