feat: support for RadioMaster GX12 (#5703)
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
raphaelcoeffic
philmoz
Peter Feerick
parent
0f86cd9a95
commit
36cdd93a1a
@@ -24,6 +24,7 @@
|
||||
#include "hal/adc_driver.h"
|
||||
#include "hal/switch_driver.h"
|
||||
#include "hal/module_port.h"
|
||||
#include "hal/rgbleds.h"
|
||||
#include "switches.h"
|
||||
|
||||
#if defined(USBJ_EX)
|
||||
@@ -70,7 +71,30 @@ enum MenuModelSetupItems {
|
||||
ITEM_MODEL_SETUP_TIMER3_PERSISTENT,
|
||||
ITEM_MODEL_SETUP_TIMER3_MINUTE_BEEP,
|
||||
ITEM_MODEL_SETUP_TIMER3_COUNTDOWN_BEEP,
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
ITEM_MODEL_SETUP_LABEL,
|
||||
ITEM_MODEL_SETUP_SW1,
|
||||
ITEM_MODEL_SETUP_SW1_COLOR,
|
||||
ITEM_MODEL_SETUP_SW2,
|
||||
ITEM_MODEL_SETUP_SW2_COLOR,
|
||||
ITEM_MODEL_SETUP_SW3,
|
||||
ITEM_MODEL_SETUP_SW3_COLOR,
|
||||
ITEM_MODEL_SETUP_SW4,
|
||||
ITEM_MODEL_SETUP_SW4_COLOR,
|
||||
ITEM_MODEL_SETUP_SW5,
|
||||
ITEM_MODEL_SETUP_SW5_COLOR,
|
||||
ITEM_MODEL_SETUP_SW6,
|
||||
ITEM_MODEL_SETUP_SW6_COLOR,
|
||||
ITEM_MODEL_SETUP_GROUP1_LABEL,
|
||||
ITEM_MODEL_SETUP_GROUP1_ALWAYS_ON,
|
||||
ITEM_MODEL_SETUP_GROUP1_START,
|
||||
ITEM_MODEL_SETUP_GROUP2_LABEL,
|
||||
ITEM_MODEL_SETUP_GROUP2_ALWAYS_ON,
|
||||
ITEM_MODEL_SETUP_GROUP2_START,
|
||||
ITEM_MODEL_SETUP_GROUP3_LABEL,
|
||||
ITEM_MODEL_SETUP_GROUP3_ALWAYS_ON,
|
||||
ITEM_MODEL_SETUP_GROUP3_START,
|
||||
#elif defined(FUNCTION_SWITCHES)
|
||||
ITEM_MODEL_SETUP_LABEL,
|
||||
ITEM_MODEL_SETUP_SW1,
|
||||
ITEM_MODEL_SETUP_SW2,
|
||||
@@ -354,7 +378,30 @@ inline uint8_t TIMER_ROW(uint8_t timer, uint8_t value)
|
||||
|
||||
#define EXTRA_MODULE_ROWS
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
#define FUNCTION_SWITCHES_ROWS 1, \
|
||||
FS_ROW(NAVIGATION_LINE_BY_LINE|3), \
|
||||
FS_ROW(1), \
|
||||
FS_ROW(NAVIGATION_LINE_BY_LINE|3), \
|
||||
FS_ROW(1), \
|
||||
FS_ROW(NAVIGATION_LINE_BY_LINE|3), \
|
||||
FS_ROW(1), \
|
||||
FS_ROW(NAVIGATION_LINE_BY_LINE|3), \
|
||||
FS_ROW(1), \
|
||||
FS_ROW(NAVIGATION_LINE_BY_LINE|3), \
|
||||
FS_ROW(1), \
|
||||
FS_ROW(NAVIGATION_LINE_BY_LINE|3), \
|
||||
FS_ROW(1), \
|
||||
FS_ROW(G1_ROW(LABEL())), \
|
||||
FS_ROW(G1_ROW(0)), \
|
||||
FS_ROW(G1_ROW(0)), \
|
||||
FS_ROW(G2_ROW(LABEL())), \
|
||||
FS_ROW(G2_ROW(0)), \
|
||||
FS_ROW(G2_ROW(0)), \
|
||||
FS_ROW(G3_ROW(LABEL())), \
|
||||
FS_ROW(G3_ROW(0)), \
|
||||
FS_ROW(G3_ROW(0)),
|
||||
#elif defined(FUNCTION_SWITCHES)
|
||||
#define FUNCTION_SWITCHES_ROWS 1, \
|
||||
FS_ROW(NAVIGATION_LINE_BY_LINE|3), \
|
||||
FS_ROW(NAVIGATION_LINE_BY_LINE|3), \
|
||||
@@ -838,9 +885,15 @@ void menuModelSetup(event_t event)
|
||||
case ITEM_MODEL_SETUP_SW5:
|
||||
case ITEM_MODEL_SETUP_SW6:
|
||||
{
|
||||
int index = k - ITEM_MODEL_SETUP_SW1;
|
||||
int index = (k - ITEM_MODEL_SETUP_SW1) / 2;
|
||||
lcdDrawSizedText(INDENT_WIDTH, y, STR_CHAR_SWITCH, 2, menuHorizontalPosition < 0 ? attr : 0);
|
||||
lcdDrawText(lcdNextPos, y, switchGetName(index+switchGetMaxSwitches()), menuHorizontalPosition < 0 ? attr : 0);
|
||||
|
||||
// TODO: restore following line when switchGetName(index+switchGetMaxSwitches()) doesn't crash anymore
|
||||
//lcdDrawText(lcdNextPos, y, switchGetName(index+switchGetMaxSwitches()), menuHorizontalPosition < 0 ? attr : 0);
|
||||
|
||||
// TODO : delete next 2 lines when switchGetName(index+switchGetMaxSwitches()) doesn't crash anymore
|
||||
lcdDrawText(lcdNextPos, y, "SW", menuHorizontalPosition < 0 ? attr : 0);
|
||||
lcdDrawChar(lcdNextPos, y, '1' + index, menuHorizontalPosition < 0 ? attr : 0);
|
||||
|
||||
if (ZEXIST(g_model.switchNames[index]) || (attr && s_editMode > 0 && menuHorizontalPosition == 0))
|
||||
editName(35, y, g_model.switchNames[index], LEN_SWITCH_NAME, event, menuHorizontalPosition == 0 ? attr : 0, 0, old_editMode);
|
||||
@@ -892,6 +945,39 @@ void menuModelSetup(event_t event)
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
case ITEM_MODEL_SETUP_SW1_COLOR:
|
||||
case ITEM_MODEL_SETUP_SW2_COLOR:
|
||||
case ITEM_MODEL_SETUP_SW3_COLOR:
|
||||
case ITEM_MODEL_SETUP_SW4_COLOR:
|
||||
case ITEM_MODEL_SETUP_SW5_COLOR:
|
||||
case ITEM_MODEL_SETUP_SW6_COLOR:
|
||||
{
|
||||
int index = (k - ITEM_MODEL_SETUP_SW1_COLOR) / 2;
|
||||
uint8_t selectedColor = 0;
|
||||
|
||||
// ON
|
||||
selectedColor = getRGBColorIndex(g_model.functionSwitchLedONColor[index].getColor());
|
||||
selectedColor = editChoice(INDENT_WIDTH + getTextWidth(STR_FS_ON_COLOR) + 2, y, STR_FS_ON_COLOR, \
|
||||
STR_FS_COLOR_LIST, selectedColor, 0, (sizeof(colorTable) / sizeof(colorTable[0])) - 1, menuHorizontalPosition == 0 ? attr : 0, event, INDENT_WIDTH);
|
||||
if (attr && menuHorizontalPosition == 0 && checkIncDec_Ret) {
|
||||
g_model.functionSwitchLedONColor[index].setColor(colorTable[selectedColor]);
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
|
||||
// OFF
|
||||
selectedColor = getRGBColorIndex(g_model.functionSwitchLedOFFColor[index].getColor());
|
||||
selectedColor = editChoice((30 + 5*FW) + getTextWidth(STR_FS_OFF_COLOR) + 2, y, STR_FS_OFF_COLOR, \
|
||||
STR_FS_COLOR_LIST, selectedColor, 0, (sizeof(colorTable) / sizeof(colorTable[0])) - 1, menuHorizontalPosition == 1 ? attr : 0, event, 30 + 5*FW);
|
||||
if (attr && menuHorizontalPosition == 1 && checkIncDec_Ret) {
|
||||
g_model.functionSwitchLedOFFColor[index].setColor(colorTable[selectedColor]);
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case ITEM_MODEL_SETUP_GROUP1_LABEL:
|
||||
case ITEM_MODEL_SETUP_GROUP2_LABEL:
|
||||
case ITEM_MODEL_SETUP_GROUP3_LABEL:
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "hal/switch_driver.h"
|
||||
#include "hal/key_driver.h"
|
||||
#include "switches.h"
|
||||
#include "boards/generic_stm32/rgb_leds.h"
|
||||
|
||||
void displayKeyState(uint8_t x, uint8_t y, uint8_t key)
|
||||
{
|
||||
@@ -54,9 +55,15 @@ static EnumKeys get_ith_key(uint8_t i)
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
void menuRadioDiagFS(event_t event)
|
||||
{
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
constexpr coord_t FS_1ST_COLUMN = 32;
|
||||
constexpr coord_t FS_2ND_COLUMN = 60;
|
||||
constexpr coord_t FS_3RD_COLUMN = 80;
|
||||
#else
|
||||
constexpr coord_t FS_1ST_COLUMN = 40;
|
||||
constexpr coord_t FS_2ND_COLUMN = 70;
|
||||
constexpr coord_t FS_3RD_COLUMN = 100;
|
||||
#endif
|
||||
SIMPLE_SUBMENU(STR_MENU_FSWITCH, 1);
|
||||
lcdDrawText(FS_1ST_COLUMN, MENU_HEADER_HEIGHT + 1, "Phys");
|
||||
lcdDrawText(FS_2ND_COLUMN, MENU_HEADER_HEIGHT + 1, "Log");
|
||||
@@ -68,7 +75,11 @@ void menuRadioDiagFS(event_t event)
|
||||
lcdDrawText(lcdNextPos, y, switchGetName(i+switchGetMaxSwitches()), 0);
|
||||
lcdDrawText(FS_1ST_COLUMN + 7, y, getFSPhysicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP);
|
||||
lcdDrawText(FS_2ND_COLUMN + 5, y, getFSLogicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP);
|
||||
lcdDrawText(FS_3RD_COLUMN, y, STR_OFFON[getFSLedState(i)]);
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
lcdDrawText(FS_3RD_COLUMN, y, STR_FS_COLOR_LIST[getRGBColorIndex(rgbGetLedColor(i))], 0);
|
||||
#else
|
||||
lcdDrawText(FS_3RD_COLUMN, y, STR_OFFON[fsLedState(i)]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "hal/rgbleds.h"
|
||||
#include "boards/generic_stm32/rgb_leds.h"
|
||||
|
||||
|
||||
#define SLEEP_BITMAP_WIDTH 42
|
||||
@@ -52,9 +54,14 @@ void drawStartupAnimation(uint32_t duration, uint32_t totalDuration)
|
||||
|
||||
for (uint8_t j = 0; j < steps; j++) {
|
||||
if (index2 > j) {
|
||||
fsLedOn(j);
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
fsLedRGB(j, 0xFFFFFF);
|
||||
rgbLedColorApply();
|
||||
#else
|
||||
setFSLedON(j);
|
||||
#endif
|
||||
#if defined(RADIO_FAMILY_T20)
|
||||
fsLedOn(j + steps);
|
||||
setFSLedON(j + steps);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -88,14 +95,14 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration,
|
||||
steps);
|
||||
|
||||
for (uint8_t j = 0; j < steps; j++) {
|
||||
fsLedOff(j);
|
||||
setFSLedOFF(j);
|
||||
#if defined(RADIO_FAMILY_T20)
|
||||
fsLedOff(j + steps);
|
||||
setFSLedOFF(j + steps);
|
||||
#endif
|
||||
if (steps - index2 > j) {
|
||||
fsLedOn(j);
|
||||
setFSLedON(j);
|
||||
#if defined(RADIO_FAMILY_T20)
|
||||
fsLedOn(j + steps);
|
||||
setFSLedON(j + steps);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,13 @@
|
||||
#include "edgetx.h"
|
||||
#include "strhelpers.h"
|
||||
#include "switches.h"
|
||||
#include "color_picker.h"
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
static constexpr coord_t LH = 72;
|
||||
#else
|
||||
static constexpr coord_t LH = 36;
|
||||
#endif
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||
|
||||
@@ -116,6 +123,37 @@ class FunctionSwitch : public Window
|
||||
SET_DIRTY();
|
||||
});
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
new StaticText(this, {8 , 6 + 36, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_FS_OFF_COLOR, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto offcolor = new ColorPicker(
|
||||
this, rect_t{},
|
||||
[=]() -> int { // getValue
|
||||
return g_model.functionSwitchLedOFFColor[switchIndex];
|
||||
},
|
||||
[=](int newValue) { // setValue
|
||||
g_model.functionSwitchLedOFFColor[switchIndex] =
|
||||
(uint32_t)newValue;
|
||||
TRACE("Color: %x", g_model.functionSwitchLedOFFColor[switchIndex]);
|
||||
SET_DIRTY();
|
||||
});
|
||||
offcolor->setPos(NM_X, 36);
|
||||
|
||||
new StaticText(this, {TP_X, 6 + 36, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_FS_ON_COLOR, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto oncolor = new ColorPicker(
|
||||
this, rect_t{},
|
||||
[=]() -> int { // getValue
|
||||
return g_model.functionSwitchLedONColor[switchIndex];
|
||||
},
|
||||
[=](int newValue) { // setValue
|
||||
g_model.functionSwitchLedONColor[switchIndex] =
|
||||
(uint32_t)newValue;
|
||||
SET_DIRTY();
|
||||
});
|
||||
oncolor->setPos(GR_X, 36);
|
||||
#endif //FUNCTION_SWITCHES_RGB_LEDS
|
||||
|
||||
setState();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "radio_diagcustswitches.h"
|
||||
|
||||
#include "hal/rgbleds.h"
|
||||
#include "board.h"
|
||||
#include "libopenui.h"
|
||||
#include "edgetx.h"
|
||||
|
||||
Reference in New Issue
Block a user