From 7789f5547c470b53388fb0e5aa8fd997c000c417 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 2 Jun 2021 06:49:06 +0200 Subject: [PATCH 01/16] Added touch support for T18 Resolves #138 --- radio/src/targets/horus/CMakeLists.txt | 1 + radio/src/targets/horus/hal.h | 30 ++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index 1ff27544a..bfbb3153e 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -106,6 +106,7 @@ if (PCB STREQUAL X10) add_definitions(-DRADIO_FAMILY_T16) option(INTERNAL_MODULE_MULTI "Support for MULTI internal module" ON) option(BLUETOOTH "Support for bluetooth module" OFF) + set(HARDWARE_TOUCH YES) add_definitions(-DMANUFACTURER_JUMPER) else() set(FLAVOUR x10) diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index 82d6d8b2a..752ed29d4 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -707,15 +707,27 @@ #endif // I2C Bus -#define I2C_RCC_AHB1Periph RCC_AHB1Periph_GPIOB -#define I2C_RCC_APB1Periph RCC_APB1Periph_I2C1 -#define I2C I2C1 -#define I2C_GPIO GPIOB -#define I2C_SCL_GPIO_PIN GPIO_Pin_8 // PB.08 -#define I2C_SDA_GPIO_PIN GPIO_Pin_9 // PB.09 -#define I2C_GPIO_AF GPIO_AF_I2C1 -#define I2C_SCL_GPIO_PinSource GPIO_PinSource8 -#define I2C_SDA_GPIO_PinSource GPIO_PinSource9 +#if defined(RADIO_T18) + #define I2C_RCC_AHB1Periph RCC_AHB1Periph_GPIOH + #define I2C_RCC_APB1Periph RCC_APB1Periph_I2C3 + #define I2C I2C3 + #define I2C_GPIO GPIOH + #define I2C_SCL_GPIO_PIN GPIO_Pin_7 // PH.07 + #define I2C_SDA_GPIO_PIN GPIO_Pin_8 // PH.08 + #define I2C_GPIO_AF GPIO_AF_I2C3 + #define I2C_SCL_GPIO_PinSource GPIO_PinSource7 + #define I2C_SDA_GPIO_PinSource GPIO_PinSource8 +#else + #define I2C_RCC_AHB1Periph RCC_AHB1Periph_GPIOB + #define I2C_RCC_APB1Periph RCC_APB1Periph_I2C1 + #define I2C I2C1 + #define I2C_GPIO GPIOB + #define I2C_SCL_GPIO_PIN GPIO_Pin_8 // PB.08 + #define I2C_SDA_GPIO_PIN GPIO_Pin_9 // PB.09 + #define I2C_GPIO_AF GPIO_AF_I2C1 + #define I2C_SCL_GPIO_PinSource GPIO_PinSource8 + #define I2C_SDA_GPIO_PinSource GPIO_PinSource9 +#endif #define I2C_SPEED 400000 // Haptic From 4dd8692191b0336617cb490fd8564a4870f15936 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 2 Jun 2021 07:07:33 +0200 Subject: [PATCH 02/16] Added GT911 config as provided by Jumper (not yet correct ATM) --- radio/src/targets/horus/tp_gt911.cpp | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/radio/src/targets/horus/tp_gt911.cpp b/radio/src/targets/horus/tp_gt911.cpp index eb8753e6f..6a57764a9 100644 --- a/radio/src/targets/horus/tp_gt911.cpp +++ b/radio/src/targets/horus/tp_gt911.cpp @@ -22,6 +22,33 @@ #include "tp_gt911.h" #include "touch.h" +#if defined(RADIO_T18) + +// TODO: +// This config has been provided by Jumper, but seems to be wrong: +// - coordinates are inverted, and only parts of the screen is covered +// +const uint8_t TOUCH_GT911_Cfg[] = { + 0x42, 0xE0, 0x01, 0x20, 0x03, 0x05, 0x35, 0x10, 0x01, 0x08, 0x28, 0x0F, + 0x5A, 0x46, 0x03, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18, + 0x1A, 0x1E, 0x14, 0x87, 0x28, 0x09, 0x46, 0x48, 0xB2, 0x04, 0x00, 0x00, + 0x00, 0x3A, 0x02, 0x1C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x32, 0x64, 0x94, 0xC5, 0x02, 0x00, 0x00, 0x00, 0x04, + 0xA2, 0x35, 0x00, 0x8F, 0x3D, 0x00, 0x80, 0x46, 0x00, 0x71, 0x51, 0x00, + 0x66, 0x5D, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, + 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x24, 0x26, 0x1D, 0x0C, 0x0A, 0x08, 0x06, 0x04, 0x02, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x6F, 0x01 +}; + +#else + //GT911 param table const uint8_t TOUCH_GT911_Cfg[] = { @@ -211,6 +238,8 @@ const uint8_t TOUCH_GT911_Cfg[] = 0x00 // 0x80FE Reserved }; +#endif + uint8_t touchGT911Flag = 0; uint8_t touchEventOccured = 0; struct TouchData touchData; From c2623aa00ee29fe5391a44a9ec26dc9aee2b5ebe Mon Sep 17 00:00:00 2001 From: Risto Date: Mon, 14 Jun 2021 20:07:15 +0200 Subject: [PATCH 03/16] Show special functions from 1 to 64, instead of 0 to 63 To be more uniform with other elements, such as curves, global variables that start from 0. --- radio/src/gui/colorlcd/special_functions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/colorlcd/special_functions.cpp b/radio/src/gui/colorlcd/special_functions.cpp index 72814bcd7..92de8cc49 100644 --- a/radio/src/gui/colorlcd/special_functions.cpp +++ b/radio/src/gui/colorlcd/special_functions.cpp @@ -76,7 +76,7 @@ class SpecialFunctionEditPage : public Page window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, LCD_W - PAGE_TITLE_LEFT, 20}, - (functions == g_model.customFn ? "SF" : "GF") + std::to_string(index), + (functions == g_model.customFn ? "SF" : "GF") + std::to_string(index+1), 0, FOCUS_COLOR); } @@ -526,7 +526,7 @@ void SpecialFunctionsPage::build(FormWindow *window, int8_t focusIndex) for (uint8_t i = 0; i < MAX_SPECIAL_FUNCTIONS; i++) { CustomFunctionData *cfn = &functions[i]; - strAppendUnsigned(&s[2], i); + strAppendUnsigned(&s[2], i+1); if (cfn->swtch == 0) { auto button = new TextButton(window, grid.getLabelSlot(), s); From 9b670b0e4d0d4e7cf3152b9e9cd8cf9f0e151b32 Mon Sep 17 00:00:00 2001 From: rotorman Date: Mon, 14 Jun 2021 20:47:04 +0200 Subject: [PATCH 04/16] The UARTs of radios are using 3.3V logic level, not TTL / 5V. --- radio/src/translations/cn.h.txt | 2 +- radio/src/translations/cz.h.txt | 2 +- radio/src/translations/de.h.txt | 2 +- radio/src/translations/en.h.txt | 2 +- radio/src/translations/es.h.txt | 2 +- radio/src/translations/fi.h.txt | 2 +- radio/src/translations/fr.h.txt | 2 +- radio/src/translations/it.h.txt | 2 +- radio/src/translations/nl.h.txt | 2 +- radio/src/translations/pl.h.txt | 2 +- radio/src/translations/pt.h.txt | 2 +- radio/src/translations/se.h.txt | 2 +- radio/src/translations/tw.h.txt | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/radio/src/translations/cn.h.txt b/radio/src/translations/cn.h.txt index 8f1b6f2ed..1f0e07dd3 100644 --- a/radio/src/translations/cn.h.txt +++ b/radio/src/translations/cn.h.txt @@ -718,7 +718,7 @@ #define TR_COPROC_TEMP "主板温度" #define TR_CAPAWARNING INDENT "电流过低" #define TR_TEMPWARNING INDENT "过热" -#define TR_TTL_WARNING "注意: 串口仅能使用TTL电平或5V" +#define TR_TTL_WARNING "注意:使用逻辑电平3.3V" #define TR_FUNC "功能" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index f369d2b88..67ba25ac1 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -805,7 +805,7 @@ #define TR_COPROC_TEMP "Tepl. MB \016>" #define TR_CAPAWARNING INDENT "Nízká kapacita" #define TR_TEMPWARNING INDENT "Přehřátí" -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Fce." #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 071d63b46..7486afd00 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -810,7 +810,7 @@ #define TR_COPROC_TEMP "MB Temp. \016>" #define TR_CAPAWARNING INDENT "Kapaz. niedrig" // wg 9XR-Pro #define TR_TEMPWARNING INDENT "Temp. größer" //wg 9XR-Pro -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Funktion" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 6ebdca2f9..b990e4484 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -814,7 +814,7 @@ #define TR_COPROC_TEMP "MB Temp." #define TR_CAPAWARNING INDENT "Capacity low" #define TR_TEMPWARNING INDENT "Overheat" -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Func" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index b88667292..cdfdc068f 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -812,7 +812,7 @@ #define TR_COPROC_TEMP "MB Temp. \016>" #define TR_CAPAWARNING INDENT "Capacidad baja" #define TR_TEMPWARNING INDENT "Sobrecalent" -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Función" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index 3d41e884a..17bd0b0c1 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -826,7 +826,7 @@ #define TR_COPROC_TEMP "MB Temp. \016>" #define TR_CAPAWARNING INDENT "Capacity Low" #define TR_TEMPWARNING INDENT "Overheat" -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Func" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index a730fda64..d2ac7ff04 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -831,7 +831,7 @@ #define TR_COPROC_TEMP "Temp. MB \016>" #define TR_CAPAWARNING INDENT "Capacité Basse" #define TR_TEMPWARNING INDENT "Surchauffe" -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Fonction" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index a1adc9151..db28fde80 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -832,7 +832,7 @@ #define TR_COPROC_TEMP "Temp. MB \016>" #define TR_CAPAWARNING INDENT "Capacità Bassa" #define TR_TEMPWARNING INDENT "Temp. Alta" -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Funz" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index b0bc956d9..4b4783a38 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -815,7 +815,7 @@ #define TR_COPROC_TEMP "MB Temp. \016>" #define TR_CAPAWARNING INDENT "Capaciteit laag" // wg 9XR-Pro #define TR_TEMPWARNING INDENT "Overhitting" //wg 9XR-Pro -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Funktie" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 82ab7cb74..4b14f6f25 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -829,7 +829,7 @@ #define TR_COPROC_TEMP "Temp. MB" #define TR_CAPAWARNING INDENT "Mała pojemność" #define TR_TEMPWARNING INDENT "Przegrzanie" -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Funkc" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index fe29043b4..0669c02c4 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -830,7 +830,7 @@ #define TR_COPROC_TEMP "MB Temp. \016>" #define TR_CAPAWARNING INDENT "Aviso Capacidade" #define TR_TEMPWARNING INDENT "Temperat. ALTA" -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Funcao" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 8a790710b..c39926ca7 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -832,7 +832,7 @@ #define TR_COPROC_TEMP "MB temp. \016>" #define TR_CAPAWARNING INDENT "Låg Kapacitet" #define TR_TEMPWARNING TR(INDENT "Hög Temp ", INDENT "Hög Temperatur") -#define TR_TTL_WARNING "Warning: use only TLL or 5v" +#define TR_TTL_WARNING "Warning: use 3.3V logic levels" #define TR_FUNC "Funk" #define TR_V1 "V1" #define TR_V2 "V2" diff --git a/radio/src/translations/tw.h.txt b/radio/src/translations/tw.h.txt index 7dba22e07..0913cd8f4 100644 --- a/radio/src/translations/tw.h.txt +++ b/radio/src/translations/tw.h.txt @@ -718,7 +718,7 @@ #define TR_COPROC_TEMP "主板溫度" #define TR_CAPAWARNING INDENT "電流過低" #define TR_TEMPWARNING INDENT "過熱" -#define TR_TTL_WARNING "注意: 端口僅能使用TTL電平或5V" +#define TR_TTL_WARNING "注意:使用逻辑电平3.3V" #define TR_FUNC "功能" #define TR_V1 "V1" #define TR_V2 "V2" From c55d915d56708997f2cb778cf861dcefe6b9e980 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 15 Jun 2021 06:15:53 +0200 Subject: [PATCH 05/16] Fixed MPM proto subtype reset on subtype change --- radio/src/gui/128x64/model_setup.cpp | 1 + radio/src/pulses/modules_helpers.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index 12ddf963d..08f1072c1 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -1576,6 +1576,7 @@ void menuModelSetup(event_t event) if (MULTIMODULE_PROTOCOL_KNOWN(moduleIdx)) { const char * title = getMultiOptionTitle(moduleIdx); + if (!title) break; lcdDrawText(INDENT_WIDTH, y, title); if (title == STR_MULTI_RFTUNE) { lcdDrawText(MODEL_SETUP_2ND_COLUMN + 23, y, "RSSI(", LEFT); diff --git a/radio/src/pulses/modules_helpers.h b/radio/src/pulses/modules_helpers.h index 227aa974d..c33a433c4 100644 --- a/radio/src/pulses/modules_helpers.h +++ b/radio/src/pulses/modules_helpers.h @@ -678,7 +678,6 @@ inline void resetMultiProtocolsOptions(uint8_t moduleIdx) else { g_model.moduleData[moduleIdx].multi.autoBindMode = 0; } - g_model.moduleData[moduleIdx].subType = 0; g_model.moduleData[moduleIdx].multi.optionValue = 0; g_model.moduleData[moduleIdx].multi.disableTelemetry = 0; g_model.moduleData[moduleIdx].multi.disableMapping = 0; From f4b50cee9dc34879ca71252c7f5eb4b76d1d5616 Mon Sep 17 00:00:00 2001 From: norulers Date: Tue, 15 Jun 2021 00:01:53 +0800 Subject: [PATCH 06/16] Update T18 gt911 configuration --- radio/src/targets/horus/tp_gt911.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/radio/src/targets/horus/tp_gt911.cpp b/radio/src/targets/horus/tp_gt911.cpp index 6a57764a9..2f973d49c 100644 --- a/radio/src/targets/horus/tp_gt911.cpp +++ b/radio/src/targets/horus/tp_gt911.cpp @@ -29,22 +29,22 @@ // - coordinates are inverted, and only parts of the screen is covered // const uint8_t TOUCH_GT911_Cfg[] = { - 0x42, 0xE0, 0x01, 0x20, 0x03, 0x05, 0x35, 0x10, 0x01, 0x08, 0x28, 0x0F, - 0x5A, 0x46, 0x03, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18, - 0x1A, 0x1E, 0x14, 0x87, 0x28, 0x09, 0x46, 0x48, 0xB2, 0x04, 0x00, 0x00, - 0x00, 0x3A, 0x02, 0x1C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x32, 0x64, 0x94, 0xC5, 0x02, 0x00, 0x00, 0x00, 0x04, - 0xA2, 0x35, 0x00, 0x8F, 0x3D, 0x00, 0x80, 0x46, 0x00, 0x71, 0x51, 0x00, - 0x66, 0x5D, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xE0, 0x01, 0x10, 0x01, 0x05, 0x0C, 0x00, 0x01, 0x18, 0x28, 0x0F, + 0x50, 0x3C, 0x03, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18, + 0x1A, 0x1E, 0x14, 0x87, 0x29, 0x0A, 0x4B, 0x4D, 0xD3, 0x07, 0x00, 0x00, + 0x00, 0x19, 0x02, 0x10, 0x32, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x32, 0x73, 0x94, 0xD5, 0x02, 0x07, 0x00, 0x00, 0x04, + 0xAE, 0x36, 0x00, 0x94, 0x40, 0x00, 0x7E, 0x4C, 0x00, 0x6D, 0x59, 0x00, + 0x5D, 0x6A, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, - 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x24, 0x26, 0x1D, 0x0C, 0x0A, 0x08, 0x06, 0x04, 0x02, - 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, + 0x1A, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x02, + 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x24, + 0x26, 0x28, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x6F, 0x01 + 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x01 }; #else From 5e03b762ea84af73a49cd607fa7495e48a26320a Mon Sep 17 00:00:00 2001 From: norulers Date: Tue, 15 Jun 2021 14:42:59 +0800 Subject: [PATCH 07/16] Update gt911 config version --- radio/src/targets/horus/tp_gt911.cpp | 207 ++++++++++++++++++++++++--- radio/src/targets/horus/tp_gt911.h | 2 +- 2 files changed, 186 insertions(+), 23 deletions(-) diff --git a/radio/src/targets/horus/tp_gt911.cpp b/radio/src/targets/horus/tp_gt911.cpp index 2f973d49c..6915a4a90 100644 --- a/radio/src/targets/horus/tp_gt911.cpp +++ b/radio/src/targets/horus/tp_gt911.cpp @@ -22,29 +22,192 @@ #include "tp_gt911.h" #include "touch.h" -#if defined(RADIO_T18) - -// TODO: -// This config has been provided by Jumper, but seems to be wrong: -// - coordinates are inverted, and only parts of the screen is covered -// +#if defined (RADIO_T18) const uint8_t TOUCH_GT911_Cfg[] = { - 0xFF, 0xE0, 0x01, 0x10, 0x01, 0x05, 0x0C, 0x00, 0x01, 0x18, 0x28, 0x0F, - 0x50, 0x3C, 0x03, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18, - 0x1A, 0x1E, 0x14, 0x87, 0x29, 0x0A, 0x4B, 0x4D, 0xD3, 0x07, 0x00, 0x00, - 0x00, 0x19, 0x02, 0x10, 0x32, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x32, 0x73, 0x94, 0xD5, 0x02, 0x07, 0x00, 0x00, 0x04, - 0xAE, 0x36, 0x00, 0x94, 0x40, 0x00, 0x7E, 0x4C, 0x00, 0x6D, 0x59, 0x00, - 0x5D, 0x6A, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, - 0x1A, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x02, - 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x24, - 0x26, 0x28, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x01 + GT911_CFG_NUMER, // 0x8047 Config version + 0xE0, // 0x8048 X output map : x 480 + 0x01, + 0x10, // 0x804A Y ouptut max : y 272 + 0x01, + GT911_MAX_TP, // 0x804C Touch number + 0x0C, // 0x804D Module switch 1 : bit4= xy change Int mode + 0x00, // 0x804E Module switch 2 + 0x01, // 0x804F Shake_Count + 0x18, // 0x8050 Filter + 0x28, // 0x8051 Larger touch + 0x0F, // 0x8052 Noise reduction + 0x50, // 0x8053 Screen touch level + 0x3C, // 0x8054 Screen touch leave + 0x03, // 0x8055 Low power control + 0x05, // 0x8056 Refresh rate + 0x00, // 0x8057 X threshold + 0x00, // 0x8058 Y threshold + 0x00, // 0x8059 Reserved + 0x00, // 0x805A Reserved + 0x00, // 0x805B Space (top, bottom) + 0x00, // 0x805C Space (left, right) + 0x04, // 0x805D Mini filter + 0x18, // 0x805E Strech R0 + 0x1A, // 0x805F Strech R1 + 0x1E, // 0x8060 Strech R2 + 0x14, // 0x8061 Strech RM + 0x87, // 0x8062 Drv groupA num + 0x29, // 0x8063 Drv groupB num + 0x0A, // 0x8064 Sensor num + 0x4B, // 0x8065 FreqA factor + 0x4D, // 0x8066 FreqB factor + 0xD3, // 0x8067 Panel bit freq + 0x07, + 0x00, // 0x8069 Reserved + 0x00, + 0x00, // 0x806B Panel tx gain + 0x19, // 0x806C Panel rx gain + 0x02, // 0x806D Panel dump shift + 0x10, // 0x806E Drv frame control + 0x32, // 0x806F Charging level up + 0x00, // 0x8070 Module switch 3 + 0x00, // 0x8071 Gesture distance + 0x00, // 0x8072 Gesture long press time + 0x00, // 0x8073 X/Y slope adjust + 0x03, // 0x8074 Gesture control + 0x00, // 0x8075 Gesture switch 1 + 0x00, // 0x8076 Gesture switch 2 + 0x00, // 0x8077 Gesture refresh rate + 0x00, // 0x8078 Gesture touch level + 0x00, // 0x8079 New green wake up level + 0x32, // 0x807A Freq hopping start + 0x73, // 0x807B Freq hopping end + 0x94, // 0x807C Noise detect time + 0xD5, // 0x807D Hopping flag + 0x02, // 0x807E Hopping flag + 0x07, // 0x807F Noise threshold + 0x00, // 0x8080 Nois min threshold old + 0x00, // 0x8081 Reserved + 0x04, // 0x8082 Hopping sensor group + 0xAE, // 0x8083 Hopping Seg1 normalize + 0x36, // 0x8084 Hopping Seg1 factor + 0x00, // 0x8085 Main clock adjust + 0x94, // 0x8086 Hopping Seg2 normalize + 0x40, // 0x8087 Hopping Seg2 factor + 0x00, // 0x8088 Reserved + 0x7E, // 0x8089 Hopping Seg3 normalize + 0x4C, // 0x808A Hopping Seg3 factor + 0x00, // 0x808B Reserved + 0x6D, // 0x808C Hopping Seg4 normalize + 0x59, // 0x808D Hopping Seg4 factor + 0x00, // 0x808E Reserved + 0x5D, // 0x808F Hopping Seg5 normalize + 0x6A, // 0x8090 Hopping Seg5 factor + 0x00, // 0x8091 Reserved + 0x5D, // 0x8092 Hopping Seg6 normalize + 0x00, // 0x8093 Key1 + 0x00, // 0x8094 Key2 + 0x00, // 0x8095 Key3 + 0x00, // 0x8096 Key4 + 0x00, // 0x8097 Key area + 0x00, // 0x8098 Key touch level + 0x00, // 0x8099 Key leave level + 0x00, // 0x809A Key sens + 0x00, // 0x809B Key sens + 0x00, // 0x809C Key restrain + 0x00, // 0x809D Key restrain time + 0x00, // 0x809E Large gesture touch + 0x00, // 0x809F Reserved + 0x00, // 0x80A0 Reserved + 0x00, // 0x80A1 Hotknot noise map + 0x00, // 0x80A2 Link threshold + 0x00, // 0x80A3 Pxy threshold + 0x00, // 0x80A4 GHot dump shift + 0x00, // 0x80A5 GHot rx gain + 0x00, // 0x80A6 Freg gain + 0x00, // 0x80A7 Freg gain 1 + 0x00, // 0x80A8 Freg gain 2 + 0x00, // 0x80A9 Freg gain 3 + 0x00, // 0x80AA Reserved + 0x00, // 0x80AB Reserved + 0x00, // 0x80AC Reserved + 0x00, // 0x80AD Reserved + 0x00, // 0x80AE Reserved + 0x00, // 0x80AF Reserved + 0x00, // 0x80B0 Reserved + 0x00, // 0x80B1 Reserved + 0x00, // 0x80B2 Reserved + 0x00, // 0x80B3 Combine dis + 0x00, // 0x80B4 Split set + 0x00, // 0x80B5 Reserved + 0x00, // 0x80B6 Reserved + 0x0A, // 0x80B7 Sensor CH0 + 0x0C, // 0x80B8 Sensor CH1 + 0x0E, // 0x80B9 Sensor CH2 + 0x10, // 0x80BA Sensor CH3 + 0x12, // 0x80BB Sensor CH4 + 0x14, // 0x80BC Sensor CH5 + 0x16, // 0x80BD Sensor CH6 + 0x18, // 0x80BE Sensor CH7 + 0x1A, // 0x80BF Sensor CH8 + 0x1C, // 0x80C0 Sensor CH9 + 0xFF, // 0x80C1 Sensor CH10 + 0xFF, // 0x80C2 Sensor CH11 + 0xFF, // 0x80C3 Sensor CH12 + 0xFF, // 0x80C4 Sensor CH13 + 0xFF, // 0x80C5 Reserved + 0xFF, // 0x80C6 Reserved + 0xFF, // 0x80C7 Reserved + 0xFF, // 0x80C8 Reserved + 0xFF, // 0x80C9 Reserved + 0xFF, // 0x80CA Reserved + 0xFF, // 0x80CB Reserved + 0xFF, // 0x80CC Reserved + 0xFF, // 0x80CD Reserved + 0xFF, // 0x80CE Reserved + 0xFF, // 0x80CF Reserved + 0xFF, // 0x80D0 Reserved + 0xFF, // 0x80D1 Reserved + 0xFF, // 0x80D2 Reserved + 0xFF, // 0x80D3 Reserved + 0xFF, // 0x80D4 Reserved + 0x00, // 0x80D5 Driver CH0 + 0x02, // 0x80D6 Driver CH1 + 0x04, // 0x80D7 Driver CH2 + 0x06, // 0x80D8 Driver CH3 + 0x08, // 0x80D9 Driver CH4 + 0x0A, // 0x80DA Driver CH5 + 0x0C, // 0x80DB Driver CH6 + 0x1D, // 0x80DC Driver CH7 + 0x1E, // 0x80DD Driver CH8 + 0x1F, // 0x80DE Driver CH9 + 0x20, // 0x80DF Driver CH10 + 0x21, // 0x80E0 Driver CH11 + 0x22, // 0x80E1 Driver CH12 + 0x24, // 0x80E2 Driver CH13 + 0x26, // 0x80E3 Driver CH14 + 0x28, // 0x80E4 Driver CH15 + 0xFF, // 0x80E5 Driver CH16 + 0xFF, // 0x80E6 Driver CH17 + 0xFF, // 0x80E7 Driver CH18 + 0xFF, // 0x80E8 Driver CH19 + 0xFF, // 0x80E9 Driver CH20 + 0xFF, // 0x80EA Driver CH21 + 0xFF, // 0x80EB Driver CH22 + 0xFF, // 0x80EC Driver CH23 + 0xFF, // 0x80ED Driver CH24 + 0xFF, // 0x80EE Driver CH25 + 0xFF, // 0x80EF Reserved + 0xFF, // 0x80F0 Reserved + 0xFF, // 0x80F1 Reserved + 0xFF, // 0x80F2 Reserved + 0xFF, // 0x80F3 Reserved + 0xFF, // 0x80F4 Reserved + 0xFF, // 0x80F5 Reserved + 0xFF, // 0x80F6 Reserved + 0xFF, // 0x80F7 Reserved + 0xFF, // 0x80F8 Reserved + 0xFF, // 0x80F9 Reserved + 0xFF, // 0x80FA Reserved + 0xFF, // 0x80FB Reserved + 0xFF, // 0x80FC Reserved + 0xFF, // 0x80FD Reserved + 0xFF // 0x80FE Reserved }; #else diff --git a/radio/src/targets/horus/tp_gt911.h b/radio/src/targets/horus/tp_gt911.h index 624db2c92..ce48a680f 100644 --- a/radio/src/targets/horus/tp_gt911.h +++ b/radio/src/targets/horus/tp_gt911.h @@ -30,7 +30,7 @@ void touchPanelRead(); bool touchPanelEventOccured(); #define GT911_MAX_TP 5 -#define GT911_CFG_NUMER 0x6A +#define GT911_CFG_NUMER 0x6C //I2C #define GT_CMD_WR 0X28 From 5471b233f2b95324e91aa7ddb67a8f158254b88b Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 15 Jun 2021 11:59:52 +0200 Subject: [PATCH 08/16] Fix models list loading Resolves #218 --- radio/src/storage/conversions/conversions.cpp | 5 ++++- radio/src/storage/sdcard_common.cpp | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/radio/src/storage/conversions/conversions.cpp b/radio/src/storage/conversions/conversions.cpp index 18e52d6a0..7071b7540 100644 --- a/radio/src/storage/conversions/conversions.cpp +++ b/radio/src/storage/conversions/conversions.cpp @@ -75,7 +75,10 @@ void convertRadioData(int version) #if defined(SIMU) RTOS_WAIT_MS(200); #endif - + + // Load models list before converting + modelslist.load(); + const char* error = nullptr; for (auto category_ptr : modelslist.getCategories()) { for (auto model_ptr : *category_ptr) { diff --git a/radio/src/storage/sdcard_common.cpp b/radio/src/storage/sdcard_common.cpp index cdf755ee8..4f3a7b910 100644 --- a/radio/src/storage/sdcard_common.cpp +++ b/radio/src/storage/sdcard_common.cpp @@ -149,9 +149,6 @@ void storageReadAll() // it's being reloaded after USB connection modelslist.clear(); - // and reload the list - modelslist.load(); - if (loadRadioSettings() != nullptr) { storageEraseAll(true); } @@ -163,6 +160,9 @@ void storageReadAll() } } + // and reload the list + modelslist.load(); + // Current model filename is empty... // Let's fix it! if (strlen(g_eeGeneral.currModelFilename) == 0) { From ba7ce9e911c5628f0a0fdceb9aeffdda33080139 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 15 Jun 2021 12:01:28 +0200 Subject: [PATCH 09/16] Fixed model select frame size calculation Resolves #219 --- radio/src/gui/colorlcd/model_select.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/model_select.cpp b/radio/src/gui/colorlcd/model_select.cpp index da6209d0e..9a4a0115b 100644 --- a/radio/src/gui/colorlcd/model_select.cpp +++ b/radio/src/gui/colorlcd/model_select.cpp @@ -277,7 +277,9 @@ class ModelCategoryPageBody : public FormWindow #endif } - y += MODEL_SELECT_CELL_HEIGHT + MODEL_CELL_PADDING; + if (index % MODEL_CELLS_PER_LINE != 0) { + y += MODEL_SELECT_CELL_HEIGHT + MODEL_CELL_PADDING; + } setInnerHeight(y); if (category->empty()) { From 95c65772e43cea3885e269c6833c192e71bbba55 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 15 Jun 2021 15:42:24 +0200 Subject: [PATCH 10/16] Added X9D (not "+") --- .github/workflows/actions.yml | 1 + .github/workflows/nightly.yml | 1 + tools/build-gh.sh | 3 +++ 3 files changed, 5 insertions(+) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 76fb8130a..a4dff18f0 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -29,6 +29,7 @@ jobs: - X10 - X12S - X7 + - X9D - X9DP - X9DP2019 - X9LITE diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e3c663190..b4a213c74 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -28,6 +28,7 @@ jobs: - X10 - X12S - X7 + - X9D - X9DP - X9DP2019 - X9LITE diff --git a/tools/build-gh.sh b/tools/build-gh.sh index 2ccc0f914..528024fa8 100755 --- a/tools/build-gh.sh +++ b/tools/build-gh.sh @@ -100,6 +100,9 @@ case $FLAVOR in XLITES) BUILD_OPTIONS+="-DPCB=XLITES" ;; + X9D) + BUILD_OPTIONS+="-DPCB=X9D" + ;; X9DP) BUILD_OPTIONS+="-DPCB=X9D+" ;; From b8511a2b2275dc4d777f861ced8557a41e3da9b7 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 15 Jun 2021 16:19:43 +0200 Subject: [PATCH 11/16] Fix lcd.RGB() It does not require access to lcd, so let's not check that. --- radio/src/lua/api_colorlcd.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/radio/src/lua/api_colorlcd.cpp b/radio/src/lua/api_colorlcd.cpp index c83229c16..c30d73bb4 100644 --- a/radio/src/lua/api_colorlcd.cpp +++ b/radio/src/lua/api_colorlcd.cpp @@ -834,9 +834,6 @@ Returns a 5/6/5 rgb color code, that can be used with lcd.setColor */ static int luaRGB(lua_State *L) { - if (!luaLcdAllowed) - return 0; - int r = luaL_checkinteger(L, 1); int g = luaL_checkinteger(L, 2); int b = luaL_checkinteger(L, 3); From 60517df3496253d7ce9b2ee0dde72ac8abd8da5d Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 15 Jun 2021 16:24:54 +0200 Subject: [PATCH 12/16] Removed necessity for lcd allowance in lcd.setColor() and lcd.getColor() --- radio/src/lua/api_colorlcd.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/radio/src/lua/api_colorlcd.cpp b/radio/src/lua/api_colorlcd.cpp index c30d73bb4..cff137481 100644 --- a/radio/src/lua/api_colorlcd.cpp +++ b/radio/src/lua/api_colorlcd.cpp @@ -783,9 +783,6 @@ Set a color for specific area */ static int luaLcdSetColor(lua_State *L) { - if (!luaLcdAllowed) - return 0; - unsigned int index = luaL_checkunsigned(L, 1) >> 16; unsigned int color = luaL_checkunsigned(L, 2); @@ -806,9 +803,6 @@ Get the color for specific area : see lcd.setColor for area list static int luaLcdGetColor(lua_State *L) { - if (!luaLcdAllowed) - return 0; - unsigned int index = luaL_checkunsigned(L, 1) >> 16; lua_pushunsigned(L, lcdColorTable[index]); From 8b92b3be982c3e9556a81e404b5390890e7d35b6 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 15 Jun 2021 17:37:13 +0200 Subject: [PATCH 13/16] [Color] Some SD manager fixes --- radio/src/gui/colorlcd/radio_sdmanager.cpp | 38 +++++++++++++++------- radio/src/gui/colorlcd/radio_tools.cpp | 10 ++++-- radio/src/gui/colorlcd/tabsgroup.cpp | 5 +-- radio/src/gui/colorlcd/tabsgroup.h | 14 ++------ 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/radio/src/gui/colorlcd/radio_sdmanager.cpp b/radio/src/gui/colorlcd/radio_sdmanager.cpp index de720ed17..cd442c3c1 100644 --- a/radio/src/gui/colorlcd/radio_sdmanager.cpp +++ b/radio/src/gui/colorlcd/radio_sdmanager.cpp @@ -92,6 +92,10 @@ class FileNameEditWindow : public Page RadioSdManagerPage::RadioSdManagerPage() : PageTab(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, ICON_RADIO_SD_MANAGER) { + setOnSetVisibleHandler([]() { + TRACE("f_chdir(ROOT_PATH)"); + f_chdir(ROOT_PATH); + }); } void RadioSdManagerPage::rebuild(FormWindow * window) @@ -115,6 +119,13 @@ char * getFullPath(const std::string &filename) return full_path; } +char * getCurrentPath() +{ + static char path[FF_MAX_LFN + 1]; // TODO optimize that! + f_getcwd((TCHAR*)path, FF_MAX_LFN); + return path; +} + class FilePreview : public Window { public: @@ -209,6 +220,7 @@ void RadioSdManagerPage::build(FormWindow * window) std::list files; std::list directories; + std::string currentPath(getCurrentPath()); auto preview = new FilePreview(window, {LCD_W / 2 + 6, 0, LCD_W / 2 - 16, window->height()}); FRESULT res = f_opendir(&dir, "."); // Open the directory @@ -238,7 +250,8 @@ void RadioSdManagerPage::build(FormWindow * window) for (auto name: directories) { auto b = new TextButton(window, grid.getLabelSlot(), name, [=]() -> uint8_t { - f_chdir(name.data()); + std::string fullpath = currentPath + "/" + name; + f_chdir(fullpath.c_str()); window->clear(); build(window); return 0; @@ -250,6 +263,7 @@ void RadioSdManagerPage::build(FormWindow * window) for (auto name: files) { auto button = new TextButton(window, grid.getLabelSlot(), name, [=]() -> uint8_t { auto menu = new Menu(window); + f_chdir(currentPath.c_str()); const char *ext = getFileExtension(name.data()); if (ext) { if (!strcasecmp(ext, SOUNDS_EXT)) { @@ -286,14 +300,14 @@ void RadioSdManagerPage::build(FormWindow * window) dialog->flash(getFullPath(name)); }); } - else if (isExtensionMatching(ext, BITMAPS_EXT)) { - // TODO - } - else if (!strcasecmp(ext, TEXT_EXT)) { - menu->addLine(STR_VIEW_TEXT, [=]() { - // TODO - }); - } + // else if (isExtensionMatching(ext, BITMAPS_EXT)) { + // // TODO + // } + // else if (!strcasecmp(ext, TEXT_EXT)) { + // menu->addLine(STR_VIEW_TEXT, [=]() { + // // TODO + // }); + // } if (!READ_ONLY() && !strcasecmp(ext, FIRMWARE_EXT)) { if (isBootloader(name.data())) { menu->addLine(STR_FLASH_BOOTLOADER, [=]() { @@ -328,8 +342,9 @@ void RadioSdManagerPage::build(FormWindow * window) } #if defined(LUA) else if (isExtensionMatching(ext, SCRIPTS_EXT)) { + std::string fullpath = currentPath + "/" + name; menu->addLine(STR_EXECUTE_FILE, [=]() { - luaExec(getFullPath(name)); + luaExec(fullpath.c_str()); //TODO: check 'luaState' StandaloneLuaWindow::instance()->attach(window); }); @@ -374,7 +389,8 @@ void RadioSdManagerPage::build(FormWindow * window) }); } return 0; - }, 0); + }, OPAQUE); + button->setBgColorHandler([=]() -> LcdFlags { return FIELD_BGCOLOR; }); button->setFocusHandler([=](bool active) { if (active) { preview->setFile(getFullPath(name)); diff --git a/radio/src/gui/colorlcd/radio_tools.cpp b/radio/src/gui/colorlcd/radio_tools.cpp index 3484f2495..88c71033e 100644 --- a/radio/src/gui/colorlcd/radio_tools.cpp +++ b/radio/src/gui/colorlcd/radio_tools.cpp @@ -119,10 +119,14 @@ void RadioToolsPage::rebuild(FormWindow * window) auto b = new TextButton( window, grid.getFieldSlot(1), label, [window, path_str]() -> uint8_t { - f_chdir("/SCRIPTS/TOOLS/"); - luaExec(path_str.c_str()); - // TODO: check 'luaState' + + char toolPath[FF_MAX_LFN + 1]; + strncpy(toolPath, path_str.c_str(), sizeof(toolPath)-1); + *((char *)getBasename(toolPath)-1) = '\0'; + f_chdir(toolPath); + StandaloneLuaWindow::instance()->attach(window); + luaExec(path_str.c_str()); return 0; }, OPAQUE); diff --git a/radio/src/gui/colorlcd/tabsgroup.cpp b/radio/src/gui/colorlcd/tabsgroup.cpp index a0b7c32a8..f3ea3163b 100644 --- a/radio/src/gui/colorlcd/tabsgroup.cpp +++ b/radio/src/gui/colorlcd/tabsgroup.cpp @@ -146,9 +146,10 @@ void TabsGroup::setVisibleTab(PageTab * tab) Keyboard::hide(); #endif currentTab = tab; + if (tab->onSetVisible) tab->onSetVisible(); tab->build(&body); - if (!focusWindow) - setFocus(SET_FOCUS_DEFAULT); + if (!focusWindow) setFocus(SET_FOCUS_DEFAULT); + header.setTitle(tab->title.c_str()); invalidate(); } diff --git a/radio/src/gui/colorlcd/tabsgroup.h b/radio/src/gui/colorlcd/tabsgroup.h index d3af8c15d..1618bf7a0 100644 --- a/radio/src/gui/colorlcd/tabsgroup.h +++ b/radio/src/gui/colorlcd/tabsgroup.h @@ -50,17 +50,9 @@ class PageTab { { } - void destroy() + void setOnSetVisibleHandler(std::function handler) { - if (onPageDestroyed) { - onPageDestroyed(); - } - delete this; - } - - void setOnPageDestroyedHandler(std::function handler) - { - onPageDestroyed = std::move(handler); + onSetVisible = std::move(handler); } void setTitle(std::string value) @@ -81,7 +73,7 @@ class PageTab { protected: std::string title; unsigned icon = 0; - std::function onPageDestroyed; + std::function onSetVisible; }; class TabsCarousel: public Window { From 8cc5e7777561cea16df227579a9ae6d5a34e6714 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 15 Jun 2021 17:37:46 +0200 Subject: [PATCH 14/16] [Color] disabled PowerMeter and Ghost tool for now --- radio/src/gui/colorlcd/radio_tools.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/radio/src/gui/colorlcd/radio_tools.cpp b/radio/src/gui/colorlcd/radio_tools.cpp index 88c71033e..9f83dda45 100644 --- a/radio/src/gui/colorlcd/radio_tools.cpp +++ b/radio/src/gui/colorlcd/radio_tools.cpp @@ -259,6 +259,7 @@ void RadioToolsPage::rebuild(FormWindow * window) } #endif #if defined(PXX2) +#if 0 // disabled Power Meter: not yet implemented if (isPXX2ModuleOptionAvailable( reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE] .information.modelID, @@ -286,8 +287,10 @@ void RadioToolsPage::rebuild(FormWindow * window) grid.nextLine(); } #endif +#endif #if defined(GHOST) +#if 0 if (isModuleGhost(EXTERNAL_MODULE)) { auto txt = new StaticText(window, grid.getLabelSlot(), "ghost", BUTTON_BACKGROUND, CENTERED); @@ -311,6 +314,7 @@ void RadioToolsPage::rebuild(FormWindow * window) }); grid.nextLine(); } +#endif #endif window->setInnerHeight(grid.getWindowHeight()); From a0090f4e0076037ea1a6e5426810104161c672bc Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 16 Jun 2021 05:47:40 +0200 Subject: [PATCH 15/16] [Color] Prevent ModelBmp from reloading the bitmap when not needed Resolves #214 --- radio/src/gui/colorlcd/widgets/modelbmp.cpp | 43 +++++++++++---------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/radio/src/gui/colorlcd/widgets/modelbmp.cpp b/radio/src/gui/colorlcd/widgets/modelbmp.cpp index 0d5a8d3cd..4c2d96c12 100644 --- a/radio/src/gui/colorlcd/widgets/modelbmp.cpp +++ b/radio/src/gui/colorlcd/widgets/modelbmp.cpp @@ -29,48 +29,44 @@ class ModelBitmapWidget: public Widget ModelBitmapWidget(const WidgetFactory * factory, FormGroup * parent, const rect_t & rect, Widget::PersistentData * persistentData): Widget(factory, parent, rect, persistentData) { + loadBitmap(); } void refresh(BitmapBuffer * dc) override { - if (buffer && ((buffer->width() != width()) || (buffer->height() != height()))) { + if (buffer && + ((buffer->width() != width()) || (buffer->height() != height()) || + (deps_hash != getHash()))) { loadBitmap(); } // big space to draw if (rect.h >= 96 && rect.w >= 120) { - dc->drawFilledRect(0, 0, rect.w, rect.h, SOLID, MAINVIEW_PANES_COLOR, OPACITY(5)); - + if (buffer) { + dc->drawBitmap(0, 0, buffer.get()); + } + auto iconMask = theme->getIconMask(ICON_MODEL); if (iconMask) { - dc->drawMask(6, 4, iconMask, MAINVIEW_GRAPHICS_COLOR); + dc->drawMask(6, 4, iconMask, HEADER_COLOR); } - dc->drawSizedText(45, 10, g_model.header.name, LEN_MODEL_NAME, FONT(XS)); - dc->drawSolidFilledRect(39, 27, rect.w - 48, 2, MAINVIEW_GRAPHICS_COLOR); - - if (buffer) { - dc->drawBitmap(0, 38, buffer.get()); - } + dc->drawSizedText(45, 10, g_model.header.name, LEN_MODEL_NAME, + FONT(XS) | DEFAULT_COLOR); + dc->drawSolidFilledRect(39, 27, rect.w - 48, 2, HEADER_COLOR); } // smaller space to draw else if (buffer) { - dc->drawBitmap(0, 38, buffer.get()); - } + dc->drawBitmap(0, 0, buffer.get()); + } } void checkEvents() override { Widget::checkEvents(); - - uint32_t new_hash = hash(g_model.header.bitmap, sizeof(g_model.header.bitmap)); - new_hash ^= hash(g_model.header.name, sizeof(g_model.header.name)); - new_hash ^= hash(g_eeGeneral.themeName, sizeof(g_eeGeneral.themeName)); - - if (new_hash != deps_hash) { - deps_hash = new_hash; - loadBitmap(); + if (getHash() != deps_hash) { + invalidate(); } } @@ -78,6 +74,11 @@ class ModelBitmapWidget: public Widget std::unique_ptr buffer; uint32_t deps_hash = 0; + uint32_t getHash() + { + return hash(g_model.header.bitmap, sizeof(g_model.header.bitmap)); + } + void loadBitmap() { std::string filename = std::string(g_model.header.bitmap); @@ -94,7 +95,7 @@ class ModelBitmapWidget: public Widget } buffer->clear(DEFAULT_BGCOLOR); - buffer->drawScaledBitmap(bitmap.get(), 0, 0, width(), height() - 38); + buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38); } }; From 368709288f90753a97c84ff6e94384b60903dd38 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 16 Jun 2021 08:21:22 +0200 Subject: [PATCH 16/16] Added X9D & T18 to the targets in fw.json --- fw.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fw.json b/fw.json index c6290644b..22102d1f2 100644 --- a/fw.json +++ b/fw.json @@ -2,12 +2,14 @@ "targets": [ ["TX16s", "tx16s-"], ["QX7", "x7-"], + ["X9D", "x9d-"], ["X9D Plus", "x9dp-"], ["X9D Plus 2019", "x9dp2019-"], ["T-Lite", "tlite-"], ["X-Lite", "xlite-"], ["X9 Lite", "x9lite-"], ["T16", "t16-"], + ["T18", "t18-"], ["TX12", "tx12-"], ["Horus X12s", "x12s-"], ["Horus X10", "x10-"], @@ -15,4 +17,4 @@ ["T8", "t8-"] ], "changelog": "- Major initial bug fixes" -} \ No newline at end of file +}