From 6325ba19cd7b2a574b8bb50fd99fb7261155c343 Mon Sep 17 00:00:00 2001 From: 3djc Date: Tue, 3 Dec 2019 16:34:58 +0100 Subject: [PATCH] Add diagnostic screens to colorlcd radios (#7140) Add key diags screen to colorlcd radios --- radio/src/gui/480x272/menus.h | 2 + radio/src/gui/480x272/radio_diaganas.cpp | 55 ++++++++++++++++++++++ radio/src/gui/480x272/radio_diagkeys.cpp | 80 ++++++++++++++++++++++++++++++++ radio/src/gui/480x272/radio_hardware.cpp | 14 ++++++ radio/src/targets/horus/CMakeLists.txt | 2 + radio/src/translations/cz.h.txt | 4 +- radio/src/translations/de.h.txt | 4 +- 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 | 4 +- radio/src/translations/it.h.txt | 2 +- radio/src/translations/nl.h.txt | 4 +- radio/src/translations/pl.h.txt | 2 +- radio/src/translations/se.h.txt | 4 +- 15 files changed, 168 insertions(+), 15 deletions(-) create mode 100644 radio/src/gui/480x272/radio_diaganas.cpp create mode 100644 radio/src/gui/480x272/radio_diagkeys.cpp diff --git a/radio/src/gui/480x272/menus.h b/radio/src/gui/480x272/menus.h index 2145c067b..836029bd4 100644 --- a/radio/src/gui/480x272/menus.h +++ b/radio/src/gui/480x272/menus.h @@ -184,6 +184,8 @@ bool menuModelSensor(event_t event); bool menuModelExpoOne(event_t event); bool menuModelModuleOptions(event_t event); bool menuModelReceiverOptions(event_t event); +bool menuRadioDiagKeys(event_t event); +bool menuRadioDiagAnalogs(event_t event); extern const MenuHandlerFunc menuTabModel[MENU_MODEL_PAGES_COUNT]; diff --git a/radio/src/gui/480x272/radio_diaganas.cpp b/radio/src/gui/480x272/radio_diaganas.cpp new file mode 100644 index 000000000..37d16f2f7 --- /dev/null +++ b/radio/src/gui/480x272/radio_diaganas.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "opentx.h" + +constexpr coord_t LEFT_NAME_COLUMN = MENUS_MARGIN_LEFT; +constexpr coord_t RIGHT_NAME_COLUMN = LCD_W / 2; +constexpr coord_t ANA_OFFSET = 150; +constexpr coord_t RAS_TOP_POSITION = LCD_H - 45; + +bool menuRadioDiagAnalogs(event_t event) +{ + SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS, ICON_MODEL_SETUP, 0); + + for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) { + coord_t y = MENU_HEADER_HEIGHT + 1 + (i / 2) * FH; + uint8_t x = i & 1 ? LCD_W / 2 + 10 : LEFT_NAME_COLUMN; + lcdDrawNumber(x, y, i + 1, LEADING0 | LEFT, 2); + lcdDrawChar(x + 2 * 15 - 2, y, ':'); + lcdDrawHexNumber(x + 3 * 15 - 1, y, anaIn(i)); +#if defined(JITTER_MEASURE) + lcdDrawNumber(x + ANA_OFFSET - 1, y, rawJitter[i].get(), RIGHT); + lcdDrawNumber(x + ANA_OFFSET + 30 - 1, y, avgJitter[i].get(), RIGHT); + lcdDrawNumber(x + ANA_OFFSET + 70 - 1, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT); +#else + lcdDrawNumber(x + ANA_OFFSET - 1, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT); +#endif + } + + // RAS + if ((isModuleXJT(INTERNAL_MODULE) && IS_INTERNAL_MODULE_ON()) || (isModulePXX1(EXTERNAL_MODULE) && !IS_INTERNAL_MODULE_ON())) { + lcdDrawText(MENUS_MARGIN_LEFT, RAS_TOP_POSITION, "RAS : "); + lcdDrawNumber(lcdNextPos, RAS_TOP_POSITION, telemetryData.swrInternal.value(), 0); + lcdDrawText(LCD_W / 2, RAS_TOP_POSITION, "XJTVER : "); + lcdDrawNumber(lcdNextPos, RAS_TOP_POSITION, telemetryData.xjtVersion, 0); + } + return true; +} diff --git a/radio/src/gui/480x272/radio_diagkeys.cpp b/radio/src/gui/480x272/radio_diagkeys.cpp new file mode 100644 index 000000000..c952775a9 --- /dev/null +++ b/radio/src/gui/480x272/radio_diagkeys.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "opentx.h" + +constexpr coord_t TRIM_COLUMN = LCD_W - 120; +constexpr coord_t TRIM_MINUS_COLUMN = TRIM_COLUMN + 60; +constexpr coord_t TRIM_PLUS_COLUMN = TRIM_MINUS_COLUMN + 20; +constexpr coord_t SWITCHES_COLUMN = LCD_W / 2 - 20; + +#if defined(KEYS_GPIO_PIN_PGUP) + constexpr uint8_t KEY_START = 0; +#else + constexpr uint8_t KEY_START = 1; +#endif + +void displayKeyState(coord_t x, coord_t y, uint8_t key) +{ + uint8_t t = keys[key].state(); + lcdDrawChar(x, y, t + '0', t ? INVERS : 0); +} + +bool menuRadioDiagKeys(event_t event) +{ + SIMPLE_SUBMENU(STR_MENU_RADIO_SWITCHES, ICON_MODEL_SETUP, 1); + + lcdDrawText(TRIM_COLUMN, MENU_HEADER_HEIGHT + 1, "Trims"); + lcdDrawText(TRIM_MINUS_COLUMN, MENU_HEADER_HEIGHT + 1, "-"); + lcdDrawText(TRIM_PLUS_COLUMN, MENU_HEADER_HEIGHT + 1, "+"); + + for (uint8_t i = 0; i < NUM_TRIMS_KEYS; i++) { + const uint8_t trimMap[NUM_TRIMS_KEYS] = {6, 7, 4 , 5, 2, 3, 0, 1, 8, 9, 10, 11}; + coord_t y = MENU_HEADER_HEIGHT + 1 + FH + FH * (i / 2); + if (i & 1) { + lcdDrawText(TRIM_COLUMN, y, "T", 0); + lcdDrawNumber(lcdNextPos, y, i / 2 + 1, 0); + } + displayKeyState(i & 1 ? TRIM_PLUS_COLUMN : TRIM_MINUS_COLUMN, y, TRM_BASE + trimMap[i]); + } + + for (uint8_t i = KEY_START; i <= 6; i++) { + coord_t y = MENU_HEADER_HEIGHT + 1 + FH * (i - KEY_START); + lcdDrawTextAtIndex(MENUS_MARGIN_LEFT, y, STR_VKEYS, (i), 0); + displayKeyState(70, y, i); + } + + for (uint8_t i = 0; i <= NUM_SWITCHES; i++) { + if (SWITCH_EXISTS(i)) { + coord_t y = MENU_HEADER_HEIGHT + 1 + FH * i; + getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i); + getvalue_t sw = ((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3)); + drawSwitch(SWITCHES_COLUMN, y, sw, 0, false); + } + } + +#if defined(ROTARY_ENCODER_NAVIGATION) + coord_t y = MENU_HEADER_HEIGHT + FH * (8 - KEY_START); + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ROTARY_ENCODER); + lcdDrawNumber(70, y, rotencValue, 0); +#endif + + return true; +} diff --git a/radio/src/gui/480x272/radio_hardware.cpp b/radio/src/gui/480x272/radio_hardware.cpp index 283c99f2b..f00990383 100644 --- a/radio/src/gui/480x272/radio_hardware.cpp +++ b/radio/src/gui/480x272/radio_hardware.cpp @@ -72,6 +72,7 @@ enum MenuRadioHardwareItems { #endif ITEM_RADIO_HARDWARE_JITTER_FILTER, + ITEM_RADIO_HARDWARE_DEBUG, ITEM_RADIO_HARDWARE_MAX }; @@ -136,6 +137,7 @@ bool menuRadioHardware(event_t event) 0, /* aux serial mode */ 0, /* ADC filter */ + 1, /* Debug */ }); if (menuEvent) { @@ -348,6 +350,18 @@ bool menuRadioHardware(event_t event) g_eeGeneral.jitterFilter = 1 - editCheckBox(b, HW_SETTINGS_COLUMN+50, y, attr, event); break; } + + case ITEM_RADIO_HARDWARE_DEBUG: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_DEBUG); + lcdDrawText(HW_SETTINGS_COLUMN + 50, y, STR_ANALOGS_BTN, menuHorizontalPosition == 0 ? attr : 0); + lcdDrawText(lcdNextPos + 10, y, STR_KEYS_BTN, menuHorizontalPosition == 1 ? attr : 0); + if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) { + if (menuHorizontalPosition == 0) + pushMenu(menuRadioDiagAnalogs); + else + pushMenu(menuRadioDiagKeys); + } + break; } } diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index bfa37d9d5..987e4e81f 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -139,6 +139,8 @@ set(GUI_SRC bitmaps.cpp radio_sdmanager.cpp radio_hardware.cpp + radio_diagkeys.cpp + radio_diaganas.cpp model_inputs.cpp model_mixes.cpp model_curves.cpp diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 5a851d34f..df4261a0a 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -286,8 +286,8 @@ #define TR_VSWASHTYPE "---\0""120\0""120X""140\0""90\0" #if defined(PCBHORUS) -#define LEN_VKEYS "\006" -#define TR_VKEYS "Menu\0 ""Exit\0 ""Enter\0""Nahoru""Dolů\0 ""Vpravo""Vlevo" + #define LEN_VKEYS "\005" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(RADIO_T12) #define LEN_VKEYS "\005" #define TR_VKEYS "Exit\0""Enter""Dolů\0""Nhoru""Vprvo""Vlevo" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index d6333dd83..89ad37779 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -289,8 +289,8 @@ #define TR_VSWASHTYPE "--- ""120 ""120X""140 ""90\0" #if defined(PCBHORUS) - #define LEN_VKEYS "\006" - #define TR_VKEYS "Menu\0 ""Exit\0 ""Enter\0""Up\0 ""Down\0 ""Right\0""Left" + #define LEN_VKEYS "\005" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(PCBXLITE) #define LEN_VKEYS "\005" #define TR_VKEYS "Shift""Exit\0""Enter""Down\0""Up\0 ""Right""Left\0" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 298912576..0cfa48682 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -290,7 +290,7 @@ #if defined(PCBHORUS) #define LEN_VKEYS "\005" - #define TR_VKEYS "Menu\0""Exit\0""Enter""Up\0 ""Down\0""Right""Left\0" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(PCBXLITE) #define LEN_VKEYS "\005" #define TR_VKEYS "Shift""Exit\0""Enter""Down\0""Up\0 ""Right""Left\0" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 6ef675b84..acdc29090 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -305,7 +305,7 @@ #if defined(PCBHORUS) #define LEN_VKEYS "\005" - #define TR_VKEYS "Menu\0""Exit\0""Enter""Up\0 ""Down\0""Right""Left\0" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(PCBXLITE) #define LEN_VKEYS "\005" #define TR_VKEYS "Shift""Exit\0""Enter""Down\0""Up\0 ""Right""Left\0" diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index 3331887d8..c378cb47c 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -305,7 +305,7 @@ #if defined(PCBHORUS) #define LEN_VKEYS "\005" - #define TR_VKEYS "Menu\0""Exit\0""Enter""Up\0 ""Down\0""Right""Left\0" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(PCBXLITE) #define LEN_VKEYS "\005" #define TR_VKEYS "Shift""Exit\0""Enter""Down\0""Up\0 ""Right""Left\0" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 1a884b990..acf1f155f 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -306,8 +306,8 @@ #define TR_VSWASHTYPE "--- ""120 ""120X""140 ""90\0" #if defined(PCBHORUS) - #define LEN_VKEYS "\006" - #define TR_VKEYS "Menu\0 ""Exit\0 ""Entree""Haut\0 ""Bas\0 ""Droit\0""Gauche" + #define LEN_VKEYS "\005" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(PCBXLITE) #define LEN_VKEYS "\005" #define TR_VKEYS "Shift""Exit\0""Enter""Bas\0 ""Haut\0""Droit""Gauch" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index f3eaeadc8..f2852ba7b 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -308,7 +308,7 @@ #if defined(PCBHORUS) #define LEN_VKEYS "\005" - #define TR_VKEYS "Menu\0""Exit\0""Enter""Up\0 ""Down\0""Right""Left\0" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(PCBXLITE) #define LEN_VKEYS "\005" #define TR_VKEYS "Shift""Exit\0""Enter""Down\0""Up\0 ""Right""Left\0" diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index ab738f119..2b68fe5df 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -290,8 +290,8 @@ #define TR_VSWASHTYPE "---\0""120\0""120X""140\0""90\0" #if defined(PCBHORUS) - #define LEN_VKEYS "\006" - #define TR_VKEYS "Menu\0 ""Exit\0 ""Enter\0""Up\0 ""Down\0 ""Right\0""Left" + #define LEN_VKEYS "\005" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(RADIO_T12) #define LEN_VKEYS "\005" #define TR_VKEYS "Exit\0""Enter""Down\0""Up\0 ""Right""Left\0" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 8b27242a3..0441b2418 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -308,7 +308,7 @@ #if defined(PCBHORUS) #define LEN_VKEYS "\005" - #define TR_VKEYS "Menu\0""Exit\0""Enter""Up\0 ""Down\0""Right""Left\0" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(PCBXLITE) #define LEN_VKEYS "\005" #define TR_VKEYS "Shift""Exit\0""Enter""Down\0""Up\0 ""Right""Left\0" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 16fa59b7c..aeff79192 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -304,8 +304,8 @@ #define TR_VSWASHTYPE "--- ""120 ""120X""140 ""90\0 " #if defined(PCBHORUS) - #define LEN_VKEYS "\006" - #define TR_VKEYS "Menu\0 ""Exit\0 ""Enter\0""Upp\0 ""Ned\0 ""Höger\0""Vänst" + #define LEN_VKEYS "\005" + #define TR_VKEYS "PGUP\0""PGDN\0""ENTER""MDL\0 ""RTN\0 ""TELE\0""SYS\0 " #elif defined(RADIO_T12) #define LEN_VKEYS "\005" #define TR_VKEYS "Exit\0""Enter""Down\0""Up\0 ""Right""Left\0" -- 2.11.4.GIT