28
28
#include " libopenui.h"
29
29
#include " edgetx.h"
30
30
31
+ #if defined(FUNCTION_SWITCHES_RGB_LEDS)
32
+ #include " color_list.h"
33
+ #include " hal/rgbleds.h"
34
+ #endif
35
+
36
+ #if defined(FUNCTION_SWITCHES_RGB_LEDS)
37
+ uint16_t getLedColor (int i)
38
+ {
39
+ // Convert RBG888 to RGB565
40
+ uint32_t rgb32 = getFSLedRGBColor (i);
41
+ uint8_t r = GET_RED32 (rgb32);
42
+ uint8_t g = GET_GREEN32 (rgb32);
43
+ uint8_t b = GET_BLUE32 (rgb32);
44
+ return RGB (r, g, b);
45
+ }
46
+ #endif
47
+
31
48
class RadioCustSwitchesDiagsWindow : public Window
32
49
{
33
- static constexpr coord_t FS_1ST_COLUMN = 95 ;
34
- static constexpr coord_t FS_2ND_COLUMN = 160 ;
35
- static constexpr coord_t FS_3RD_COLUMN = 260 ;
50
+ static LAYOUT_VAL (FS_1ST_COLUMN, 95 , 62 , LS(95 ))
51
+ static LAYOUT_VAL(FS_2ND_COLUMN, 160 , 107 , LS(160 ))
52
+ static LAYOUT_VAL(FS_3RD_COLUMN, 260 , 173 , LS(260 ))
53
+ static LAYOUT_VAL(FS_LBL_WIDTH, 60 , 40 , LS(60 ))
54
+ #if defined(FUNCTION_SWITCHES_RGB_LEDS)
55
+ static LAYOUT_VAL (FS_COLOR_WIDTH, 30 , 30 , LS(30 ))
56
+ static LAYOUT_VAL(FS_COLOR_HEIGHT, 15 , 15 , LS(15 ))
57
+ ColorSwatch* colorBox[NUM_FUNCTIONS_SWITCHES];
58
+ #endif
36
59
37
60
public:
38
61
RadioCustSwitchesDiagsWindow (Window *parent, const rect_t &rect) :
39
62
Window (parent, rect)
40
63
{
41
- new StaticText (this , {FS_1ST_COLUMN, PAD_SMALL, 60 , LV_SIZE_CONTENT},
64
+ new StaticText (this , {FS_1ST_COLUMN, PAD_SMALL, FS_LBL_WIDTH , LV_SIZE_CONTENT},
42
65
" Phys" );
43
- new StaticText (this , {FS_2ND_COLUMN, PAD_SMALL, 60 , LV_SIZE_CONTENT},
66
+ new StaticText (this , {FS_2ND_COLUMN, PAD_SMALL, FS_LBL_WIDTH , LV_SIZE_CONTENT},
44
67
" Log" );
45
- new StaticText (this , {FS_3RD_COLUMN, PAD_SMALL, 60 , LV_SIZE_CONTENT},
68
+ new StaticText (this , {FS_3RD_COLUMN, PAD_SMALL, FS_LBL_WIDTH , LV_SIZE_CONTENT},
46
69
" Led" );
47
70
for (uint8_t i = 0 ; i < NUM_FUNCTIONS_SWITCHES; i += 1 ) {
48
- coord_t y = 2 * EdgeTxStyles::STD_FONT_HEIGHT +
49
- i * EdgeTxStyles::STD_FONT_HEIGHT;
50
- new StaticText (this , {10 , y, LV_SIZE_CONTENT, LV_SIZE_CONTENT},
51
- STR_CHAR_SWITCH);
52
- new StaticText (this , {25 , y, LV_SIZE_CONTENT, LV_SIZE_CONTENT},
53
- switchGetName (i + switchGetMaxSwitches ()));
71
+ coord_t y = (i + 2 ) * EdgeTxStyles::STD_FONT_HEIGHT;
72
+ std::string s (STR_CHAR_SWITCH);
73
+ s += switchGetName (i + switchGetMaxSwitches ());
74
+ new StaticText (this , {PAD_LARGE, y, FS_LBL_WIDTH, LV_SIZE_CONTENT}, s);
54
75
new DynamicText (
55
- this , {FS_1ST_COLUMN + 10 , y, LV_SIZE_CONTENT , LV_SIZE_CONTENT},
76
+ this , {FS_1ST_COLUMN + PAD_LARGE , y, FS_LBL_WIDTH , LV_SIZE_CONTENT},
56
77
[=]() {
57
78
return getFSPhysicalState (i) ? STR_CHAR_DOWN : STR_CHAR_UP;
58
79
});
59
80
new DynamicText (
60
- this , {FS_2ND_COLUMN + 10 , y, LV_SIZE_CONTENT , LV_SIZE_CONTENT},
81
+ this , {FS_2ND_COLUMN + PAD_LARGE , y, FS_LBL_WIDTH , LV_SIZE_CONTENT},
61
82
[=]() { return getFSLogicalState (i) ? STR_CHAR_DOWN : STR_CHAR_UP; });
83
+
84
+ #if defined(FUNCTION_SWITCHES_RGB_LEDS)
85
+ colorBox[i] = new ColorSwatch (this , {FS_3RD_COLUMN, y, FS_COLOR_WIDTH,
86
+ FS_COLOR_HEIGHT}, getLedColor (i));
87
+ #else
62
88
new DynamicText (this ,
63
- {FS_3RD_COLUMN + 5 , y, LV_SIZE_CONTENT, LV_SIZE_CONTENT},
64
- [=]() { return STR_OFFON[getFSLedState (i)]; });
89
+ {FS_3RD_COLUMN, y, FS_LBL_WIDTH, LV_SIZE_CONTENT},
90
+ [=]() { return STR_OFFON[getFSLedState (i)]; });
91
+ #endif
92
+ }
93
+ }
94
+
95
+ #if defined(FUNCTION_SWITCHES_RGB_LEDS)
96
+ void checkEvents () {
97
+ Window::checkEvents ();
98
+ for (uint8_t i = 0 ; i < NUM_FUNCTIONS_SWITCHES; i += 1 ) {
99
+ colorBox[i]->setColor (getLedColor (i));
65
100
}
66
101
}
102
+ #endif
67
103
68
104
protected:
69
105
};
@@ -88,4 +124,4 @@ RadioCustSwitchesDiagsPage::RadioCustSwitchesDiagsPage() :
88
124
buildBody (body);
89
125
}
90
126
91
- #endif
127
+ #endif
0 commit comments