chore(color): color UI code cleanup - round 3 (#5351)
This commit is contained in:
@@ -541,7 +541,7 @@ void ModuleOptions::update()
|
||||
if (!optionsAvailable) {
|
||||
// no options available
|
||||
line = form->newLine(grid);
|
||||
new StaticText(line, rect_t{}, STR_NO_TX_OPTIONS, 0);
|
||||
new StaticText(line, rect_t{}, STR_NO_TX_OPTIONS);
|
||||
} else {
|
||||
// some options available
|
||||
if (optionsAvailable & (1 << MODULE_OPTION_EXTERNAL_ANTENNA)) {
|
||||
|
||||
@@ -219,30 +219,29 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
|
||||
uint8_t _channel, bool isInHeader) :
|
||||
Window(parent, rect), channel(_channel)
|
||||
{
|
||||
LcdFlags textColor =
|
||||
isInHeader ? COLOR_THEME_PRIMARY2 : COLOR_THEME_SECONDARY1;
|
||||
LcdColorIndex txtColIdx = isInHeader ? COLOR_THEME_PRIMARY2_INDEX : COLOR_THEME_SECONDARY1_INDEX;
|
||||
|
||||
outputChannelBar = new OutputChannelBar(
|
||||
this, {ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT + ChannelBar::TMARGIN, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT},
|
||||
this, {PAD_TINY, ChannelBar::BAR_HEIGHT + PAD_TINY, width() - PAD_TINY, ChannelBar::BAR_HEIGHT},
|
||||
channel, isInHeader);
|
||||
|
||||
new MixerChannelBar(
|
||||
this,
|
||||
{ChannelBar::LMARGIN, (2 * ChannelBar::BAR_HEIGHT) + ChannelBar::TMARGIN + 1, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT},
|
||||
{PAD_TINY, (2 * ChannelBar::BAR_HEIGHT) + PAD_TINY + 1, width() - PAD_TINY, ChannelBar::BAR_HEIGHT},
|
||||
channel);
|
||||
|
||||
// Channel number
|
||||
char chanString[] = TR_CH "32 ";
|
||||
strAppendSigned(&chanString[2], channel + 1, 2);
|
||||
new StaticText(this, {ChannelBar::LMARGIN, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString,
|
||||
textColor | FONT(XS) | LEFT);
|
||||
new StaticText(this, {PAD_TINY, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString,
|
||||
txtColIdx, FONT(XS) | LEFT);
|
||||
|
||||
// Channel name
|
||||
if (g_model.limitData[channel].name[0]) {
|
||||
char nm[LEN_CHANNEL_NAME + 1];
|
||||
strAppend(nm, g_model.limitData[channel].name, LEN_CHANNEL_NAME);
|
||||
new StaticText(this, {ChannelBar::LMARGIN + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm,
|
||||
textColor | FONT(XS) | LEFT);
|
||||
new StaticText(this, {PAD_TINY + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm,
|
||||
txtColIdx, FONT(XS) | LEFT);
|
||||
}
|
||||
|
||||
// Channel value in µS
|
||||
@@ -254,12 +253,12 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
|
||||
return calcRESXto100(channelOutputs[channel]);
|
||||
return PPM_CH_CENTER(channel) + channelOutputs[channel] / 2;
|
||||
},
|
||||
textColor | FONT(XS) | RIGHT, "", suffix);
|
||||
txtColIdx, FONT(XS) | RIGHT, "", suffix);
|
||||
|
||||
// Override icon
|
||||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
||||
overrideIcon = new StaticIcon(
|
||||
this, 0, 5, ICON_CHAN_MONITOR_LOCKED, textColor);
|
||||
this, 0, 5, ICON_CHAN_MONITOR_LOCKED, txtColIdx);
|
||||
overrideIcon->show(safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED);
|
||||
#endif
|
||||
|
||||
@@ -267,7 +266,7 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
|
||||
LimitData* ld = limitAddress(channel);
|
||||
if (ld && ld->revert) {
|
||||
new StaticIcon(this, 0, ICON_SZ, ICON_CHAN_MONITOR_INVERTED,
|
||||
textColor);
|
||||
txtColIdx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ class ChannelBar : public Window
|
||||
LcdColorIndex textColorIndex = COLOR_THEME_SECONDARY1_INDEX);
|
||||
|
||||
static LAYOUT_VAL(BAR_HEIGHT, 13, 13)
|
||||
static LAYOUT_VAL(LMARGIN, 2, 2)
|
||||
static LAYOUT_VAL(TMARGIN, 2, 2)
|
||||
|
||||
static LAYOUT_VAL(VAL_W, 45, 45)
|
||||
static LAYOUT_VAL(VAL_H, 14, 14)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "themes/etx_lv_theme.h"
|
||||
|
||||
ColorList::ColorList(Window *parent, const rect_t &rect,
|
||||
std::vector<ColorEntry> colors, LcdFlags lcdFlags) :
|
||||
std::vector<ColorEntry> colors) :
|
||||
ListBox(parent, rect, getColorListNames(colors)), _colorList(colors)
|
||||
{
|
||||
setSelected(0);
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
class ColorList : public ListBox
|
||||
{
|
||||
public:
|
||||
ColorList(Window* parent, const rect_t& rect, std::vector<ColorEntry> colors,
|
||||
LcdFlags lcdFlags = 0);
|
||||
ColorList(Window* parent, const rect_t& rect, std::vector<ColorEntry> colors);
|
||||
|
||||
inline ColorEntry getSelectedColor()
|
||||
{
|
||||
|
||||
@@ -89,7 +89,7 @@ class ColorEditorPopup : public BaseDialog
|
||||
colorPad = new ColorSwatch(hbox, {0, 0, COLOR_PAD_WIDTH, COLOR_PAD_HEIGHT},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
|
||||
hexStr = new StaticText(hbox, {0, 0, CVAL_W, 0}, "", COLOR_THEME_PRIMARY1 | FONT(L));
|
||||
hexStr = new StaticText(hbox, {0, 0, CVAL_W, 0}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(L));
|
||||
|
||||
updateColor(color);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g,
|
||||
// getStringAtIndex(buf, STR_CRSF_BAUDRATE,
|
||||
// CROSSFIRE_STORE_TO_INDEX(
|
||||
// g_eeGeneral.internalModuleBaudrate)),
|
||||
// 0, COLOR_THEME_PRIMARY1);
|
||||
// COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
|
||||
auto line = newLine(grid);
|
||||
|
||||
@@ -165,7 +165,7 @@ Curve::Curve(Window* parent, const rect_t& rect,
|
||||
posHLine = lv_line_create(lvobj);
|
||||
etx_obj_add_style(posHLine, styles->graph_position_line, LV_PART_MAIN);
|
||||
|
||||
positionValue = new StaticText(this, {10, 10, LV_SIZE_CONTENT, 17}, "", COLOR_THEME_PRIMARY1 | FONT(XS));
|
||||
positionValue = new StaticText(this, {10, 10, LV_SIZE_CONTENT, 17}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
positionValue->padLeft(PAD_TINY);
|
||||
positionValue->padRight(PAD_TINY);
|
||||
etx_solid_bg(positionValue->getLvObj(), COLOR_THEME_ACTIVE_INDEX);
|
||||
|
||||
@@ -90,14 +90,14 @@ class CurveDataEdit : public Window
|
||||
{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y,
|
||||
NUM_BTN_WIDTH, PTNUM_H},
|
||||
std::to_string(i + start + 1),
|
||||
COLOR_THEME_PRIMARY1 | FONT(XS) | CENTERED);
|
||||
COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | CENTERED);
|
||||
}
|
||||
|
||||
y += NUM_HDR_HEIGHT;
|
||||
|
||||
new StaticText(
|
||||
parent, {1, y + PAD_MEDIUM, PTNUM_X, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||
"X", COLOR_THEME_PRIMARY1 | CENTERED);
|
||||
"X", COLOR_THEME_PRIMARY1_INDEX, CENTERED);
|
||||
|
||||
int8_t* points = curveAddress(index);
|
||||
|
||||
@@ -110,7 +110,7 @@ class CurveDataEdit : public Window
|
||||
parent,
|
||||
{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM,
|
||||
NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||
"-100", COLOR_THEME_SECONDARY1 | CENTERED);
|
||||
"-100", COLOR_THEME_SECONDARY1_INDEX, CENTERED);
|
||||
i += 1;
|
||||
}
|
||||
if ((start + count) == curvePointsCount) {
|
||||
@@ -145,7 +145,7 @@ class CurveDataEdit : public Window
|
||||
parent,
|
||||
{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM,
|
||||
NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||
"100", COLOR_THEME_SECONDARY1 | CENTERED);
|
||||
"100", COLOR_THEME_SECONDARY1_INDEX, CENTERED);
|
||||
}
|
||||
} else {
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
@@ -154,7 +154,7 @@ class CurveDataEdit : public Window
|
||||
rect_t{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM,
|
||||
NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||
std::to_string(-100 + (200 * (i + start)) / (curvePointsCount - 1)),
|
||||
COLOR_THEME_SECONDARY1 | CENTERED);
|
||||
COLOR_THEME_SECONDARY1_INDEX, CENTERED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ class CurveDataEdit : public Window
|
||||
|
||||
new StaticText(
|
||||
parent, {1, y + PAD_MEDIUM, PTNUM_X, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||
"Y", COLOR_THEME_PRIMARY1 | CENTERED);
|
||||
"Y", COLOR_THEME_PRIMARY1_INDEX, CENTERED);
|
||||
|
||||
// y value
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
|
||||
@@ -168,12 +168,12 @@ class ChannelFSCombo : public Window
|
||||
lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0);
|
||||
|
||||
edit = new ChannelFailsafeEdit(this, ch, vmin, vmax);
|
||||
auto btn = new TextButton(this, rect_t{}, LV_SYMBOL_SETTINGS, [=]() {
|
||||
new TextButton(this, rect_t{}, LV_SYMBOL_SETTINGS, [=]() {
|
||||
edit->toggle();
|
||||
return 0;
|
||||
});
|
||||
|
||||
btn = new TextButton(this, rect_t{}, LV_SYMBOL_COPY, [=]() {
|
||||
new TextButton(this, rect_t{}, LV_SYMBOL_COPY, [=]() {
|
||||
edit->copyChannel();
|
||||
return 0;
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ FileCarosell::FileCarosell(Window *parent, const rect_t &rect,
|
||||
{
|
||||
setWindowFlag(NO_FOCUS);
|
||||
|
||||
message = new StaticText(this, {0, rect.h/2, rect.w, EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, "", CENTERED | FONT(L) | COLOR_THEME_PRIMARY1);
|
||||
message = new StaticText(this, {0, rect.h/2, rect.w, EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, "", COLOR_THEME_PRIMARY1_INDEX, CENTERED | FONT(L));
|
||||
|
||||
setFileNames(fileNames);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ void FullScreenDialog::build()
|
||||
new StaticIcon(
|
||||
this, ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP,
|
||||
(type == WARNING_TYPE_INFO) ? ICON_BUSY : ICON_ERROR,
|
||||
COLOR_THEME_WARNING);
|
||||
COLOR_THEME_WARNING_INDEX);
|
||||
|
||||
std::string t;
|
||||
if (type == WARNING_TYPE_ALERT) {
|
||||
@@ -95,14 +95,14 @@ void FullScreenDialog::build()
|
||||
rect_t{ALERT_TITLE_LEFT, ALERT_TITLE_TOP,
|
||||
LCD_W - ALERT_TITLE_LEFT - PAD_MEDIUM,
|
||||
LCD_H - ALERT_TITLE_TOP - PAD_MEDIUM},
|
||||
t.c_str(), COLOR_THEME_WARNING | FONT(XL));
|
||||
t.c_str(), COLOR_THEME_WARNING_INDEX, FONT(XL));
|
||||
|
||||
messageLabel =
|
||||
new StaticText(this,
|
||||
rect_t{ALERT_MESSAGE_LEFT, ALERT_MESSAGE_TOP,
|
||||
LCD_W - ALERT_MESSAGE_LEFT - PAD_MEDIUM,
|
||||
LCD_H - ALERT_MESSAGE_TOP - PAD_MEDIUM},
|
||||
message.c_str(), COLOR_THEME_PRIMARY1 | FONT(BOLD));
|
||||
message.c_str(), COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD));
|
||||
|
||||
if (!action.empty()) {
|
||||
auto btn = new TextButton(
|
||||
|
||||
@@ -56,8 +56,7 @@ class FunctionSwitch : public Window
|
||||
std::string s(STR_CHAR_SWITCH);
|
||||
s += switchGetName(switchIndex + switchGetMaxSwitches());
|
||||
|
||||
new StaticText(this, {PAD_LARGE, PAD_MEDIUM, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, s,
|
||||
COLOR_THEME_PRIMARY1);
|
||||
new StaticText(this, {PAD_LARGE, PAD_MEDIUM, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, s);
|
||||
|
||||
new ModelTextEdit(this, {NM_X, 0, NM_W, 0},
|
||||
g_model.switchNames[switchIndex], LEN_SWITCH_NAME);
|
||||
@@ -146,7 +145,7 @@ class FunctionSwitch : public Window
|
||||
void checkEvents() override
|
||||
{
|
||||
setState();
|
||||
if (lastType != FSWITCH_CONFIG(switchIndex)) {
|
||||
if (lastType != (int)FSWITCH_CONFIG(switchIndex)) {
|
||||
lastType = FSWITCH_CONFIG(switchIndex);
|
||||
typeChoice->setValue(lastType);
|
||||
}
|
||||
@@ -163,8 +162,7 @@ class SwitchGroup : public Window
|
||||
padAll(PAD_TINY_GAP);
|
||||
|
||||
new StaticText(this, {0, PAD_MEDIUM, NM_W, EdgeTxStyles::PAGE_LINE_HEIGHT},
|
||||
STR_FUNCTION_SWITCH_GROUPS[groupIndex],
|
||||
COLOR_THEME_PRIMARY1);
|
||||
STR_FUNCTION_SWITCH_GROUPS[groupIndex]);
|
||||
|
||||
auto btn = new TextButton(
|
||||
this, {AO_X, 0, AO_W, 0}, STR_GROUP_ALWAYS_ON, [=]() -> int8_t {
|
||||
@@ -178,8 +176,7 @@ class SwitchGroup : public Window
|
||||
});
|
||||
btn->check(IS_FSWITCH_GROUP_ON(groupIndex));
|
||||
|
||||
new StaticText(this, {SL_X, PAD_MEDIUM, SL_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_SWITCH_STARTUP,
|
||||
COLOR_THEME_PRIMARY1);
|
||||
new StaticText(this, {SL_X, PAD_MEDIUM, SL_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_SWITCH_STARTUP);
|
||||
|
||||
startChoice = new Choice(
|
||||
this, {ST_X, 0, ST_W, 0}, STR_FSSWITCHES, 0,
|
||||
@@ -234,13 +231,13 @@ ModelFunctionSwitches::ModelFunctionSwitches() : Page(ICON_MODEL_SETUP)
|
||||
FlexGridLayout grid2(line_col_dsc2, line_row_dsc, PAD_TINY);
|
||||
|
||||
auto line = body->newLine(grid2);
|
||||
new StaticText(line, rect_t{}, STR_SWITCHES, COLOR_THEME_PRIMARY1);
|
||||
new StaticText(line, rect_t{}, STR_NAME, COLOR_THEME_PRIMARY1 | FONT(XS));
|
||||
new StaticText(line, rect_t{}, STR_SWITCHES);
|
||||
new StaticText(line, rect_t{}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
new StaticText(line, rect_t{}, STR_SWITCH_TYPE,
|
||||
COLOR_THEME_PRIMARY1 | FONT(XS));
|
||||
new StaticText(line, rect_t{}, STR_GROUP, COLOR_THEME_PRIMARY1 | FONT(XS));
|
||||
COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
new StaticText(line, rect_t{}, STR_GROUP, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
startupHeader = new StaticText(line, rect_t{}, STR_SWITCH_STARTUP,
|
||||
COLOR_THEME_PRIMARY1 | FONT(XS));
|
||||
COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
|
||||
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i += 1) {
|
||||
new FunctionSwitch(body, i);
|
||||
@@ -254,7 +251,7 @@ ModelFunctionSwitches::ModelFunctionSwitches() : Page(ICON_MODEL_SETUP)
|
||||
|
||||
line = body->newLine(grid1);
|
||||
|
||||
new StaticText(line, rect_t{}, STR_MORE_INFO, COLOR_THEME_PRIMARY1);
|
||||
new StaticText(line, rect_t{}, STR_MORE_INFO);
|
||||
|
||||
line = body->newLine(grid1);
|
||||
line->padBottom(PAD_LARGE);
|
||||
|
||||
@@ -64,8 +64,7 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, int32_t vmin,
|
||||
|
||||
num_field = new NumberEdit(
|
||||
this, {0, 0, NUM_EDIT_W, 0}, vmin, vmax, [=]() { return getValue() + voffset; },
|
||||
nullptr);
|
||||
num_field->setTextFlag(textFlags);
|
||||
nullptr, textFlags);
|
||||
num_field->setDefault(vdefault);
|
||||
|
||||
#if defined(GVARS)
|
||||
|
||||
@@ -51,8 +51,7 @@ class BTDetailsDialog : public BaseDialog
|
||||
[=]() {
|
||||
return std::string(bluetooth.localAddr[0] ? bluetooth.localAddr
|
||||
: "---");
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
});
|
||||
|
||||
// Remote MAC
|
||||
line = form->newLine(grid);
|
||||
@@ -62,8 +61,7 @@ class BTDetailsDialog : public BaseDialog
|
||||
[=]() {
|
||||
return std::string(bluetooth.distantAddr[0] ? bluetooth.distantAddr
|
||||
: "---");
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -92,9 +92,9 @@ HWPots::HWPots(Window* parent) :
|
||||
}
|
||||
});
|
||||
|
||||
new StaticText(this, {P_NM_X, -2, 0, 0}, STR_NAME, FONT(XS));
|
||||
new StaticText(this, {P_TYP_X, -2, 0, 0}, STR_TYPE, FONT(XS));
|
||||
new StaticText(this, {P_INV_X, -2, 0, 0}, STR_MENU_INVERT, FONT(XS));
|
||||
new StaticText(this, {P_NM_X, -2, 0, 0}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
new StaticText(this, {P_TYP_X, -2, 0, 0}, STR_TYPE, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
new StaticText(this, {P_INV_X, -2, 0, 0}, STR_MENU_INVERT, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
|
||||
coord_t yo = EdgeTxStyles::PAGE_LINE_HEIGHT - 2;
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ SerialConfigWindow::SerialConfigWindow(Window *parent, FlexGridLayout& grid)
|
||||
grid.setColSpan(2);
|
||||
auto line = parent->newLine(grid);
|
||||
line->padLeft(WARN_PADL);
|
||||
line->padBottom(WARN_PADB);
|
||||
new StaticText(line, rect_t{}, STR_TTL_WARNING, COLOR_THEME_WARNING);
|
||||
line->padBottom(PAD_MEDIUM);
|
||||
new StaticText(line, rect_t{}, STR_TTL_WARNING, COLOR_THEME_WARNING_INDEX);
|
||||
grid.setColSpan(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,5 +29,4 @@ class SerialConfigWindow
|
||||
SerialConfigWindow(Window *parent, FlexGridLayout& grid);
|
||||
|
||||
static LAYOUT_VAL(WARN_PADL, 20, 20);
|
||||
static LAYOUT_VAL(WARN_PADB, 6, 6);
|
||||
};
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#define MAX_LAYOUT_ZONES 10
|
||||
#define MAX_LAYOUT_OPTIONS 10
|
||||
|
||||
constexpr uint32_t LAYOUT_REFRESH = 1000 / 2; // 2 Hz
|
||||
|
||||
#if !defined(YAML_GENERATOR)
|
||||
typedef WidgetsContainerPersistentData<MAX_LAYOUT_ZONES, MAX_LAYOUT_OPTIONS>
|
||||
LayoutPersistentData;
|
||||
|
||||
@@ -67,8 +67,10 @@ SliderIcon::SliderIcon(Window* parent) :
|
||||
|
||||
MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx,
|
||||
bool isVertical) :
|
||||
Window(parent, rect), idx(idx), isVertical(isVertical)
|
||||
Window(parent, rect), isVertical(isVertical)
|
||||
{
|
||||
potIdx = adcGetInputOffset(ADC_INPUT_FLEX) + idx;
|
||||
|
||||
if (isVertical) {
|
||||
int sliderTicksCount = (height() - LayoutFactory::TRIM_SQUARE_SIZE) / SLIDER_TICK_SPACING;
|
||||
tickPoints = new lv_point_t[(sliderTicksCount + 1) * 2];
|
||||
@@ -76,10 +78,10 @@ MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx,
|
||||
lv_coord_t y = LayoutFactory::TRIM_SQUARE_SIZE / 2;
|
||||
for (uint8_t i = 0; i <= sliderTicksCount; i++) {
|
||||
if (i == 0 || i == sliderTicksCount / 2 || i == sliderTicksCount) {
|
||||
tickPoints[i * 2] = {SL_TK, y};
|
||||
tickPoints[i * 2] = {PAD_TINY, y};
|
||||
tickPoints[i * 2 + 1] = {SL_SZ, y};
|
||||
} else {
|
||||
tickPoints[i * 2] = {SL_TK + 2, y};
|
||||
tickPoints[i * 2] = {PAD_TINY + 2, y};
|
||||
tickPoints[i * 2 + 1] = {SL_SZ - 2, y};
|
||||
}
|
||||
auto line = lv_line_create(lvobj);
|
||||
@@ -94,10 +96,10 @@ MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx,
|
||||
lv_coord_t x = LayoutFactory::TRIM_SQUARE_SIZE / 2;
|
||||
for (uint8_t i = 0; i <= sliderTicksCount; i++) {
|
||||
if (i == 0 || i == sliderTicksCount / 2 || i == SLIDER_TICKS_COUNT) {
|
||||
tickPoints[i * 2] = {x, SL_TK};
|
||||
tickPoints[i * 2] = {x, PAD_TINY};
|
||||
tickPoints[i * 2 + 1] = {x, SL_SZ};
|
||||
} else {
|
||||
tickPoints[i * 2] = {x, SL_TK + 2};
|
||||
tickPoints[i * 2] = {x, PAD_TINY + 2};
|
||||
tickPoints[i * 2 + 1] = {x, SL_SZ - 2};
|
||||
}
|
||||
auto line = lv_line_create(lvobj);
|
||||
@@ -108,14 +110,8 @@ MainViewSlider::MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx,
|
||||
}
|
||||
|
||||
sliderIcon = new SliderIcon(this);
|
||||
coord_t x = 0, y = 0;
|
||||
if (isVertical)
|
||||
y = (height() - LayoutFactory::TRIM_SQUARE_SIZE) / 2;
|
||||
else
|
||||
y = (width() - LayoutFactory::TRIM_SQUARE_SIZE) / 2;
|
||||
lv_obj_set_pos(sliderIcon->getLvObj(), x, y);
|
||||
|
||||
checkEvents();
|
||||
setPos();
|
||||
}
|
||||
|
||||
void MainViewSlider::deleteLater(bool detach, bool trash)
|
||||
@@ -126,24 +122,27 @@ void MainViewSlider::deleteLater(bool detach, bool trash)
|
||||
}
|
||||
}
|
||||
|
||||
void MainViewSlider::setPos()
|
||||
{
|
||||
coord_t x = 0, y = 0;
|
||||
if (isVertical) {
|
||||
y = divRoundClosest((height() - LayoutFactory::TRIM_SQUARE_SIZE) * (-value + RESX),
|
||||
2 * RESX);
|
||||
} else {
|
||||
x = divRoundClosest((width() - LayoutFactory::TRIM_SQUARE_SIZE) * (value + RESX),
|
||||
2 * RESX);
|
||||
}
|
||||
lv_obj_set_pos(sliderIcon->getLvObj(), x, y);
|
||||
}
|
||||
|
||||
void MainViewSlider::checkEvents()
|
||||
{
|
||||
Window::checkEvents();
|
||||
|
||||
auto pot_idx = adcGetInputOffset(ADC_INPUT_FLEX) + idx;
|
||||
int16_t newValue = calibratedAnalogs[pot_idx];
|
||||
int16_t newValue = calibratedAnalogs[potIdx];
|
||||
if (value != newValue) {
|
||||
value = newValue;
|
||||
|
||||
coord_t x = 0, y = 0;
|
||||
if (isVertical) {
|
||||
y = divRoundClosest((height() - LayoutFactory::TRIM_SQUARE_SIZE) * (-value + RESX),
|
||||
2 * RESX);
|
||||
} else {
|
||||
x = divRoundClosest((width() - LayoutFactory::TRIM_SQUARE_SIZE) * (value + RESX),
|
||||
2 * RESX);
|
||||
}
|
||||
lv_obj_set_pos(sliderIcon->getLvObj(), x, y);
|
||||
setPos();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ class MainViewSlider : public Window
|
||||
public:
|
||||
MainViewSlider(Window* parent, const rect_t& rect, uint8_t idx,
|
||||
bool isVertical);
|
||||
void checkEvents() override;
|
||||
|
||||
static LAYOUT_VAL(SLIDER_TICKS_COUNT, 40, 30)
|
||||
static LAYOUT_VAL(SLIDER_TICK_SPACING, 4, 4)
|
||||
@@ -47,15 +46,18 @@ class MainViewSlider : public Window
|
||||
SLIDER_TICKS_COUNT * SLIDER_TICK_SPACING + LayoutFactory::TRIM_SQUARE_SIZE;
|
||||
|
||||
static LAYOUT_VAL(SL_SZ, 15, 15)
|
||||
static LAYOUT_VAL(SL_TK, 2, 2)
|
||||
|
||||
protected:
|
||||
uint8_t idx;
|
||||
int16_t value = -10000;
|
||||
uint8_t potIdx;
|
||||
int16_t value = 0;
|
||||
bool isVertical;
|
||||
SliderIcon* sliderIcon = nullptr;
|
||||
lv_point_t* tickPoints = nullptr;
|
||||
|
||||
void setPos();
|
||||
|
||||
void checkEvents() override;
|
||||
|
||||
void deleteLater(bool detach = true, bool trash = true) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -62,9 +62,9 @@ rect_t TopBar::getZone(unsigned int index) const
|
||||
coord_t x = MENU_HEADER_BUTTONS_LEFT + 1;
|
||||
|
||||
for (int i = 0; i < index; i += 1)
|
||||
x += (g_model.topbarWidgetWidth[i] * (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN));
|
||||
x += (g_model.topbarWidgetWidth[i] * (TOPBAR_ZONE_WIDTH + PAD_TINY));
|
||||
|
||||
coord_t size = ((g_model.topbarWidgetWidth[index] - 1) * (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN) + TOPBAR_ZONE_WIDTH);
|
||||
coord_t size = ((g_model.topbarWidgetWidth[index] - 1) * (TOPBAR_ZONE_WIDTH + PAD_TINY) + TOPBAR_ZONE_WIDTH);
|
||||
|
||||
if ((x + size) > LCD_W) size = LCD_W - x;
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@ class TopBar: public TopBarBase
|
||||
|
||||
static LAYOUT_VAL(TOPBAR_ZONE_WIDTH, 70, 70)
|
||||
static LAYOUT_VAL(TOPBAR_ZONE_VMARGIN, 3, 3)
|
||||
static LAYOUT_VAL(TOPBAR_ZONE_HMARGIN, 2, 2)
|
||||
static constexpr coord_t TOPBAR_ZONE_HEIGHT = EdgeTxStyles::MENU_HEADER_HEIGHT - 2 * TOPBAR_ZONE_VMARGIN;
|
||||
|
||||
static LAYOUT_VAL(HDR_DATE_XO, 48, 48)
|
||||
|
||||
@@ -45,9 +45,11 @@ class TrimIcon : public SliderIcon
|
||||
|
||||
bar1 = lv_line_create(lvobj);
|
||||
etx_obj_add_style(bar1, styles->div_line_white, LV_PART_MAIN);
|
||||
etx_obj_add_style(bar1, styles->div_line_black, LV_STATE_USER_1);
|
||||
lv_line_set_points(bar1, &barPoints[0], 2);
|
||||
bar2 = lv_line_create(lvobj);
|
||||
etx_obj_add_style(bar2, styles->div_line_white, LV_PART_MAIN);
|
||||
etx_obj_add_style(bar2, styles->div_line_black, LV_STATE_USER_1);
|
||||
lv_line_set_points(bar2, &barPoints[2], 2);
|
||||
|
||||
etx_bg_color(fill, COLOR_THEME_ACTIVE_INDEX, LV_STATE_USER_1);
|
||||
@@ -55,10 +57,15 @@ class TrimIcon : public SliderIcon
|
||||
|
||||
void setState(int value)
|
||||
{
|
||||
if (value < TRIM_MIN || value > TRIM_MAX)
|
||||
if (value < TRIM_MIN || value > TRIM_MAX) {
|
||||
lv_obj_add_state(fill, LV_STATE_USER_1);
|
||||
else
|
||||
lv_obj_add_state(bar1, LV_STATE_USER_1);
|
||||
lv_obj_add_state(bar2, LV_STATE_USER_1);
|
||||
} else {
|
||||
lv_obj_clear_state(fill, LV_STATE_USER_1);
|
||||
lv_obj_clear_state(bar1, LV_STATE_USER_1);
|
||||
lv_obj_clear_state(bar2, LV_STATE_USER_1);
|
||||
}
|
||||
|
||||
if (value >= 0)
|
||||
lv_obj_clear_flag(bar1, LV_OBJ_FLAG_HIDDEN);
|
||||
@@ -81,8 +88,6 @@ MainViewTrim::MainViewTrim(Window* parent, const rect_t& rect, uint8_t idx,
|
||||
bool isVertical) :
|
||||
Window(parent, rect), idx(idx), isVertical(isVertical)
|
||||
{
|
||||
setRange();
|
||||
|
||||
trimBar = lv_obj_create(lvobj);
|
||||
etx_solid_bg(trimBar, COLOR_THEME_SECONDARY1_INDEX);
|
||||
etx_obj_add_style(trimBar, styles->rounded, LV_PART_MAIN);
|
||||
@@ -99,26 +104,22 @@ MainViewTrim::MainViewTrim(Window* parent, const rect_t& rect, uint8_t idx,
|
||||
}
|
||||
|
||||
trimIcon = new TrimIcon(this, isVertical);
|
||||
coord_t x = 0, y = 0;
|
||||
if (isVertical)
|
||||
y = (height() - LayoutFactory::TRIM_SQUARE_SIZE) / 2;
|
||||
else
|
||||
y = (width() - LayoutFactory::TRIM_SQUARE_SIZE) / 2;
|
||||
lv_obj_set_pos(trimIcon->getLvObj(), x, y);
|
||||
|
||||
trimValue = new DynamicNumber<int16_t>(
|
||||
this, {0, 0, LayoutFactory::TRIM_SQUARE_SIZE, 12},
|
||||
[=]() { return divRoundClosest(abs(value) * 100, trimMax); },
|
||||
COLOR_THEME_PRIMARY2 | FONT(XXS) | CENTERED);
|
||||
COLOR_THEME_PRIMARY2_INDEX, FONT(XXS) | CENTERED);
|
||||
etx_solid_bg(trimValue->getLvObj(), COLOR_THEME_SECONDARY1_INDEX);
|
||||
trimValue->hide();
|
||||
|
||||
setRange();
|
||||
setPos();
|
||||
}
|
||||
|
||||
void MainViewTrim::setRange()
|
||||
{
|
||||
if (g_model.extendedTrims) {
|
||||
extendedTrims = g_model.extendedTrims;
|
||||
if (extendedTrims) {
|
||||
trimMin = TRIM_EXTENDED_MIN;
|
||||
trimMax = TRIM_EXTENDED_MAX;
|
||||
} else {
|
||||
@@ -193,10 +194,15 @@ void MainViewTrim::checkEvents()
|
||||
|
||||
int newValue = getTrimValue(mixerCurrentFlightMode, inputMappingConvertMode(idx));
|
||||
|
||||
setRange();
|
||||
newValue = min(max(newValue, trimMin), trimMax);
|
||||
bool update = false;
|
||||
|
||||
if (extendedTrims != g_model.extendedTrims) {
|
||||
update = true;
|
||||
setRange();
|
||||
newValue = limit(trimMin, newValue, trimMax);
|
||||
}
|
||||
|
||||
if (value != newValue || (g_model.displayTrims == DISPLAY_TRIMS_CHANGE &&
|
||||
if (update || value != newValue || (g_model.displayTrims == DISPLAY_TRIMS_CHANGE &&
|
||||
showChange && trimsDisplayTimer == 0)) {
|
||||
value = newValue;
|
||||
setPos();
|
||||
|
||||
@@ -39,6 +39,7 @@ class MainViewTrim : public Window
|
||||
bool isVertical;
|
||||
bool showChange = false;
|
||||
int trimMin = 0, trimMax = 0;
|
||||
bool extendedTrims = false;
|
||||
bool hidden = false;
|
||||
TrimIcon* trimIcon = nullptr;
|
||||
DynamicNumber<int16_t>* trimValue = nullptr;
|
||||
|
||||
@@ -50,8 +50,6 @@ static lv_disp_drv_t disp_drv;
|
||||
static lv_disp_t disp;
|
||||
#endif
|
||||
|
||||
static lv_area_t screen_area = {0, 0, LCD_W - 1, LCD_H - 1};
|
||||
|
||||
// Call backs
|
||||
static void (*lcd_wait_cb)(lv_disp_drv_t*) = nullptr;
|
||||
static void (*lcd_flush_cb)(lv_disp_drv_t*, uint16_t* buffer,
|
||||
@@ -222,8 +220,22 @@ void lcdInitDisplayDriver()
|
||||
lcdFront->setDrawCtx(draw_ctx);
|
||||
}
|
||||
|
||||
void lcdClear() { lcd->clear(); }
|
||||
|
||||
void lcdFlushed()
|
||||
{
|
||||
// its possible to get here before flushLcd is ever called.
|
||||
// so check for nullptr first. (Race condition if you put breakpoints in
|
||||
// startup code)
|
||||
if (refr_disp != nullptr) lv_disp_flush_ready(refr_disp);
|
||||
}
|
||||
|
||||
// Direct drawing - used by boot loader and battery charging state
|
||||
|
||||
void lcdInitDirectDrawing()
|
||||
{
|
||||
static lv_area_t screen_area = {0, 0, LCD_W - 1, LCD_H - 1};
|
||||
|
||||
lv_draw_ctx_t* draw_ctx = disp_drv.draw_ctx;
|
||||
draw_ctx->buf = disp_drv.draw_buf->buf_act;
|
||||
draw_ctx->buf_area = &screen_area;
|
||||
@@ -285,13 +297,3 @@ void lcdRefresh()
|
||||
lv_disp_t* d = _lv_refr_get_disp_refreshing();
|
||||
_draw_buf_flush(d);
|
||||
}
|
||||
|
||||
void lcdClear() { lcd->clear(); }
|
||||
|
||||
void lcdFlushed()
|
||||
{
|
||||
// its possible to get here before flushLcd is ever called.
|
||||
// so check for nullptr first. (Race condition if you put breakpoints in
|
||||
// startup code)
|
||||
if (refr_disp != nullptr) lv_disp_flush_ready(refr_disp);
|
||||
}
|
||||
|
||||
@@ -45,10 +45,11 @@ void lcdSetFlushCb(void (*cb)(lv_disp_drv_t *, uint16_t*, const rect_t&));
|
||||
// Init LVGL and its display driver
|
||||
void lcdInitDisplayDriver();
|
||||
|
||||
void lcdClear();
|
||||
|
||||
// Patch the draw context to allow for direct drawing
|
||||
void lcdInitDirectDrawing();
|
||||
|
||||
void lcdClear();
|
||||
|
||||
void lcdRefresh();
|
||||
|
||||
void lcdFlushed();
|
||||
|
||||
@@ -39,7 +39,7 @@ static const lv_obj_class_t input_mix_line_class = {
|
||||
.user_data = nullptr,
|
||||
.event_cb = nullptr,
|
||||
.width_def = LV_PCT(100),
|
||||
.height_def = LV_SIZE_CONTENT,
|
||||
.height_def = ListLineButton::BTN_H,
|
||||
.editable = LV_OBJ_CLASS_EDITABLE_INHERIT,
|
||||
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
|
||||
.instance_size = sizeof(lv_btn_t),
|
||||
|
||||
@@ -38,7 +38,7 @@ class ListLineButton : public ButtonBase
|
||||
virtual void refresh() = 0;
|
||||
|
||||
static LAYOUT_VAL(BTN_H, 29, 29)
|
||||
static constexpr coord_t GRP_W = LCD_W - PAD_MEDIUM * 2;
|
||||
static constexpr coord_t GRP_W = LCD_W - PAD_SMALL * 2;
|
||||
|
||||
protected:
|
||||
uint8_t index;
|
||||
@@ -64,7 +64,7 @@ class InputMixButtonBase : public ListLineButton
|
||||
static LAYOUT_VAL(FM_CANVAS_HEIGHT, 17, 17)
|
||||
static LAYOUT_VAL(FM_CANVAS_WIDTH, 90, 90)
|
||||
|
||||
static LAYOUT_VAL(BTN_W, 389, 229)
|
||||
static LAYOUT_VAL(BTN_W, 395, 235)
|
||||
static constexpr coord_t WGT_X = PAD_TINY;
|
||||
static constexpr coord_t WGT_Y = PAD_TINY;
|
||||
static LAYOUT_VAL(WGT_W, 50, 50)
|
||||
|
||||
@@ -43,7 +43,7 @@ class CurveButton : public Button
|
||||
strAppend(s, g_model.curves[index].name, LEN_CURVE_NAME);
|
||||
}
|
||||
title = new StaticText(this, {4, -1, width() - 12, TITLE_H + 1}, buf,
|
||||
COLOR_THEME_SECONDARY1 | CENTERED | FONT(BOLD));
|
||||
COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(BOLD));
|
||||
etx_txt_color(title->getLvObj(), COLOR_THEME_PRIMARY2_INDEX,
|
||||
LV_PART_MAIN | LV_STATE_USER_1);
|
||||
etx_solid_bg(title->getLvObj(), COLOR_THEME_SECONDARY2_INDEX);
|
||||
@@ -51,10 +51,10 @@ class CurveButton : public Button
|
||||
LV_PART_MAIN | LV_STATE_USER_1);
|
||||
|
||||
hdrLeft = new StaticIcon(this, 0, 0, ICON_ROUND_TITLE_LEFT,
|
||||
COLOR_THEME_SECONDARY2);
|
||||
COLOR_THEME_SECONDARY2_INDEX);
|
||||
hdrRight = new StaticIcon(this, width() - 8, 0,
|
||||
ICON_ROUND_TITLE_RIGHT,
|
||||
COLOR_THEME_SECONDARY2);
|
||||
COLOR_THEME_SECONDARY2_INDEX);
|
||||
|
||||
// Preview
|
||||
preview = new CurveRenderer(
|
||||
@@ -68,7 +68,7 @@ class CurveButton : public Button
|
||||
snprintf(buf, 32, "%s %d %s", STR_CURVE_TYPES[curve.type], 5 + curve.points,
|
||||
STR_PTS);
|
||||
new StaticText(this, {0, height() - INFO_H + 1, LV_PCT(100), 16}, buf,
|
||||
COLOR_THEME_SECONDARY1 | CENTERED | FONT(BOLD));
|
||||
COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(BOLD));
|
||||
}
|
||||
|
||||
void update() { preview->update(); }
|
||||
@@ -211,9 +211,9 @@ void ModelCurvesPage::build(Window *window)
|
||||
#endif
|
||||
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
window->setFlexLayout();
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO);
|
||||
|
||||
FlexGridLayout grid(col_dsc, row_dsc);
|
||||
FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY);
|
||||
|
||||
FormLine *line = nullptr;
|
||||
|
||||
|
||||
@@ -478,7 +478,7 @@ const lv_obj_class_t FlightModeBtn::fm_trim_value_class = {
|
||||
};
|
||||
|
||||
ModelFlightModesPage::ModelFlightModesPage() :
|
||||
PageTab(STR_MENUFLIGHTMODES, ICON_MODEL_FLIGHT_MODES, PAD_MEDIUM)
|
||||
PageTab(STR_MENUFLIGHTMODES, ICON_MODEL_FLIGHT_MODES)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ void ModelFlightModesPage::build(Window* form)
|
||||
|
||||
for (int i = 0; i < MAX_FLIGHT_MODES; i++) {
|
||||
auto btn = new FlightModeBtn(form, i);
|
||||
lv_obj_set_pos(btn->getLvObj(), PAD_MEDIUM, i * (FlightModeBtn::BTN_H + 3) + 4);
|
||||
lv_obj_set_pos(btn->getLvObj(), PAD_SMALL, i * (FlightModeBtn::BTN_H + 3) + 4);
|
||||
btn->setWidth(ListLineButton::GRP_W);
|
||||
|
||||
btn->setPressHandler([=]() {
|
||||
|
||||
@@ -554,7 +554,7 @@ void ModelGVarsPage::build(Window* window)
|
||||
if (modelFMEnabled()) {
|
||||
hdr = new GVarHeader(window->getParent());
|
||||
lv_obj_set_pos(hdr->getLvObj(), 0, TabsGroup::MENU_TITLE_TOP + TabsGroup::MENU_TITLE_HEIGHT);
|
||||
yo = GVarButton::HDR_H - 4;
|
||||
yo = GVarButton::HDR_H - 2;
|
||||
}
|
||||
|
||||
for (uint8_t index = 0; index < MAX_GVARS; index++) {
|
||||
|
||||
@@ -66,7 +66,7 @@ void ModelHeliPage::build(Window* form)
|
||||
GET_SET_DEFAULT(g_model.swashR.elevatorSource));
|
||||
|
||||
// Elevator weight
|
||||
auto w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1 | RIGHT);
|
||||
auto w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
|
||||
w->padRight(PAD_LARGE);
|
||||
new NumberEdit(line, rect_t{}, -100, 100,
|
||||
GET_SET_DEFAULT(g_model.swashR.elevatorWeight));
|
||||
@@ -78,7 +78,7 @@ void ModelHeliPage::build(Window* form)
|
||||
GET_SET_DEFAULT(g_model.swashR.aileronSource));
|
||||
|
||||
// Aileron weight
|
||||
w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1 | RIGHT);
|
||||
w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
|
||||
w->padRight(PAD_LARGE);
|
||||
new NumberEdit(line, rect_t{}, -100, 100,
|
||||
GET_SET_DEFAULT(g_model.swashR.aileronWeight));
|
||||
@@ -90,7 +90,7 @@ void ModelHeliPage::build(Window* form)
|
||||
GET_SET_DEFAULT(g_model.swashR.collectiveSource));
|
||||
|
||||
// Collective weight
|
||||
w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1 | RIGHT);
|
||||
w = new StaticText(line, rect_t{}, STR_WEIGHT, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
|
||||
w->padRight(PAD_LARGE);
|
||||
new NumberEdit(line, rect_t{}, -100, 100,
|
||||
GET_SET_DEFAULT(g_model.swashR.collectiveWeight));
|
||||
|
||||
@@ -304,7 +304,7 @@ void getsEdgeDelayParam(char* s, LogicalSwitchData* ls)
|
||||
class LogicalSwitchButton : public ListLineButton
|
||||
{
|
||||
public:
|
||||
LogicalSwitchButton(Window* parent, const rect_t& rect, int lsIndex) :
|
||||
LogicalSwitchButton(Window* parent, int lsIndex) :
|
||||
ListLineButton(parent, lsIndex)
|
||||
{
|
||||
setHeight(LS_BUTTON_H);
|
||||
@@ -510,7 +510,7 @@ class LogicalSwitchButton : public ListLineButton
|
||||
};
|
||||
|
||||
ModelLogicalSwitchesPage::ModelLogicalSwitchesPage() :
|
||||
PageTab(STR_MENULOGICALSWITCHES, ICON_MODEL_LOGICAL_SWITCHES, PAD_SMALL)
|
||||
PageTab(STR_MENULOGICALSWITCHES, ICON_MODEL_LOGICAL_SWITCHES)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -570,13 +570,8 @@ void ModelLogicalSwitchesPage::plusPopup(Window* window)
|
||||
|
||||
void ModelLogicalSwitchesPage::build(Window* window)
|
||||
{
|
||||
static const lv_coord_t l_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
|
||||
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO);
|
||||
|
||||
FlexGridLayout grid(l_col_dsc, row_dsc, PAD_TINY);
|
||||
|
||||
FormLine* line;
|
||||
bool hasEmptySwitch = false;
|
||||
|
||||
// Reset focusIndex after switching tabs
|
||||
@@ -588,10 +583,7 @@ void ModelLogicalSwitchesPage::build(Window* window)
|
||||
bool isActive = (ls->func != LS_FUNC_NONE);
|
||||
|
||||
if (isActive) {
|
||||
line = window->newLine(grid);
|
||||
|
||||
auto button = new LogicalSwitchButton(
|
||||
line, rect_t{0, 0, window->width() - 12, LogicalSwitchButton::LS_BUTTON_H}, i);
|
||||
auto button = new LogicalSwitchButton(window, i);
|
||||
|
||||
button->setPressHandler([=]() {
|
||||
Menu* menu = new Menu(window);
|
||||
@@ -652,9 +644,8 @@ void ModelLogicalSwitchesPage::build(Window* window)
|
||||
}
|
||||
|
||||
if (hasEmptySwitch) {
|
||||
line = window->newLine(grid);
|
||||
addButton =
|
||||
new TextButton(line, rect_t{0, 0, window->width() - 12, LogicalSwitchButton::LS_BUTTON_H},
|
||||
new TextButton(window, rect_t{0, 0, window->width() - 12, LogicalSwitchButton::LS_BUTTON_H},
|
||||
LV_SYMBOL_PLUS, [=]() {
|
||||
plusPopup(window);
|
||||
return 0;
|
||||
|
||||
@@ -35,9 +35,6 @@
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||
|
||||
// Overview grid
|
||||
static const lv_coord_t col_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
// Edit grid
|
||||
#if !PORTRAIT_LCD
|
||||
static const lv_coord_t e_col_dsc[] = {LV_GRID_FR(2), LV_GRID_FR(3),
|
||||
@@ -153,11 +150,11 @@ class ScriptEditWindow : public Page
|
||||
getSourceString(
|
||||
s, MIXSRC_FIRST_LUA + (idx * MAX_SCRIPT_OUTPUTS) + i);
|
||||
return std::string(s, sizeof(s) - 1);
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
});
|
||||
lbl->padLeft(PAD_LARGE);
|
||||
new DynamicNumber<int16_t>(
|
||||
line, rect_t{}, [=]() { return calcRESXto1000(so->value); }, PREC1);
|
||||
line, rect_t{}, [=]() { return calcRESXto1000(so->value); },
|
||||
COLOR_THEME_PRIMARY1_INDEX, PREC1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,16 +171,15 @@ class ScriptEditWindow : public Page
|
||||
class ScriptLineButton : public ListLineButton
|
||||
{
|
||||
public:
|
||||
ScriptLineButton(Window* parent, const rect_t& rect,
|
||||
ScriptLineButton(Window* parent,
|
||||
const ScriptData& scriptData,
|
||||
const ScriptInternalData* runtimeData, uint8_t index) :
|
||||
ListLineButton(parent, index),
|
||||
scriptData(scriptData),
|
||||
runtimeData(runtimeData)
|
||||
{
|
||||
#if PORTRAIT_LCD
|
||||
setHeight(EdgeTxStyles::UI_ELEMENT_HEIGHT);
|
||||
padTop(PAD_SMALL);
|
||||
#endif
|
||||
padLeft(PAD_TINY);
|
||||
padRight(PAD_TINY);
|
||||
lv_obj_set_layout(lvobj, LV_LAYOUT_GRID);
|
||||
@@ -274,8 +270,6 @@ class ScriptLineButton : public ListLineButton
|
||||
const ScriptInternalData* runtimeData;
|
||||
};
|
||||
|
||||
#define CM_BUTTON_H 34
|
||||
|
||||
ModelMixerScriptsPage::ModelMixerScriptsPage() :
|
||||
PageTab(STR_MENUCUSTOMSCRIPTS, ICON_MODEL_LUA_SCRIPTS)
|
||||
{
|
||||
@@ -291,15 +285,11 @@ void ModelMixerScriptsPage::rebuild(Window* window, int8_t focusIdx)
|
||||
|
||||
void ModelMixerScriptsPage::build(Window* window, int8_t focusIdx)
|
||||
{
|
||||
window->padAll(PAD_SMALL);
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO);
|
||||
|
||||
FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY);
|
||||
window->padBottom(PAD_LARGE);
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
|
||||
|
||||
int8_t scriptIdx = 0;
|
||||
for (int8_t idx = 0; idx < MAX_SCRIPTS; idx++) {
|
||||
auto line = window->newLine(grid);
|
||||
|
||||
ScriptInternalData* runtimeData = nullptr;
|
||||
ScriptData* const sd = &(g_model.scriptsData[idx]);
|
||||
ScriptInputsOutputs* const sio = &(scriptInputsOutputs[idx]);
|
||||
@@ -308,9 +298,7 @@ void ModelMixerScriptsPage::build(Window* window, int8_t focusIdx)
|
||||
runtimeData = &(scriptInternalData[scriptIdx++]);
|
||||
}
|
||||
|
||||
auto button = new ScriptLineButton(
|
||||
line, rect_t{0, 0, window->width() - 12, CM_BUTTON_H}, *sd, runtimeData,
|
||||
idx);
|
||||
auto button = new ScriptLineButton(window, *sd, runtimeData, idx);
|
||||
|
||||
button->setPressHandler([=]() -> uint8_t {
|
||||
Menu* const menu = new Menu(window);
|
||||
|
||||
@@ -43,7 +43,7 @@ class MPlexIcon : public Window
|
||||
} else if (mix->mltpx == MLTPX_REPL) {
|
||||
n = ICON_MPLEX_REPLACE;
|
||||
}
|
||||
icon = new StaticIcon(this, 0, 0, n, COLOR_THEME_SECONDARY1);
|
||||
icon = new StaticIcon(this, 0, 0, n, COLOR_THEME_SECONDARY1_INDEX);
|
||||
icon->center(width(), height());
|
||||
}
|
||||
|
||||
@@ -429,10 +429,10 @@ void ModelMixesPage::pasteMixAfter(uint8_t dst_idx)
|
||||
|
||||
void ModelMixesPage::build(Window * window)
|
||||
{
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
|
||||
|
||||
form = new Window(window, rect_t{});
|
||||
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);
|
||||
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
|
||||
|
||||
auto box = new Window(window, rect_t{});
|
||||
box->padAll(PAD_TINY);
|
||||
|
||||
@@ -98,7 +98,7 @@ class OutputLineButton : public ListLineButton
|
||||
lv_obj_set_pos(revert, REV_X, REV_Y);
|
||||
|
||||
curve =
|
||||
new StaticIcon(this, CRV_X, CRV_Y, ICON_TEXTLINE_CURVE, COLOR_THEME_SECONDARY1);
|
||||
new StaticIcon(this, CRV_X, CRV_Y, ICON_TEXTLINE_CURVE, COLOR_THEME_SECONDARY1_INDEX);
|
||||
|
||||
new OutputChannelBar(this, rect_t{BAR_X, PAD_MEDIUM, CH_BAR_WIDTH, CH_BAR_HEIGHT},
|
||||
index, false, false);
|
||||
@@ -230,7 +230,7 @@ class OutputLineButton : public ListLineButton
|
||||
};
|
||||
|
||||
ModelOutputsPage::ModelOutputsPage() :
|
||||
PageTab(STR_MENULIMITS, ICON_MODEL_OUTPUTS, PAD_TINY)
|
||||
PageTab(STR_MENULIMITS, ICON_MODEL_OUTPUTS)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ void ModelOutputsPage::build(Window* window)
|
||||
return 0;
|
||||
});
|
||||
|
||||
new StaticText(window, {EXLIM_X, EXLIM_Y, EXLIM_W, EXLIM_H}, STR_ELIMITS, RIGHT);
|
||||
new StaticText(window, {EXLIM_X, EXLIM_Y, EXLIM_W, EXLIM_H}, STR_ELIMITS, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
|
||||
new ToggleSwitch(window, {EXLIMCB_X, EXLIMCB_Y, EXLIMCB_W, EXLIMCB_H}, GET_SET_DEFAULT(g_model.extendedLimits));
|
||||
|
||||
for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {
|
||||
|
||||
@@ -31,7 +31,7 @@ class ModelOutputsPage : public PageTab
|
||||
ModelOutputsPage();
|
||||
void build(Window* window) override;
|
||||
|
||||
static constexpr coord_t ADD_TRIMS_X = PAD_MEDIUM;
|
||||
static constexpr coord_t ADD_TRIMS_X = PAD_SMALL;
|
||||
static constexpr coord_t ADD_TRIMS_Y = PAD_SMALL;
|
||||
static LAYOUT_VAL(ADD_TRIMS_W, (LCD_W / 2) - 10, LCD_W - 12)
|
||||
static constexpr coord_t ADD_TRIMS_H = EdgeTxStyles::UI_ELEMENT_HEIGHT;
|
||||
@@ -44,9 +44,9 @@ class ModelOutputsPage : public PageTab
|
||||
static LAYOUT_VAL(EXLIM_Y, 10, ADD_TRIMS_X + ADD_TRIMS_H + 8)
|
||||
static constexpr coord_t EXLIM_W = EXLIMCB_X - EXLIM_X - PAD_SMALL;
|
||||
static LAYOUT_VAL(EXLIM_H, 20, 20)
|
||||
static constexpr coord_t TRIMB_X = PAD_MEDIUM;
|
||||
static constexpr coord_t TRIMB_X = PAD_SMALL;
|
||||
static constexpr coord_t TRIMB_Y = EXLIMCB_Y + EXLIMCB_H + PAD_MEDIUM / 2;
|
||||
static constexpr coord_t TRIMB_W = LCD_W - PAD_MEDIUM * 2;
|
||||
static constexpr coord_t TRIMB_W = LCD_W - PAD_SMALL * 2;
|
||||
|
||||
protected:
|
||||
void editOutput(uint8_t channel, OutputLineButton* btn);
|
||||
|
||||
@@ -88,13 +88,13 @@ class ModelButton : public Button
|
||||
coord_t fo = (font == FONT(STD)) ? -3 : (font == FONT(XS)) ? -3 : -1;
|
||||
|
||||
modelName = new StaticText(this, {PAD_TINY, PAD_TINY, w, fh}, modelCell->modelName,
|
||||
CENTERED | COLOR_THEME_SECONDARY1 | font);
|
||||
COLOR_THEME_SECONDARY1_INDEX, CENTERED | font);
|
||||
etx_bg_color(modelName->getLvObj(), COLOR_THEME_ACTIVE_INDEX, LV_STATE_USER_1);
|
||||
etx_obj_add_style(modelName->getLvObj(), styles->bg_opacity_75, LV_STATE_USER_1);
|
||||
modelName->padTop(fo);
|
||||
} else {
|
||||
modelName = new StaticText(this, {PAD_TINY, PAD_SMALL, w, EdgeTxStyles::PAGE_LINE_HEIGHT}, modelCell->modelName,
|
||||
COLOR_THEME_SECONDARY1 | font);
|
||||
COLOR_THEME_SECONDARY1_INDEX, font);
|
||||
}
|
||||
lv_label_set_long_mode(modelName->getLvObj(), LV_LABEL_LONG_DOT);
|
||||
|
||||
@@ -173,7 +173,7 @@ class ModelButton : public Button
|
||||
errorMsg += ")";
|
||||
LcdFlags font = (modelLayouts[layout].font == FONT(STD)) ? FONT(XS) : FONT(XXS);
|
||||
new StaticText(this, {PAD_TINY, h / 2, w, getFontHeight(font)}, errorMsg,
|
||||
CENTERED | COLOR_THEME_SECONDARY1 | font);
|
||||
COLOR_THEME_SECONDARY1_INDEX, CENTERED | font);
|
||||
}
|
||||
|
||||
void checkEvents() override
|
||||
@@ -689,7 +689,7 @@ void ModelLabelsWindow::buildHead(Window *hdr)
|
||||
setTitle();
|
||||
|
||||
// new model button
|
||||
new TextButton(hdr, {LCD_W - NEW_BTN_W - PAD_LARGE, LAYOUT_BTN_YO, NEW_BTN_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_NEW, [=]() {
|
||||
new TextButton(hdr, {LCD_W - NEW_BTN_W - PAD_LARGE, PAD_MEDIUM, NEW_BTN_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_NEW, [=]() {
|
||||
auto menu = new Menu(this);
|
||||
menu->setTitle(STR_CREATE_NEW);
|
||||
menu->addLine(STR_NEW_MODEL, [=]() { newModel(); });
|
||||
@@ -697,7 +697,7 @@ void ModelLabelsWindow::buildHead(Window *hdr)
|
||||
return 0;
|
||||
});
|
||||
|
||||
mdlLayout = new ModelLayoutButton(this, LCD_W - LAYOUT_BTN_XO, LAYOUT_BTN_YO, g_eeGeneral.modelSelectLayout, [=]() {
|
||||
mdlLayout = new ModelLayoutButton(this, LCD_W - LAYOUT_BTN_XO, PAD_MEDIUM, g_eeGeneral.modelSelectLayout, [=]() {
|
||||
uint8_t l = mdlLayout->getLayout();
|
||||
l = (l + 1) & 3;
|
||||
mdlLayout->setLayout(l);
|
||||
@@ -711,7 +711,7 @@ void ModelLabelsWindow::buildHead(Window *hdr)
|
||||
void ModelLabelsWindow::buildBody(Window *window)
|
||||
{
|
||||
// Models List
|
||||
mdlselector = new ModelsPageBody(window, {MDLS_X, MDLS_Y, MDLS_W, MDLS_H});
|
||||
mdlselector = new ModelsPageBody(window, {MDLS_X, PAD_SMALL, MDLS_W, MDLS_H});
|
||||
mdlselector->setLblRefreshFunc([=]() { labelRefreshRequest(); });
|
||||
auto mdl_obj = mdlselector->getLvObj();
|
||||
lv_obj_set_style_max_width(mdl_obj, MDLS_W, LV_PART_MAIN);
|
||||
|
||||
@@ -78,7 +78,7 @@ static void viewOption(Window* parent, coord_t x, coord_t y,
|
||||
std::function<void(uint8_t)> setValue, bool globalState)
|
||||
{
|
||||
auto lbl = new StaticText(parent, {x + ModelSetupPage::OPTS_W + PAD_MEDIUM, y + PAD_SMALL + 1, 0, 0},
|
||||
STR_ADCFILTERVALUES[globalState ? 1 : 2], COLOR_THEME_SECONDARY1);
|
||||
STR_ADCFILTERVALUES[globalState ? 1 : 2], COLOR_THEME_SECONDARY1_INDEX);
|
||||
new Choice(parent, {x, y, ModelSetupPage::OPTS_W, 0}, STR_ADCFILTERVALUES, 0, 2, getValue,
|
||||
[=](int newValue) {
|
||||
setValue(newValue);
|
||||
|
||||
@@ -350,7 +350,7 @@ class USBChannelEditWindow : public Page
|
||||
line->padBottom(PAD_ZERO);
|
||||
collisionText =
|
||||
new StaticText(line, rect_t{}, "",
|
||||
FONT(BOLD) | COLOR_THEME_PRIMARY2 | CENTERED);
|
||||
COLOR_THEME_PRIMARY2_INDEX, FONT(BOLD) | CENTERED);
|
||||
etx_bg_color(collisionText->getLvObj(), COLOR_THEME_WARNING_INDEX);
|
||||
lv_obj_set_grid_cell(collisionText->getLvObj(), LV_GRID_ALIGN_STRETCH, 0,
|
||||
USBCH_COLS, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
@@ -400,7 +400,7 @@ class USBChannelLineButton : public ListLineButton
|
||||
|
||||
m_inverse =
|
||||
new StaticIcon(this, 0, 0, ICON_CHAN_MONITOR_INVERTED,
|
||||
COLOR_THEME_SECONDARY1);
|
||||
COLOR_THEME_SECONDARY1_INDEX);
|
||||
lv_obj_set_grid_cell(m_inverse->getLvObj(), LV_GRID_ALIGN_START, 1, 1,
|
||||
LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
|
||||
@@ -531,7 +531,7 @@ ModelUSBJoystickPage::ModelUSBJoystickPage() : Page(ICON_MODEL_USB)
|
||||
line = body->newLine(grid);
|
||||
|
||||
_CircCoutoutLabel = new StaticText(
|
||||
line, rect_t{}, STR_USBJOYSTICK_CIRC_COUTOUT, COLOR_THEME_PRIMARY1);
|
||||
line, rect_t{}, STR_USBJOYSTICK_CIRC_COUTOUT);
|
||||
_CircCoutout =
|
||||
new Choice(line, rect_t{}, STR_VUSBJOYSTICK_CIRC_COUTOUT, 0, USBJOYS_LAST,
|
||||
GET_DEFAULT(g_model.usbJoystickCircularCut),
|
||||
|
||||
@@ -554,7 +554,7 @@ void ModuleWindow::startRSSIDialog(std::function<void()> closeHandler)
|
||||
return std::to_string((int)TELEMETRY_RSSI()) + getRxStatLabels()->unit;
|
||||
},
|
||||
getRxStatLabels()->label, 50,
|
||||
COLOR_THEME_SECONDARY1 | CENTERED | FONT(XL));
|
||||
COLOR_THEME_SECONDARY1_INDEX, CENTERED | FONT(XL));
|
||||
|
||||
rssiDialog->setCloseHandler([this, closeHandler]() {
|
||||
rangeButton->check(false);
|
||||
|
||||
@@ -52,7 +52,7 @@ class MPMProtoOption : public FormLine {
|
||||
edit = new NumberEdit(box, rect_t{}, 0, 0, nullptr);
|
||||
cb = new ToggleSwitch(box, rect_t{}, nullptr, nullptr);
|
||||
rssi = new DynamicNumber<uint16_t>(
|
||||
box, rect_t{}, [] { return (uint16_t)TELEMETRY_RSSI(); }, 0,
|
||||
box, rect_t{}, [] { return (uint16_t)TELEMETRY_RSSI(); }, COLOR_THEME_PRIMARY1_INDEX, 0,
|
||||
getRxStatLabels()->label, getRxStatLabels()->unit);
|
||||
rssi->padTop(PAD_SMALL);
|
||||
}
|
||||
@@ -345,8 +345,7 @@ MultimoduleSettings::MultimoduleSettings(Window* parent,
|
||||
char msg[64] = "";
|
||||
getModuleStatusString(moduleIdx, msg);
|
||||
return std::string(msg);
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
});
|
||||
|
||||
st_line = new MPMSubtype(this, grid, moduleIdx);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ PageHeader::PageHeader(Window* parent, EdgeTxIcon icon) :
|
||||
title = new StaticText(this,
|
||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP,
|
||||
LCD_W - PAGE_TITLE_LEFT, EdgeTxStyles::PAGE_LINE_HEIGHT},
|
||||
"", COLOR_THEME_PRIMARY2);
|
||||
"", COLOR_THEME_PRIMARY2_INDEX);
|
||||
}
|
||||
|
||||
PageHeader::PageHeader(Window* parent, const char* iconFile) :
|
||||
@@ -52,7 +52,7 @@ PageHeader::PageHeader(Window* parent, const char* iconFile) :
|
||||
title = new StaticText(this,
|
||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP,
|
||||
LCD_W - PAGE_TITLE_LEFT, EdgeTxStyles::PAGE_LINE_HEIGHT},
|
||||
"", COLOR_THEME_PRIMARY2);
|
||||
"", COLOR_THEME_PRIMARY2_INDEX);
|
||||
}
|
||||
|
||||
StaticText* PageHeader::setTitle2(std::string txt)
|
||||
@@ -61,7 +61,7 @@ StaticText* PageHeader::setTitle2(std::string txt)
|
||||
title2 = new StaticText(this,
|
||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + EdgeTxStyles::PAGE_LINE_HEIGHT,
|
||||
LCD_W - PAGE_TITLE_LEFT, EdgeTxStyles::PAGE_LINE_HEIGHT},
|
||||
"", COLOR_THEME_PRIMARY2);
|
||||
"", COLOR_THEME_PRIMARY2_INDEX);
|
||||
}
|
||||
title2->setText(std::move(txt));
|
||||
return title2;
|
||||
|
||||
@@ -151,11 +151,11 @@ PreviewWindow::PreviewWindow(Window *window, rect_t rect,
|
||||
etx_solid_bg(topbar->getLvObj(), COLOR_THEME_SECONDARY1_INDEX);
|
||||
|
||||
new StaticIcon(topbar, ICON_X1, ICON_Y, ICON_RADIO,
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
new StaticIcon(topbar, ICON_X2, ICON_Y, ICON_RADIO_TOOLS,
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
new StaticIcon(topbar, ICON_X3, ICON_Y, ICON_RADIO_SETUP,
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
|
||||
new StaticText(this, {ICON_X1, CBT_Y, CBT_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_THEME_CHECKBOX);
|
||||
new ThemedCheckBox(this, {CB1_X, CB_Y, CB_W, 0}, true);
|
||||
@@ -166,9 +166,9 @@ PreviewWindow::PreviewWindow(Window *window, rect_t rect,
|
||||
new MainViewTrim(this, {ICON_X1, TRIM_Y, MainViewSlider::HORIZONTAL_SLIDERS_WIDTH, TRIM_H}, 0, false);
|
||||
new MainViewSlider(this, {ICON_X1, SLIDER_Y, MainViewSlider::HORIZONTAL_SLIDERS_WIDTH, TRIM_H}, 0, false);
|
||||
new StaticText(this, {ICON_X1, TXT1_Y, TXT_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_THEME_WARNING,
|
||||
COLOR_THEME_WARNING);
|
||||
COLOR_THEME_WARNING_INDEX);
|
||||
new StaticText(this, {ICON_X1, TXT2_Y, TXT_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_THEME_DISABLED,
|
||||
COLOR_THEME_DISABLED);
|
||||
COLOR_THEME_DISABLED_INDEX);
|
||||
|
||||
new ThemedTextEdit(this, {ICON_X1, EDT_Y, TXT_W, 0}, STR_THEME_EDIT, true);
|
||||
new ThemedTextEdit(this, {EDT2_X, EDT_Y, TXT_W, 0}, STR_THEME_FOCUS, false);
|
||||
|
||||
@@ -46,6 +46,7 @@ class StickCalibrationWindow : public Window
|
||||
{
|
||||
new StaticLZ4Image(this, 0, 0, (LZ4Bitmap *)stick_background);
|
||||
calibStick = new StaticLZ4Image(this, 0, 0, (LZ4Bitmap *)stick_pointer);
|
||||
checkEvents();
|
||||
}
|
||||
|
||||
void checkEvents() override
|
||||
@@ -103,10 +104,7 @@ void RadioCalibrationPage::buildBody(Window *window)
|
||||
3, 2);
|
||||
}
|
||||
|
||||
std::unique_ptr<ViewMainDecoration> deco(new ViewMainDecoration(window));
|
||||
deco->setTrimsVisible(false);
|
||||
deco->setSlidersVisible(true);
|
||||
deco->setFlightModeVisible(false);
|
||||
std::unique_ptr<ViewMainDecoration> deco(new ViewMainDecoration(window, false, true, false));
|
||||
|
||||
#if defined(PCBNV14) || defined(PCBPL18)
|
||||
new TextButton(window, {LCD_W - 120, LCD_H - 140, 90, 40}, "Next",
|
||||
|
||||
@@ -92,13 +92,11 @@ class AnaViewWindow : public Window
|
||||
line, rect_t{},
|
||||
[=]() {
|
||||
return std::to_string((int16_t)calibratedAnalogs[i] * 25 / 256);
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
});
|
||||
etx_obj_add_style(lbl->getLvObj(), styles->text_align_right, LV_PART_MAIN);
|
||||
|
||||
lbl = new DynamicText(
|
||||
line, rect_t{}, [=]() { return std::to_string((int16_t)column3(i)); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
line, rect_t{}, [=]() { return std::to_string((int16_t)column3(i)); });
|
||||
etx_obj_add_style(lbl->getLvObj(), styles->text_align_right, LV_PART_MAIN);
|
||||
|
||||
if (column4size() > 0) {
|
||||
@@ -107,8 +105,7 @@ class AnaViewWindow : public Window
|
||||
[=]() {
|
||||
return std::string(column4prefix()) +
|
||||
std::to_string((int16_t)column4(i));
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
});
|
||||
etx_obj_add_style(lbl->getLvObj(), (column4size() == 2) ? styles->text_align_left : styles->text_align_right, LV_PART_MAIN);
|
||||
#if !PORTRAIT_LCD
|
||||
lv_obj_set_grid_cell(lbl->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
||||
@@ -125,8 +122,7 @@ class AnaViewWindow : public Window
|
||||
if (column5size() > 0) {
|
||||
lbl = new DynamicText(
|
||||
line, rect_t{},
|
||||
[=]() { return std::to_string((int16_t)column5(i)); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
[=]() { return std::to_string((int16_t)column5(i)); });
|
||||
etx_obj_add_style(lbl->getLvObj(), styles->text_align_left, LV_PART_MAIN);
|
||||
} else {
|
||||
grid.nextCell();
|
||||
@@ -182,8 +178,7 @@ class AnaCalibratedViewWindow : public AnaViewWindow
|
||||
std::to_string(rawTouchState.x) + " : " +
|
||||
std::to_string(rawTouchState.y);
|
||||
return std::string("");
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
});
|
||||
lv_obj_set_grid_cell(lbl->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 5,
|
||||
LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
|
||||
@@ -192,7 +187,7 @@ class AnaCalibratedViewWindow : public AnaViewWindow
|
||||
auto lbl2 = new StaticText(
|
||||
line, rect_t{},
|
||||
std::string("Touch GT911 FW ver: ") + std::to_string(touchGT911fwver),
|
||||
COLOR_THEME_PRIMARY1);
|
||||
COLOR_THEME_PRIMARY1_INDEX);
|
||||
lv_obj_set_grid_cell(lbl2->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 5,
|
||||
LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class GhostModuleConfigWindow : public Window
|
||||
for (int i = 0; i < GHST_MENU_LINES; i += 1) {
|
||||
menuLines[i][0] = new StaticText(
|
||||
this, {xOffset, yOffset + i * lineSpacing, LV_SIZE_CONTENT, h}, "",
|
||||
FONT(L));
|
||||
COLOR_THEME_PRIMARY1_INDEX, FONT(L));
|
||||
etx_txt_color(menuLines[i][0]->getLvObj(), COLOR_THEME_SECONDARY1_INDEX,
|
||||
LV_PART_MAIN);
|
||||
etx_solid_bg(menuLines[i][0]->getLvObj(), COLOR_THEME_FOCUS_INDEX,
|
||||
@@ -49,7 +49,7 @@ class GhostModuleConfigWindow : public Window
|
||||
|
||||
menuLines[i][1] = new StaticText(
|
||||
this, {xOffset2, yOffset + i * lineSpacing, LV_SIZE_CONTENT, h}, "",
|
||||
FONT(L));
|
||||
COLOR_THEME_PRIMARY1_INDEX, FONT(L));
|
||||
etx_txt_color(menuLines[i][1]->getLvObj(), COLOR_THEME_SECONDARY1_INDEX,
|
||||
LV_PART_MAIN);
|
||||
etx_solid_bg(menuLines[i][1]->getLvObj(), COLOR_THEME_FOCUS_INDEX,
|
||||
|
||||
@@ -138,8 +138,8 @@ static SetupLineDef setupLines[] = {
|
||||
// RTC Batt display
|
||||
new DynamicNumber<uint16_t>(
|
||||
parent,
|
||||
{x + ToggleSwitch::TOGGLE_W + PAD_LARGE, y + PAD_SMALL + 1, 0, 0},
|
||||
[] { return getRTCBatteryVoltage(); }, COLOR_THEME_PRIMARY1 | PREC2,
|
||||
{x + ToggleSwitch::TOGGLE_W + PAD_SMALL, y + PAD_SMALL + 1, 0, 0},
|
||||
[] { return getRTCBatteryVoltage(); }, COLOR_THEME_PRIMARY1_INDEX, PREC2,
|
||||
"", "V");
|
||||
}
|
||||
},
|
||||
@@ -165,7 +165,6 @@ void RadioHardwarePage::build(Window* window)
|
||||
{
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
|
||||
|
||||
// TODO: sub-title?
|
||||
SetupLine::showLines(window, 0, SubPage::EDT_X, padding, setupLines, DIM(setupLines));
|
||||
|
||||
FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY);
|
||||
|
||||
@@ -574,7 +574,7 @@ static void viewOption(Window* parent, coord_t x, coord_t y,
|
||||
std::string s(STR_MODEL);
|
||||
s += " - ";
|
||||
s += STR_ADCFILTERVALUES[modelOption];
|
||||
new StaticText(parent, {x + ToggleSwitch::TOGGLE_W + PAD_MEDIUM, y + PAD_SMALL + 1, 0, 0}, s.c_str(), COLOR_THEME_SECONDARY1);
|
||||
new StaticText(parent, {x + ToggleSwitch::TOGGLE_W + PAD_MEDIUM, y + PAD_SMALL + 1, 0, 0}, s.c_str(), COLOR_THEME_SECONDARY1_INDEX);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,9 @@
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_GENERAL)
|
||||
|
||||
constexpr coord_t SPECTRUM_HEIGHT = 180;
|
||||
constexpr coord_t SCALE_HEIGHT = 15;
|
||||
constexpr coord_t FOOTER_HEIGHT = 32;
|
||||
|
||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1),
|
||||
LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||
constexpr coord_t SPECTRUM_HEIGHT = LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT - SCALE_HEIGHT - FOOTER_HEIGHT;
|
||||
|
||||
coord_t getAverage(uint8_t number, const uint8_t* value)
|
||||
{
|
||||
@@ -49,15 +45,7 @@ class SpectrumFooterWindow : public Window
|
||||
SpectrumFooterWindow(Window* parent, const rect_t& rect, int moduleIdx) :
|
||||
Window(parent, rect)
|
||||
{
|
||||
setFlexLayout();
|
||||
padAll(PAD_ZERO);
|
||||
padLeft(PAD_SMALL);
|
||||
padRight(PAD_SMALL);
|
||||
|
||||
FlexGridLayout grid(col_dsc, row_dsc);
|
||||
|
||||
auto line = newLine(grid);
|
||||
line->padAll(PAD_ZERO);
|
||||
|
||||
if (isModuleMultimodule(moduleIdx)) {
|
||||
char label[16];
|
||||
@@ -65,18 +53,18 @@ class SpectrumFooterWindow : public Window
|
||||
// Frequency
|
||||
sprintf(label, "T: %dMHz",
|
||||
int(reusableBuffer.spectrumAnalyser.freq / 1000000));
|
||||
(new StaticText(line, rect_t{0, 0, lv_pct(30), FOOTER_HEIGHT}, label))
|
||||
(new StaticText(this, rect_t{PAD_TINY, 0, FLD_W, FOOTER_HEIGHT}, label))
|
||||
->padTop(PAD_MEDIUM);
|
||||
|
||||
// Span
|
||||
sprintf(label, "S: %dMHz",
|
||||
int(reusableBuffer.spectrumAnalyser.span / 1000000));
|
||||
(new StaticText(line, rect_t{0, 0, lv_pct(30), FOOTER_HEIGHT}, label))
|
||||
(new StaticText(this, rect_t{PAD_TINY + FLD_W, 0, FLD_W, FOOTER_HEIGHT}, label))
|
||||
->padTop(PAD_MEDIUM);
|
||||
} else {
|
||||
// Frequency
|
||||
auto freq = new NumberEdit(
|
||||
line, rect_t{0, 0, lv_pct(30), FOOTER_HEIGHT},
|
||||
this, rect_t{PAD_TINY, 0, FLD_W, 0},
|
||||
reusableBuffer.spectrumAnalyser.freqMin,
|
||||
reusableBuffer.spectrumAnalyser.freqMax,
|
||||
GET_DEFAULT(reusableBuffer.spectrumAnalyser.freq / 1000000),
|
||||
@@ -86,7 +74,7 @@ class SpectrumFooterWindow : public Window
|
||||
|
||||
// Span
|
||||
auto span = new NumberEdit(
|
||||
line, rect_t{0, 0, lv_pct(30), FOOTER_HEIGHT}, 1,
|
||||
this, rect_t{PAD_TINY + FLD_W, 0, FLD_W, 0}, 1,
|
||||
reusableBuffer.spectrumAnalyser.spanMax,
|
||||
GET_DEFAULT(reusableBuffer.spectrumAnalyser.span / 1000000),
|
||||
SET_VALUE(reusableBuffer.spectrumAnalyser.span, newValue * 1000000));
|
||||
@@ -96,7 +84,7 @@ class SpectrumFooterWindow : public Window
|
||||
|
||||
// Tracker
|
||||
auto tracker = new NumberEdit(
|
||||
line, rect_t{0, 0, lv_pct(30), LV_SIZE_CONTENT},
|
||||
this, rect_t{(PAD_TINY + FLD_W) * 2, 0, FLD_W, FOOTER_HEIGHT},
|
||||
(reusableBuffer.spectrumAnalyser.freq -
|
||||
reusableBuffer.spectrumAnalyser.span / 2) /
|
||||
1000000,
|
||||
@@ -109,6 +97,8 @@ class SpectrumFooterWindow : public Window
|
||||
tracker->setPrefix("T: ");
|
||||
tracker->setDefault(reusableBuffer.spectrumAnalyser.freqDefault);
|
||||
}
|
||||
|
||||
static constexpr coord_t FLD_W = (LCD_W - PAD_TINY * 4) / 3;
|
||||
};
|
||||
|
||||
class SpectrumScaleWindow : public Window
|
||||
@@ -132,8 +122,8 @@ class SpectrumScaleWindow : public Window
|
||||
int x = (frequency - startFreq) / reusableBuffer.spectrumAnalyser.step;
|
||||
if (x >= LCD_W - 1) break;
|
||||
formatNumberAsString(s, 16, frequency / 1000000, 16);
|
||||
new StaticText(this, {x - 16, 0, 32, 15}, s,
|
||||
FONT(XS) | CENTERED | COLOR_THEME_PRIMARY1);
|
||||
new StaticText(this, {x - 16, 0, 32, SCALE_HEIGHT}, s,
|
||||
COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | CENTERED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +183,7 @@ class SpectrumWindow : public Window
|
||||
|
||||
warning = new StaticText(
|
||||
this, {0, height() / 2 - 20, lv_pct(100), LV_SIZE_CONTENT},
|
||||
STR_TURN_OFF_RECEIVER, COLOR_THEME_PRIMARY1 | CENTERED | FONT(XL));
|
||||
STR_TURN_OFF_RECEIVER, COLOR_THEME_PRIMARY1_INDEX, CENTERED | FONT(XL));
|
||||
warning->show(TELEMETRY_STREAMING());
|
||||
}
|
||||
|
||||
@@ -331,8 +321,8 @@ void RadioSpectrumAnalyser::checkEvents()
|
||||
limit<int>(0, offset / reusableBuffer.spectrumAnalyser.step, width() - 1);
|
||||
if (x != trackX) {
|
||||
trackX = x;
|
||||
trackPts[0] = {(lv_coord_t)x, 45};
|
||||
trackPts[1] = {(lv_coord_t)x, (lv_coord_t)(height() - 32)};
|
||||
trackPts[0] = {(lv_coord_t)x, EdgeTxStyles::MENU_HEADER_HEIGHT};
|
||||
trackPts[1] = {(lv_coord_t)x, (lv_coord_t)(height() - FOOTER_HEIGHT)};
|
||||
lv_line_set_points(trackLine, trackPts, 2);
|
||||
}
|
||||
Page::checkEvents();
|
||||
|
||||
@@ -272,9 +272,12 @@ class ColorEditPage : public Page
|
||||
|
||||
r.h = colForm->height() - COLOR_BOX_HEIGHT - 4;
|
||||
|
||||
uint32_t color = _theme->getColorEntryByIndex(_indexOfColor)->colorValue;
|
||||
|
||||
_colorEditor = new ColorEditor(
|
||||
colForm, r, _theme->getColorEntryByIndex(_indexOfColor)->colorValue,
|
||||
colForm, r, COLOR2FLAGS(color) | RGB_FLAG,
|
||||
[=](uint32_t rgb) {
|
||||
rgb = COLOR_VAL(rgb);
|
||||
_theme->setColor(_indexOfColor, rgb);
|
||||
if (_colorSquare != nullptr) {
|
||||
_colorSquare->setColor(rgb);
|
||||
@@ -290,12 +293,12 @@ class ColorEditPage : public Page
|
||||
r.w = COLOR_BOX_WIDTH;
|
||||
r.h = COLOR_BOX_HEIGHT;
|
||||
_colorSquare = new ColorSwatch(
|
||||
colBoxForm, r, _theme->getColorEntryByIndex(_indexOfColor)->colorValue);
|
||||
colBoxForm, r, color);
|
||||
|
||||
// hexBox
|
||||
r.w = HEX_STR_W;
|
||||
_hexBox = new StaticText(colBoxForm, r, "", COLOR_THEME_PRIMARY1 | FONT(L) | RIGHT);
|
||||
setHexStr(_theme->getColorEntryByIndex(_indexOfColor)->colorValue);
|
||||
_hexBox = new StaticText(colBoxForm, r, "", COLOR_THEME_PRIMARY1_INDEX, FONT(L) | RIGHT);
|
||||
setHexStr(color);
|
||||
}
|
||||
|
||||
void buildHead(PageHeader *window)
|
||||
|
||||
@@ -149,10 +149,12 @@ static void run_spektrum_int(Window* parent, const std::string&)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_EXTERNAL_MODULE)
|
||||
static void run_spektrum_ext(Window* parent, const std::string&)
|
||||
{
|
||||
new RadioSpectrumAnalyser(EXTERNAL_MODULE);
|
||||
}
|
||||
#endif
|
||||
#endif // defined(PXX2) || defined(MULTIMODULE)
|
||||
|
||||
#if defined(INTERNAL_MODULE_PXX2)
|
||||
@@ -196,6 +198,13 @@ void RadioToolsPage::rebuild(Window* window)
|
||||
|
||||
std::list<ToolEntry> tools;
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
bool intSpecAnalyser = false;
|
||||
#endif
|
||||
#if defined(HARDWARE_EXTERNAL_MODULE)
|
||||
bool extSpecAnalyser = false;
|
||||
#endif
|
||||
|
||||
#if defined(PXX2)
|
||||
auto hwSettings = &reusableBuffer.hardwareAndSettings;
|
||||
|
||||
@@ -204,8 +213,7 @@ void RadioToolsPage::rebuild(Window* window)
|
||||
// PXX2 modules tools
|
||||
if (isPXX2ModuleOptionAvailable(intHwSettings->information.modelID,
|
||||
MODULE_OPTION_SPECTRUM_ANALYSER)) {
|
||||
tools.emplace_back(
|
||||
ToolEntry{STR_SPECTRUM_ANALYSER_INT, {}, run_spektrum_int});
|
||||
intSpecAnalyser = true;
|
||||
}
|
||||
if (isPXX2ModuleOptionAvailable(intHwSettings->information.modelID,
|
||||
MODULE_OPTION_POWER_METER)) {
|
||||
@@ -216,25 +224,32 @@ void RadioToolsPage::rebuild(Window* window)
|
||||
auto extHwSettings = &hwSettings->modules[EXTERNAL_MODULE];
|
||||
if (isPXX2ModuleOptionAvailable(extHwSettings->information.modelID,
|
||||
MODULE_OPTION_SPECTRUM_ANALYSER)) {
|
||||
tools.emplace_back(
|
||||
ToolEntry{STR_SPECTRUM_ANALYSER_EXT, {}, run_spektrum_ext});
|
||||
extSpecAnalyser = true;
|
||||
}
|
||||
#endif // defined(PXX2)
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE) && defined(MULTIMODULE)
|
||||
if (g_eeGeneral.internalModule == MODULE_TYPE_MULTIMODULE) {
|
||||
tools.emplace_back(
|
||||
ToolEntry{STR_SPECTRUM_ANALYSER_INT, {}, run_spektrum_int});
|
||||
intSpecAnalyser = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PXX2) || defined(MULTIMODULE)
|
||||
if (isModuleMultimodule(EXTERNAL_MODULE)) {
|
||||
tools.emplace_back(
|
||||
ToolEntry{STR_SPECTRUM_ANALYSER_EXT, {}, run_spektrum_ext});
|
||||
extSpecAnalyser = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
if (intSpecAnalyser)
|
||||
tools.emplace_back(ToolEntry{STR_SPECTRUM_ANALYSER_INT, {}, run_spektrum_int});
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_EXTERNAL_MODULE)
|
||||
if (extSpecAnalyser)
|
||||
tools.emplace_back(ToolEntry{STR_SPECTRUM_ANALYSER_EXT, {}, run_spektrum_ext});
|
||||
#endif
|
||||
|
||||
#if defined(GHOST)
|
||||
if (isModuleGhost(EXTERNAL_MODULE)) {
|
||||
tools.emplace_back(ToolEntry{"Ghost module config", {}, run_ghost_config});
|
||||
|
||||
@@ -52,7 +52,7 @@ void RadioTrainerPage::build(Window* form)
|
||||
|
||||
if (SLAVE_MODE()) {
|
||||
form->setHeight(TabsGroup::MENU_BODY_HEIGHT);
|
||||
auto txt = new StaticText(form, rect_t{}, STR_SLAVE, FONT(L));
|
||||
auto txt = new StaticText(form, rect_t{}, STR_SLAVE, COLOR_THEME_PRIMARY1_INDEX, FONT(L));
|
||||
lv_obj_align(txt->getLvObj(), LV_ALIGN_CENTER, 0, 0);
|
||||
} else {
|
||||
FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY);
|
||||
@@ -78,7 +78,7 @@ void RadioTrainerPage::build(Window* form)
|
||||
line->padBottom(PAD_LARGE);
|
||||
#endif
|
||||
|
||||
LcdFlags flags = LEFT | COLOR_THEME_PRIMARY1;
|
||||
LcdFlags flags = LEFT;
|
||||
if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) flags |= PREC1;
|
||||
|
||||
new DynamicNumber<int16_t>(
|
||||
@@ -86,7 +86,7 @@ void RadioTrainerPage::build(Window* form)
|
||||
[=]() {
|
||||
return (trainerInput[i] - g_eeGeneral.trainer.calib[i]) * 2;
|
||||
},
|
||||
flags);
|
||||
COLOR_THEME_PRIMARY1_INDEX, flags);
|
||||
}
|
||||
|
||||
auto line = form->newLine(grid);
|
||||
|
||||
@@ -69,62 +69,62 @@ class ThemeView : public Window
|
||||
auto theme = tp->getCurrentTheme();
|
||||
|
||||
if (theme) {
|
||||
if (!details) {
|
||||
FlexGridLayout theme_grid(theme_col_dsc, theme_row_dsc);
|
||||
auto line = newLine(theme_grid);
|
||||
FlexGridLayout theme_grid(theme_col_dsc, theme_row_dsc, PAD_TINY);
|
||||
auto line = newLine(theme_grid);
|
||||
|
||||
details = new Window(line, rect_t{});
|
||||
// vertical flow layout
|
||||
lv_obj_set_flex_flow(details->getLvObj(), LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_pad_row(details->getLvObj(), 2, LV_PART_MAIN);
|
||||
details = new Window(line, rect_t{0, 0, 0, LV_SIZE_CONTENT});
|
||||
// vertical flow layout
|
||||
lv_obj_set_flex_flow(details->getLvObj(), LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_pad_row(details->getLvObj(), PAD_TINY, LV_PART_MAIN);
|
||||
|
||||
// make the object fill the grid cell
|
||||
lv_obj_set_style_grid_cell_x_align(details->getLvObj(),
|
||||
LV_GRID_ALIGN_STRETCH, 0);
|
||||
// make the object fill the grid cell
|
||||
lv_obj_set_style_grid_cell_x_align(details->getLvObj(),
|
||||
LV_GRID_ALIGN_STRETCH, 0);
|
||||
lv_obj_set_style_grid_cell_y_align(details->getLvObj(),
|
||||
LV_GRID_ALIGN_START, 0);
|
||||
|
||||
new StaticText(details, rect_t{}, STR_AUTHOR, COLOR_THEME_PRIMARY1 | FONT(BOLD));
|
||||
author = new StaticText(details, rect_t{}, "");
|
||||
new StaticText(details, rect_t{}, STR_AUTHOR, COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD));
|
||||
author = new StaticText(details, rect_t{}, "");
|
||||
|
||||
// labels default to LV_SIZE_CONTENT,
|
||||
// which could overflow the width avail
|
||||
lv_obj_set_width(author->getLvObj(), lv_pct(100));
|
||||
// labels default to LV_SIZE_CONTENT,
|
||||
// which could overflow the width avail
|
||||
lv_obj_set_width(author->getLvObj(), lv_pct(100));
|
||||
|
||||
new StaticText(details, rect_t{}, STR_DESCRIPTION, COLOR_THEME_PRIMARY1 | FONT(BOLD));
|
||||
description =
|
||||
new StaticText(details, rect_t{}, "");
|
||||
new StaticText(details, rect_t{}, STR_DESCRIPTION, COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD));
|
||||
description =
|
||||
new StaticText(details, rect_t{}, "");
|
||||
|
||||
lv_obj_set_width(description->getLvObj(), lv_pct(100));
|
||||
lv_obj_set_width(description->getLvObj(), lv_pct(100));
|
||||
|
||||
#if !PORTRAIT_LCD
|
||||
preview = new FilePreview(line, rect_t{0, 0, LCD_W / 2, LCD_H / 2});
|
||||
#else
|
||||
preview = new FilePreview(line, rect_t{0, 0, LCD_W - 12, LCD_H / 2});
|
||||
#endif
|
||||
preview = new FilePreview(line, {0, 0, PREVIEW_W, LV_SIZE_CONTENT});
|
||||
|
||||
// center within cell
|
||||
lv_obj_set_style_grid_cell_x_align(preview->getLvObj(),
|
||||
LV_GRID_ALIGN_CENTER, 0);
|
||||
}
|
||||
// align within cell
|
||||
lv_obj_set_style_grid_cell_x_align(preview->getLvObj(),
|
||||
LV_GRID_ALIGN_START, 0);
|
||||
|
||||
author->setText(theme->getAuthor());
|
||||
description->setText(theme->getInfo());
|
||||
|
||||
setImage();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void setImage()
|
||||
void update()
|
||||
{
|
||||
auto tp = ThemePersistance::instance();
|
||||
auto theme = tp->getCurrentTheme();
|
||||
auto themeImage = theme->getThemeImageFileNames();
|
||||
if (themeImage.size() > 0) {
|
||||
preview->setFile(themeImage[0].c_str());
|
||||
} else {
|
||||
preview->setFile("");
|
||||
if (theme) {
|
||||
author->setText(theme->getAuthor());
|
||||
description->setText(theme->getInfo());
|
||||
|
||||
auto themeImage = theme->getThemeImageFileNames();
|
||||
if (themeImage.size() > 0) {
|
||||
preview->setFile(themeImage[0].c_str());
|
||||
} else {
|
||||
preview->setFile("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static LAYOUT_VAL(PREVIEW_W, (LCD_W - PAD_MEDIUM * 3) / 2, LCD_W - 12)
|
||||
|
||||
protected:
|
||||
Window* details = nullptr;
|
||||
FilePreview* preview = nullptr;
|
||||
@@ -133,16 +133,16 @@ class ThemeView : public Window
|
||||
};
|
||||
|
||||
ScreenUserInterfacePage::ScreenUserInterfacePage(ScreenMenu* menu) :
|
||||
PageTab(STR_USER_INTERFACE, ICON_THEME_SETUP), menu(menu)
|
||||
PageTab(STR_USER_INTERFACE, ICON_THEME_SETUP, PAD_TINY), menu(menu)
|
||||
{
|
||||
}
|
||||
|
||||
void ScreenUserInterfacePage::build(Window* window)
|
||||
{
|
||||
window->padAll(PAD_SMALL);
|
||||
window->padAll(PAD_TINY);
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO);
|
||||
|
||||
FlexGridLayout grid(line_col_dsc, line_row_dsc);
|
||||
FlexGridLayout grid(line_col_dsc, line_row_dsc, PAD_TINY);
|
||||
|
||||
// Top Bar
|
||||
auto line = window->newLine(grid);
|
||||
@@ -222,7 +222,7 @@ void ScreenUserInterfacePage::build(Window* window)
|
||||
tp->setThemeIndex(value);
|
||||
tp->applyTheme(value);
|
||||
tp->setDefaultTheme(value);
|
||||
themeView->setImage();
|
||||
themeView->update();
|
||||
});
|
||||
|
||||
grid.setColSpan(2);
|
||||
|
||||
@@ -103,11 +103,11 @@ class SelectFabButton : public ButtonBase
|
||||
etx_quick_icon_create);
|
||||
iconLayout->setWindowFlag(NO_FOCUS);
|
||||
|
||||
(new StaticIcon(iconLayout, 0, 0, icon, COLOR_WHITE))
|
||||
(new StaticIcon(iconLayout, 0, 0, icon, COLOR_WHITE_INDEX))
|
||||
->center(SelectFabCarousel::FAB_ICON_SIZE - 4, SelectFabCarousel::FAB_ICON_SIZE - 4);
|
||||
|
||||
new StaticText(this, {0, SelectFabCarousel::FAB_BUTTON_HEIGHT - SelectFabCarousel::FAB_TXT_YO, SelectFabCarousel::FAB_BUTTON_INNER_WIDTH, 0},
|
||||
title, COLOR_WHITE | CENTERED);
|
||||
title, COLOR_WHITE_INDEX, CENTERED);
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
|
||||
@@ -42,6 +42,5 @@ class SelectFabCarousel : public Window
|
||||
|
||||
static LAYOUT_VAL(FAB_ICON_SIZE, 52, 52)
|
||||
static LAYOUT_VAL(FAB_TXT_YO, 48, 48)
|
||||
static LAYOUT_VAL(FAB_PAD, 4, 4)
|
||||
static constexpr coord_t FAB_BUTTON_INNER_WIDTH = FAB_BUTTON_WIDTH - PAD_MEDIUM;
|
||||
};
|
||||
|
||||
@@ -741,14 +741,8 @@ void FunctionsPage::plusPopup(Window *window)
|
||||
|
||||
void FunctionsPage::build(Window *window)
|
||||
{
|
||||
static const lv_coord_t l_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_TINY);
|
||||
|
||||
window->padAll(PAD_SMALL);
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO);
|
||||
|
||||
FlexGridLayout grid(l_col_dsc, row_dsc, PAD_TINY);
|
||||
|
||||
FormLine *line;
|
||||
bool hasEmptyFunction = false;
|
||||
|
||||
// Reset focusIndex after switching tabs
|
||||
@@ -760,10 +754,8 @@ void FunctionsPage::build(Window *window)
|
||||
bool isActive = (cfn->swtch != 0);
|
||||
|
||||
if (isActive) {
|
||||
line = window->newLine(grid);
|
||||
|
||||
auto button = functionButton(
|
||||
line, rect_t{0, 0, window->width() - 12, SF_BUTTON_H}, i);
|
||||
window, rect_t{0, 0, window->width() - 12, SF_BUTTON_H}, i);
|
||||
|
||||
lv_obj_set_grid_cell(button->getLvObj(), LV_GRID_ALIGN_CENTER, 0, 1,
|
||||
LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
@@ -862,9 +854,8 @@ void FunctionsPage::build(Window *window)
|
||||
}
|
||||
|
||||
if (hasEmptyFunction) {
|
||||
line = window->newLine(grid);
|
||||
addButton =
|
||||
new TextButton(line, rect_t{0, 0, window->width() - 12, SF_BUTTON_H},
|
||||
new TextButton(window, rect_t{0, 0, window->width() - 12, SF_BUTTON_H},
|
||||
LV_SYMBOL_PLUS, [=]() {
|
||||
plusPopup(window);
|
||||
return 0;
|
||||
|
||||
@@ -103,12 +103,12 @@ void drawSplash()
|
||||
new StaticLZ4Image(splashScreen, IMG_X - logo->width / 2,
|
||||
IMG_Y - logo->height / 2, logo);
|
||||
|
||||
new StaticText(splashScreen, {TXT_X - 100, TXT_Y, 200, 24}, ver_str.c_str(), COLOR_GREY | CENTERED);
|
||||
new StaticText(splashScreen, {TXT_X - 100, TXT_Y, 200, 24}, ver_str.c_str(), COLOR_GREY_INDEX, CENTERED);
|
||||
new StaticText(splashScreen, {TXT_X - 100, TXT_Y + TXT_H, 200, TXT_H},
|
||||
nam_str.c_str(), COLOR_GREY | CENTERED);
|
||||
nam_str.c_str(), COLOR_GREY_INDEX, CENTERED);
|
||||
#if !defined(VERSION_TAG)
|
||||
new StaticText(splashScreen, {TXT_X - 100, TXT_Y + TXT_H * 2, 200, TXT_H},
|
||||
git_str.c_str(), COLOR_GREY | CENTERED);
|
||||
git_str.c_str(), COLOR_GREY_INDEX, CENTERED);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ void drawSleepBitmap()
|
||||
etx_solid_bg(shutdownWindow->getLvObj(), COLOR_THEME_PRIMARY1_INDEX);
|
||||
}
|
||||
|
||||
(new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2))
|
||||
(new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2_INDEX))
|
||||
->center(LCD_W, LCD_H);
|
||||
|
||||
LvglWrapper::instance()->run();
|
||||
@@ -235,14 +235,14 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration,
|
||||
shutdownSplashImg->width(),
|
||||
shutdownSplashImg->height(), LV_IMG_CF_TRUE_COLOR);
|
||||
}
|
||||
(new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2))
|
||||
(new StaticIcon(shutdownWindow, 0, 0, ICON_SHUTDOWN, COLOR_THEME_PRIMARY2_INDEX))
|
||||
->center(LCD_W, LCD_H);
|
||||
|
||||
for (int i = 0; i < 4; i += 1) {
|
||||
shutdownAnim[i] = new StaticIcon(
|
||||
shutdownWindow, LCD_W / 2 + bmp_shutdown_xo[i],
|
||||
LCD_H / 2 + bmp_shutdown_yo[i],
|
||||
(EdgeTxIcon)(ICON_SHUTDOWN_CIRCLE0 + i), COLOR_THEME_PRIMARY2);
|
||||
(EdgeTxIcon)(ICON_SHUTDOWN_CIRCLE0 + i), COLOR_THEME_PRIMARY2_INDEX);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ void drawFatalErrorScreen(const char* message)
|
||||
etx_solid_bg(fatalErrorWindow->getLvObj(), COLOR_BLACK_INDEX);
|
||||
|
||||
new StaticText(fatalErrorWindow, rect_t{0, LCD_H / 2 - 20, LCD_W, 40},
|
||||
message, FONT(XL) | CENTERED | COLOR_WHITE);
|
||||
message, COLOR_WHITE_INDEX, FONT(XL) | CENTERED);
|
||||
}
|
||||
|
||||
backlightEnable(100);
|
||||
|
||||
@@ -53,10 +53,10 @@ class SelectedTabIcon : public StaticIcon
|
||||
{
|
||||
public:
|
||||
SelectedTabIcon(Window* parent) :
|
||||
StaticIcon(parent, 0, 0, ICON_CURRENTMENU_SHADOW, COLOR_THEME_PRIMARY1)
|
||||
StaticIcon(parent, 0, 0, ICON_CURRENTMENU_SHADOW, COLOR_THEME_PRIMARY1_INDEX)
|
||||
{
|
||||
new StaticIcon(this, 0, 0, ICON_CURRENTMENU_BG, COLOR_THEME_FOCUS);
|
||||
new StaticIcon(this, SEL_DOT_X, SEL_DOT_Y, ICON_CURRENTMENU_DOT, COLOR_THEME_PRIMARY2);
|
||||
new StaticIcon(this, 0, 0, ICON_CURRENTMENU_BG, COLOR_THEME_FOCUS_INDEX);
|
||||
new StaticIcon(this, SEL_DOT_X, SEL_DOT_Y, ICON_CURRENTMENU_DOT, COLOR_THEME_PRIMARY2_INDEX);
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
@@ -74,7 +74,7 @@ class TabsGroupButton : public ButtonBase
|
||||
ButtonBase(parent, rect, nullptr, window_create), pageTab(page), index(idx)
|
||||
{
|
||||
lastIcon = pageTab->getIcon();
|
||||
icon = new StaticIcon(this, 2, ICON_Y, lastIcon, COLOR_THEME_PRIMARY2);
|
||||
icon = new StaticIcon(this, 2, ICON_Y, lastIcon, COLOR_THEME_PRIMARY2_INDEX);
|
||||
|
||||
show(isVisible());
|
||||
}
|
||||
@@ -154,7 +154,7 @@ class TabsGroupHeader : public Window
|
||||
|
||||
selectedIcon = new SelectedTabIcon(carousel);
|
||||
|
||||
new HeaderDateTime(this, LCD_W - DATE_XO, DATE_Y);
|
||||
new HeaderDateTime(this, LCD_W - DATE_XO, PAD_MEDIUM);
|
||||
}
|
||||
|
||||
void setTitle(const char* title) { lv_label_set_text(titleLabel, title); }
|
||||
@@ -221,7 +221,6 @@ class TabsGroupHeader : public Window
|
||||
uint8_t tabCount() const { return buttons.size(); }
|
||||
|
||||
static LAYOUT_VAL(DATE_XO, 48, 48)
|
||||
static LAYOUT_VAL(DATE_Y, 6, 6)
|
||||
static LAYOUT_VAL(MENU_HEADER_BUTTON_WIDTH, 33, 33)
|
||||
static LAYOUT_VAL(HDR_DATE_FULL_WIDTH, 51, 51)
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ class TabsGroupHeader;
|
||||
class PageTab
|
||||
{
|
||||
public:
|
||||
PageTab(PaddingSize padding = PAD_MEDIUM) : padding(padding) {}
|
||||
PageTab(PaddingSize padding = PAD_SMALL) : padding(padding) {}
|
||||
|
||||
PageTab(std::string title, EdgeTxIcon icon,
|
||||
PaddingSize padding = PAD_MEDIUM) :
|
||||
PaddingSize padding = PAD_SMALL) :
|
||||
title(std::move(title)), icon(icon), padding(padding)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "themes/etx_lv_theme.h"
|
||||
#include "topbar_impl.h"
|
||||
#include "view_main.h"
|
||||
#include "storage/sdcard_yaml.h"
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_GENERAL)
|
||||
|
||||
@@ -36,13 +37,6 @@ constexpr const char* RGBSTRING = "RGB(";
|
||||
|
||||
ThemePersistance ThemePersistance::themePersistance;
|
||||
|
||||
// prototype for SD card function to read a YAML file
|
||||
// TODO: should this be in sdcard header file?
|
||||
enum class ChecksumResult;
|
||||
extern const char* readYamlFile(const char* fullpath,
|
||||
const YamlParserCalls* calls, void* parser_ctx,
|
||||
ChecksumResult* checksum_result);
|
||||
|
||||
static uint32_t r_color(const YamlNode* node, const char* val, uint8_t val_len)
|
||||
{
|
||||
if ((strncmp(val, RGBSTRING, strlen(RGBSTRING)) == 0) &&
|
||||
@@ -521,7 +515,8 @@ void HeaderDateTime::checkEvents()
|
||||
struct gtm t;
|
||||
gettime(&t);
|
||||
|
||||
if (t.tm_min != lastMinute) {
|
||||
if (t.tm_min != lastTime.tm_min || t.tm_hour != lastTime.tm_hour ||
|
||||
t.tm_mday != lastTime.tm_mday || t.tm_mon != lastTime.tm_mon) {
|
||||
char str[10];
|
||||
#if defined(TRANSLATIONS_CN) || defined(TRANSLATIONS_TW)
|
||||
sprintf(str, "%02d-%02d", t.tm_mon + 1, t.tm_mday);
|
||||
@@ -533,7 +528,7 @@ void HeaderDateTime::checkEvents()
|
||||
getTimerString(str, getValue(MIXSRC_TX_TIME), timerOptions);
|
||||
lv_label_set_text(time, str);
|
||||
|
||||
lastMinute = t.tm_min;
|
||||
lastTime = t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,15 +539,15 @@ void HeaderDateTime::setColor(LcdFlags color)
|
||||
}
|
||||
|
||||
HeaderIcon::HeaderIcon(Window* parent, EdgeTxIcon icon) :
|
||||
StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS)
|
||||
StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS_INDEX)
|
||||
{
|
||||
(new StaticIcon(this, 0, 0, icon, COLOR_THEME_PRIMARY2))->center(width(), height());
|
||||
(new StaticIcon(this, 0, 0, icon, COLOR_THEME_PRIMARY2_INDEX))->center(width(), height());
|
||||
}
|
||||
|
||||
HeaderIcon::HeaderIcon(Window* parent, const char* iconFile) :
|
||||
StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS)
|
||||
StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS_INDEX)
|
||||
{
|
||||
(new StaticIcon(this, 0, 0, iconFile, COLOR_THEME_PRIMARY2))->center(width(), height());
|
||||
(new StaticIcon(this, 0, 0, iconFile, COLOR_THEME_PRIMARY2_INDEX))->center(width(), height());
|
||||
}
|
||||
|
||||
UsbSDConnected::UsbSDConnected() :
|
||||
@@ -561,8 +556,8 @@ UsbSDConnected::UsbSDConnected() :
|
||||
setWindowFlag(OPAQUE);
|
||||
|
||||
etx_solid_bg(lvobj, COLOR_THEME_PRIMARY1_INDEX);
|
||||
new HeaderDateTime(this, LCD_W - TopBar::HDR_DATE_XO, HDR_DATE_Y);
|
||||
new HeaderDateTime(this, LCD_W - TopBar::HDR_DATE_XO, PAD_MEDIUM);
|
||||
|
||||
auto icon = new StaticIcon(this, 0, 0, ICON_USB_PLUGGED, COLOR_THEME_PRIMARY2);
|
||||
auto icon = new StaticIcon(this, 0, 0, ICON_USB_PLUGGED, COLOR_THEME_PRIMARY2_INDEX);
|
||||
lv_obj_center(icon->getLvObj());
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ class HeaderDateTime : public Window
|
||||
protected:
|
||||
lv_obj_t *date = nullptr;
|
||||
lv_obj_t *time = nullptr;
|
||||
int8_t lastMinute = -1;
|
||||
struct gtm lastTime = { 0 };
|
||||
|
||||
void checkEvents() override;
|
||||
};
|
||||
@@ -188,6 +188,4 @@ class UsbSDConnected : public Window
|
||||
{
|
||||
public:
|
||||
UsbSDConnected();
|
||||
|
||||
static LAYOUT_VAL(HDR_DATE_Y, 6, 6)
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ AboutUs::AboutUs() :
|
||||
{
|
||||
new StaticText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT},
|
||||
about_str + "\n" + copyright_str,
|
||||
COLOR_THEME_SECONDARY1 | CENTERED);
|
||||
COLOR_THEME_SECONDARY1_INDEX, CENTERED);
|
||||
|
||||
auto qrBox = new Window(form, {0, 0, LV_PCT(100), QR_SZ});
|
||||
auto qr = new QRCode(qrBox, 0, 0, QR_SZ, edgetx_url);
|
||||
|
||||
@@ -49,7 +49,7 @@ class ChannelsViewFooter : public Window
|
||||
w->setWindowFlag(NO_FOCUS);
|
||||
etx_solid_bg(w->getLvObj(), COLOR_THEME_ACTIVE_INDEX);
|
||||
|
||||
new StaticText(this, {LEG_COLORBOX + PAD_MEDIUM + PAD_SMALL, PAD_TINY, LV_SIZE_CONTENT, TXT_H}, STR_MONITOR_OUTPUT_DESC, COLOR_THEME_PRIMARY2 | LEFT);
|
||||
new StaticText(this, {LEG_COLORBOX + PAD_MEDIUM + PAD_SMALL, PAD_TINY, LV_SIZE_CONTENT, TXT_H}, STR_MONITOR_OUTPUT_DESC, COLOR_THEME_PRIMARY2_INDEX);
|
||||
|
||||
int x = getTextWidth(STR_MONITOR_OUTPUT_DESC) + LEG_COLORBOX + PAD_MEDIUM * 2;
|
||||
|
||||
@@ -61,7 +61,7 @@ class ChannelsViewFooter : public Window
|
||||
etx_solid_bg(w->getLvObj(), COLOR_THEME_FOCUS_INDEX);
|
||||
|
||||
new StaticText(this, {x + LEG_COLORBOX + PAD_MEDIUM + PAD_SMALL, PAD_TINY, LV_SIZE_CONTENT, TXT_H},
|
||||
STR_MONITOR_MIXER_DESC, COLOR_THEME_PRIMARY2);
|
||||
STR_MONITOR_MIXER_DESC, COLOR_THEME_PRIMARY2_INDEX);
|
||||
}
|
||||
|
||||
static LAYOUT_VAL(LEG_COLORBOX, 14, 14)
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "view_main_decoration.h"
|
||||
#include "layout.h"
|
||||
|
||||
// because of IS_POT_MULTIPOS() and pal
|
||||
#include "opentx.h"
|
||||
@@ -29,12 +28,29 @@
|
||||
#include "layouts/sliders.h"
|
||||
#include "layouts/trims.h"
|
||||
|
||||
#include "board.h"
|
||||
#include "hal/adc_driver.h"
|
||||
#include "themes/etx_lv_theme.h"
|
||||
|
||||
static Window* create_layout_box(Window* parent, lv_align_t align,
|
||||
lv_flex_flow_t flow)
|
||||
ViewMainDecoration::ViewMainDecoration(Window* parent, bool showTrims, bool showSliders, bool showFM) :
|
||||
parent(parent)
|
||||
{
|
||||
w_ml = layoutBox(parent, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_ROW_REVERSE);
|
||||
w_mr = layoutBox(parent, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_ROW);
|
||||
w_bl = layoutBox(parent, LV_ALIGN_BOTTOM_LEFT, LV_FLEX_FLOW_COLUMN);
|
||||
w_br = layoutBox(parent, LV_ALIGN_BOTTOM_RIGHT, LV_FLEX_FLOW_COLUMN);
|
||||
|
||||
w_bc = layoutBox(parent, LV_ALIGN_BOTTOM_MID, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(w_bc->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
|
||||
|
||||
if (showTrims)
|
||||
createTrims(w_ml, w_mr, w_bl, w_br);
|
||||
if (showFM)
|
||||
createFlightMode(w_bc);
|
||||
if (showSliders)
|
||||
createSliders(w_ml, w_mr, w_bl, w_bc, w_br);
|
||||
}
|
||||
|
||||
Window* ViewMainDecoration::layoutBox(Window* parent, lv_align_t align,
|
||||
lv_flex_flow_t flow)
|
||||
{
|
||||
auto w = new Window(parent, rect_t{0, 0, LV_SIZE_CONTENT, LV_SIZE_CONTENT});
|
||||
|
||||
@@ -50,26 +66,6 @@ static Window* create_layout_box(Window* parent, lv_align_t align,
|
||||
return w;
|
||||
}
|
||||
|
||||
ViewMainDecoration::ViewMainDecoration(Window* parent) :
|
||||
parent(parent)
|
||||
{
|
||||
memset(sliders, 0, sizeof(sliders));
|
||||
memset(trims, 0, sizeof(trims));
|
||||
flightMode = nullptr;
|
||||
|
||||
w_ml = create_layout_box(parent, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_ROW_REVERSE);
|
||||
w_mr = create_layout_box(parent, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_ROW);
|
||||
w_bl = create_layout_box(parent, LV_ALIGN_BOTTOM_LEFT, LV_FLEX_FLOW_COLUMN);
|
||||
w_br = create_layout_box(parent, LV_ALIGN_BOTTOM_RIGHT, LV_FLEX_FLOW_COLUMN);
|
||||
|
||||
w_bc = create_layout_box(parent, LV_ALIGN_BOTTOM_MID, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(w_bc->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
|
||||
|
||||
createTrims(w_ml, w_mr, w_bl, w_br);
|
||||
createFlightMode(w_bc);
|
||||
createSliders(w_ml, w_mr, w_bl, w_bc, w_br);
|
||||
}
|
||||
|
||||
void ViewMainDecoration::setSlidersVisible(bool visible)
|
||||
{
|
||||
for (int i=0; i < SLIDERS_MAX; i++) {
|
||||
@@ -106,8 +102,7 @@ rect_t ViewMainDecoration::getMainZone() const
|
||||
Window* boxes[] = { w_bl, w_bc, w_br };
|
||||
|
||||
for ( auto box : boxes ) {
|
||||
auto obj = box->getLvObj();
|
||||
auto y = lv_obj_get_y(obj);
|
||||
auto y = lv_obj_get_y(box->getLvObj());
|
||||
if (y < bottom) bottom = y;
|
||||
}
|
||||
|
||||
@@ -116,12 +111,11 @@ rect_t ViewMainDecoration::getMainZone() const
|
||||
|
||||
void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Window* bc, Window* br)
|
||||
{
|
||||
int pot = 0, sl = 0;
|
||||
int pot = 0;
|
||||
|
||||
// Bottom left horizontal slider
|
||||
if (IS_POT_AVAILABLE(pot)) {
|
||||
sliders[sl] = new MainViewHorizontalSlider(bl, pot);
|
||||
sl += 1;
|
||||
sliders[pot] = new MainViewHorizontalSlider(bl, pot);
|
||||
}
|
||||
pot += 1;
|
||||
|
||||
@@ -129,8 +123,8 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo
|
||||
if (IS_POT_AVAILABLE(pot)) {
|
||||
if (IS_POT_MULTIPOS(pot)) {
|
||||
// Has 6POS - place bottom center
|
||||
sliders[sl] = new MainView6POS(bc, pot);
|
||||
pot += 1; sl += 1;
|
||||
sliders[pot] = new MainView6POS(bc, pot);
|
||||
pot += 1;
|
||||
}
|
||||
} else {
|
||||
pot += 1;
|
||||
@@ -138,8 +132,7 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo
|
||||
|
||||
// Bottom right horizontal slider
|
||||
if (IS_POT_AVAILABLE(pot)) {
|
||||
sliders[sl] = new MainViewHorizontalSlider(br, pot);
|
||||
sl += 1;
|
||||
sliders[pot] = new MainViewHorizontalSlider(br, pot);
|
||||
}
|
||||
pot += 1;
|
||||
|
||||
@@ -147,35 +140,32 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo
|
||||
if (max_pots > pot) {
|
||||
// create containers for the sliders, so that they are at the borders of the display
|
||||
// on top of each other, when there are two sliders to display per side
|
||||
auto leftPots = create_layout_box(ml, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_COLUMN);
|
||||
auto leftPots = layoutBox(ml, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_COLUMN);
|
||||
leftPots->setHeight(MainViewSlider::HORIZONTAL_SLIDERS_WIDTH);
|
||||
|
||||
auto rightPots = create_layout_box(mr, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_COLUMN);
|
||||
auto rightPots = layoutBox(mr, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_COLUMN);
|
||||
rightPots->setHeight(MainViewSlider::VERTICAL_SLIDERS_HEIGHT);
|
||||
|
||||
coord_t lsh = (IS_POT_AVAILABLE(pot + 2)) ? MainViewSlider::HORIZONTAL_SLIDERS_WIDTH / 2 : MainViewSlider::HORIZONTAL_SLIDERS_WIDTH;
|
||||
coord_t rsh = (IS_POT_AVAILABLE(pot + 3)) ? MainViewSlider::HORIZONTAL_SLIDERS_WIDTH / 2 : MainViewSlider::HORIZONTAL_SLIDERS_WIDTH;
|
||||
|
||||
if (IS_POT_AVAILABLE(pot)) {
|
||||
sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot);
|
||||
sl += 1;
|
||||
sliders[pot] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot);
|
||||
}
|
||||
pot += 1;
|
||||
|
||||
if (IS_POT_AVAILABLE(pot)) {
|
||||
sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot);
|
||||
sl += 1;
|
||||
sliders[pot] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot);
|
||||
}
|
||||
pot += 1;
|
||||
|
||||
if (IS_POT_AVAILABLE(pot)) {
|
||||
sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot);
|
||||
sl += 1;
|
||||
sliders[pot] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, lsh}, pot);
|
||||
}
|
||||
pot += 1;
|
||||
|
||||
if (IS_POT_AVAILABLE(pot)) {
|
||||
sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot);
|
||||
sliders[pot] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, LayoutFactory::TRIM_SQUARE_SIZE, rsh}, pot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,6 +185,5 @@ void ViewMainDecoration::createFlightMode(Window* bc)
|
||||
return stringFromNtString(g_model.flightModeData[mixerCurrentFlightMode].name);
|
||||
};
|
||||
|
||||
flightMode = new DynamicText(bc, rect_t{}, getFM, COLOR_THEME_SECONDARY1);
|
||||
flightMode = new DynamicText(bc, rect_t{}, getFM, COLOR_THEME_SECONDARY1_INDEX);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,12 @@
|
||||
|
||||
#include "window.h"
|
||||
|
||||
constexpr coord_t FM_LABEL_HEIGHT = 20;
|
||||
|
||||
class MainViewTrim;
|
||||
|
||||
class ViewMainDecoration
|
||||
{
|
||||
public:
|
||||
ViewMainDecoration(Window* parent);
|
||||
ViewMainDecoration(Window* parent, bool showTrims = true, bool showSliders = true, bool showFM = true);
|
||||
|
||||
// Set decoration visibility
|
||||
void setTrimsVisible(bool visible);
|
||||
@@ -69,9 +67,11 @@ class ViewMainDecoration
|
||||
Window* w_bc;
|
||||
Window* w_br;
|
||||
|
||||
Window* sliders[SLIDERS_MAX];
|
||||
MainViewTrim* trims[TRIMS_MAX];
|
||||
Window* flightMode;
|
||||
Window* sliders[SLIDERS_MAX] = { 0 };
|
||||
MainViewTrim* trims[TRIMS_MAX] = { 0 };
|
||||
Window* flightMode = nullptr;
|
||||
|
||||
Window* layoutBox(Window* parent, lv_align_t align, lv_flex_flow_t flow);
|
||||
|
||||
void createSliders(Window* ml, Window* mr, Window* bl, Window* bc, Window* br);
|
||||
void createTrims(Window* ml, Window* mr, Window* bl, Window* br);
|
||||
|
||||
@@ -96,7 +96,7 @@ class DebugInfoNumber : public Window
|
||||
coord_t prefixSize = 0;
|
||||
if (prefix != nullptr) {
|
||||
prefixSize = getTextWidth(prefix, 0, FONT(XS));
|
||||
new StaticText(this, {0, 1, prefixSize, rect.h}, prefix,FONT(XS));
|
||||
new StaticText(this, {0, 1, prefixSize, rect.h}, prefix, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||
}
|
||||
new DynamicNumber<uint32_t>(this,
|
||||
{prefixSize, 0, rect.w - prefixSize, rect.h},
|
||||
@@ -179,15 +179,13 @@ void StatisticsViewPage::build(Window* window)
|
||||
// Session data
|
||||
new StaticText(line, rect_t{}, STR_SESSION);
|
||||
new DynamicText(
|
||||
line, rect_t{}, [] { return getTimerString(sessionTimer); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
line, rect_t{}, [] { return getTimerString(sessionTimer); });
|
||||
|
||||
// Battery data
|
||||
new StaticText(line, rect_t{}, STR_BATT_LABEL);
|
||||
new DynamicText(
|
||||
line, rect_t{},
|
||||
[] { return getTimerString(g_eeGeneral.globalTimer + sessionTimer); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
[] { return getTimerString(g_eeGeneral.globalTimer + sessionTimer); });
|
||||
|
||||
line = window->newLine(grid);
|
||||
line->padAll(PAD_ZERO);
|
||||
@@ -195,14 +193,12 @@ void StatisticsViewPage::build(Window* window)
|
||||
// Throttle
|
||||
new StaticText(line, rect_t{}, STR_THROTTLE_LABEL);
|
||||
new DynamicText(
|
||||
line, rect_t{}, [] { return getTimerString(s_timeCumThr); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
line, rect_t{}, [] { return getTimerString(s_timeCumThr); });
|
||||
|
||||
// Throttle % data
|
||||
new StaticText(line, rect_t{}, STR_THROTTLE_PERCENT_LABEL);
|
||||
new DynamicText(
|
||||
line, rect_t{}, [] { return getTimerString(s_timeCum16ThrP / 16); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
line, rect_t{}, [] { return getTimerString(s_timeCum16ThrP / 16); });
|
||||
|
||||
line = window->newLine(grid);
|
||||
line->padAll(PAD_ZERO);
|
||||
@@ -210,14 +206,11 @@ void StatisticsViewPage::build(Window* window)
|
||||
// Timers
|
||||
new StaticText(line, rect_t{}, STR_TIMER_LABEL);
|
||||
new DynamicText(
|
||||
line, rect_t{}, [] { return getTimerString(timersStates[0].val); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
line, rect_t{}, [] { return getTimerString(timersStates[0].val); });
|
||||
new DynamicText(
|
||||
line, rect_t{}, [] { return getTimerString(timersStates[1].val); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
line, rect_t{}, [] { return getTimerString(timersStates[1].val); });
|
||||
new DynamicText(
|
||||
line, rect_t{}, [] { return getTimerString(timersStates[2].val); },
|
||||
COLOR_THEME_PRIMARY1);
|
||||
line, rect_t{}, [] { return getTimerString(timersStates[2].val); });
|
||||
|
||||
line = window->newLine(grid);
|
||||
line->padAll(PAD_ZERO);
|
||||
@@ -269,11 +262,11 @@ void DebugViewPage::build(Window* window)
|
||||
new StaticText(line, rect_t{}, STR_TMIXMAXMS);
|
||||
new DynamicNumber<uint16_t>(
|
||||
line, rect_t{}, [] { return DURATION_MS_PREC2(maxMixerDuration); },
|
||||
PREC2 | COLOR_THEME_PRIMARY1, nullptr, pad_STR_MS.c_str());
|
||||
COLOR_THEME_PRIMARY1_INDEX, PREC2, nullptr, pad_STR_MS.c_str());
|
||||
|
||||
new DynamicNumber<uint16_t>(
|
||||
line, rect_t{}, [] { return getMixerSchedulerPeriod() / 1000; },
|
||||
COLOR_THEME_PRIMARY1, pad_STR_PERIOD.c_str(), pad_STR_MS.c_str());
|
||||
COLOR_THEME_PRIMARY1_INDEX, 0, pad_STR_PERIOD.c_str(), pad_STR_MS.c_str());
|
||||
|
||||
line = window->newLine(grid);
|
||||
line->padAll(PAD_TINY);
|
||||
@@ -282,7 +275,7 @@ void DebugViewPage::build(Window* window)
|
||||
static std::string pad_STR_BYTES = " " + std::string(STR_BYTES);
|
||||
new StaticText(line, rect_t{}, STR_FREE_MEM_LABEL);
|
||||
new DynamicNumber<int32_t>(
|
||||
line, rect_t{}, [] { return availableMemory(); }, COLOR_THEME_PRIMARY1,
|
||||
line, rect_t{}, [] { return availableMemory(); }, COLOR_THEME_PRIMARY1_INDEX, 0,
|
||||
nullptr, pad_STR_BYTES.c_str());
|
||||
|
||||
#if defined(LUA)
|
||||
@@ -380,8 +373,7 @@ void DebugViewPage::build(Window* window)
|
||||
line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT},
|
||||
[] {
|
||||
return std::string(gpsData.fix ? STR_GPS_FIX_YES : STR_GPS_FIX_NO);
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
});
|
||||
new DebugInfoNumber<uint8_t>(
|
||||
line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT},
|
||||
[] { return gpsData.numSat; }, STR_GPS_SATS);
|
||||
|
||||
@@ -31,11 +31,11 @@ class GaugeWidget : public Widget
|
||||
{
|
||||
// Gauge label
|
||||
sourceText = new StaticText(this, {0, 0, LV_SIZE_CONTENT, 16}, "",
|
||||
FONT(XS) | COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX, FONT(XS));
|
||||
|
||||
valueText = new DynamicNumber<int16_t>(
|
||||
this, {0, 0, lv_pct(100), 16}, [=]() { return getGuageValue(); },
|
||||
FONT(XS) | CENTERED | COLOR_THEME_PRIMARY2, "", "%");
|
||||
COLOR_THEME_PRIMARY2_INDEX, FONT(XS) | CENTERED, "", "%");
|
||||
etx_obj_add_style(valueText->getLvObj(), styles->text_align_right,
|
||||
LV_STATE_USER_1);
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ class ModelBitmapWidget : public Widget
|
||||
|
||||
protected:
|
||||
bool isLarge = false;
|
||||
// std::unique_ptr<BitmapBuffer> buffer;
|
||||
uint32_t deps_hash = 0;
|
||||
StaticText* label = nullptr;
|
||||
StaticImage* image = nullptr;
|
||||
|
||||
@@ -44,24 +44,24 @@ class RadioInfoWidget : public TopBarWidget
|
||||
{
|
||||
// Logs
|
||||
logsIcon = new StaticIcon(this, W_LOG_X, W_LOG_Y, ICON_DOT,
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
logsIcon->hide();
|
||||
|
||||
usbIcon =
|
||||
new StaticIcon(this, W_USB_X, W_USB_Y, ICON_TOPMENU_USB,
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
usbIcon->hide();
|
||||
|
||||
#if defined(AUDIO)
|
||||
audioScale = new StaticIcon(this, W_AUDIO_SCALE_X, 2,
|
||||
ICON_TOPMENU_VOLUME_SCALE,
|
||||
COLOR_THEME_PRIMARY3);
|
||||
COLOR_THEME_PRIMARY3_INDEX);
|
||||
|
||||
for (int i = 0; i < 5; i += 1) {
|
||||
audioVol[i] = new StaticIcon(
|
||||
this, W_AUDIO_X, 2,
|
||||
(EdgeTxIcon)(ICON_TOPMENU_VOLUME_0 + i),
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
audioVol[i]->hide();
|
||||
}
|
||||
audioVol[0]->show();
|
||||
@@ -69,18 +69,18 @@ class RadioInfoWidget : public TopBarWidget
|
||||
|
||||
batteryIcon = new StaticIcon(this, W_AUDIO_X, W_BATT_Y,
|
||||
ICON_TOPMENU_TXBATT,
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
#if defined(USB_CHARGER)
|
||||
batteryChargeIcon = new StaticIcon(
|
||||
this, W_BATT_CHG_X, W_BATT_CHG_Y,
|
||||
ICON_TOPMENU_TXBATT_CHARGE, COLOR_THEME_PRIMARY2);
|
||||
ICON_TOPMENU_TXBATT_CHARGE, COLOR_THEME_PRIMARY2_INDEX);
|
||||
batteryChargeIcon->hide();
|
||||
#endif
|
||||
|
||||
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
|
||||
extAntenna = new StaticIcon(this, W_RSSI_X - 4, 1,
|
||||
ICON_TOPMENU_ANTENNA,
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
extAntenna->hide();
|
||||
#endif
|
||||
|
||||
@@ -280,11 +280,11 @@ class InternalGPSWidget : public TopBarWidget
|
||||
{
|
||||
icon =
|
||||
new StaticIcon(this, width() / 2 - 10, 19,
|
||||
ICON_TOPMENU_GPS, COLOR_THEME_PRIMARY3);
|
||||
ICON_TOPMENU_GPS, COLOR_THEME_PRIMARY3_INDEX);
|
||||
|
||||
numSats = new DynamicNumber<uint16_t>(
|
||||
this, {0, 1, width(), 12}, [=] { return gpsData.numSat; },
|
||||
COLOR_THEME_PRIMARY2 | CENTERED | FONT(XS));
|
||||
COLOR_THEME_PRIMARY2_INDEX, CENTERED | FONT(XS));
|
||||
}
|
||||
|
||||
void checkEvents() override
|
||||
|
||||
@@ -43,8 +43,8 @@ class TimerWidget : public Widget
|
||||
lv_style_set_width(&style, lv_pct(100));
|
||||
lv_style_set_height(&style, LV_SIZE_CONTENT);
|
||||
|
||||
timerBg = new StaticIcon(this, 0, 0, ICON_TIMER_BG, COLOR_THEME_PRIMARY2);
|
||||
timerIcon = new StaticIcon(this, 3, 4, ICON_TIMER, COLOR_THEME_SECONDARY1);
|
||||
timerBg = new StaticIcon(this, 0, 0, ICON_TIMER_BG, COLOR_THEME_PRIMARY2_INDEX);
|
||||
timerIcon = new StaticIcon(this, 3, 4, ICON_TIMER, COLOR_THEME_SECONDARY1_INDEX);
|
||||
|
||||
// Timer name
|
||||
nameLabel = lv_label_create(lvobj);
|
||||
|
||||
@@ -555,9 +555,9 @@ static int luaModelSetFlightMode(lua_State * L)
|
||||
if (idx < 0 || idx >= max_trims) continue;
|
||||
int16_t val = luaL_checkinteger(L, -1);
|
||||
if (g_model.extendedTrims)
|
||||
val = limit<int16_t>(val, TRIM_EXTENDED_MIN, TRIM_EXTENDED_MAX);
|
||||
val = limit<int16_t>(TRIM_EXTENDED_MIN, val, TRIM_EXTENDED_MAX);
|
||||
else
|
||||
val = limit<int16_t>(val, TRIM_MIN, TRIM_MAX);
|
||||
val = limit<int16_t>(TRIM_MIN, val, TRIM_MAX);
|
||||
if (idx < max_trims)
|
||||
fm->trim[idx].value = val;
|
||||
}
|
||||
|
||||
@@ -200,13 +200,8 @@ void LuaWidget::redraw_cb(lv_event_t* e)
|
||||
} else {
|
||||
lv_draw_ctx_t* draw_ctx = lv_event_get_draw_ctx(e);
|
||||
|
||||
lv_area_t a, clipping, obj_coords;
|
||||
lv_area_copy(&a, draw_ctx->buf_area);
|
||||
lv_area_copy(&clipping, draw_ctx->clip_area);
|
||||
lv_obj_get_coords(target, &obj_coords);
|
||||
|
||||
auto w = a.x2 - a.x1 + 1;
|
||||
auto h = a.y2 - a.y1 + 1;
|
||||
auto w = draw_ctx->buf_area->x2 - draw_ctx->buf_area->x1 + 1;
|
||||
auto h = draw_ctx->buf_area->y2 - draw_ctx->buf_area->y1 + 1;
|
||||
|
||||
TRACE_WINDOWS("Draw %s", widget->getWindowDebugString().c_str());
|
||||
|
||||
@@ -215,10 +210,6 @@ void LuaWidget::redraw_cb(lv_event_t* e)
|
||||
|
||||
buf.setDrawCtx(draw_ctx);
|
||||
|
||||
buf.setOffset(obj_coords.x1 - a.x1, obj_coords.y1 - a.y1);
|
||||
buf.setClippingRect(clipping.x1 - a.x1, clipping.x2 + 1 - a.x1,
|
||||
clipping.y1 - a.y1, clipping.y2 + 1 - a.y1);
|
||||
|
||||
widget->refresh(&buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _MODELSLIST_H_
|
||||
#define _MODELSLIST_H_
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -281,5 +280,3 @@ ModelLabelsVector getUniqueLabels();
|
||||
|
||||
extern ModelsList modelslist;
|
||||
extern ModelMap modelslabels;
|
||||
|
||||
#endif // _MODELSLIST_H_
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
#pragma once
|
||||
|
||||
enum class ChecksumResult {Success, Failed, None};
|
||||
#include "sdcard_common.h" // TODO CHECK REQUIRED
|
||||
|
||||
struct YamlParserCalls;
|
||||
|
||||
constexpr uint8_t MODELIDX_STRLEN = sizeof(MODEL_FILENAME_PREFIX "00");
|
||||
|
||||
@@ -32,3 +33,7 @@ const char * readModelYaml(const char * filename, uint8_t * buffer, uint32_t siz
|
||||
bool YamlFileChecksum(const YamlNode* root_node, uint8_t* data, uint16_t* checksum);
|
||||
|
||||
void getModelNumberStr(uint8_t idx, char* model_idx);
|
||||
|
||||
const char* readYamlFile(const char* fullpath,
|
||||
const YamlParserCalls* calls, void* parser_ctx,
|
||||
ChecksumResult* checksum_result);
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _yaml_bits_h_
|
||||
#define _yaml_bits_h_
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -45,5 +44,3 @@ char* yaml_unsigned2hex(uint32_t i);
|
||||
char* yaml_rgb2hex(uint32_t i);
|
||||
|
||||
int32_t yaml_to_signed(uint32_t i, uint32_t bits);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,13 +19,10 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _YAML_DATASTRUCTS_H_
|
||||
#define _YAML_DATASTRUCTS_H_
|
||||
#pragma once
|
||||
|
||||
struct YamlNode;
|
||||
|
||||
const YamlNode* get_radiodata_nodes();
|
||||
const YamlNode* get_modeldata_nodes();
|
||||
const YamlNode* get_partialmodel_nodes();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _YAML_DEFS_H_
|
||||
#define _YAML_DEFS_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(YAML_GENERATOR)
|
||||
|
||||
@@ -71,5 +70,3 @@
|
||||
#define CUST_IDX(tag, read, write)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _YAML_LABELSLIST_H_
|
||||
#define _YAML_LABELSLIST_H_
|
||||
#pragma once
|
||||
|
||||
#define MODULE_ID_STR "mod%did"
|
||||
#define MODULE_TYPE_STR "mod%dtype"
|
||||
@@ -30,5 +29,3 @@ struct YamlParserCalls;
|
||||
|
||||
void* get_labelslist_iter();
|
||||
const YamlParserCalls* get_labelslist_parser_calls();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _YAML_MODELSLIST_H_
|
||||
#define _YAML_MODELSLIST_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -29,5 +28,3 @@ struct YamlParserCalls;
|
||||
|
||||
void* get_modelslist_iter(std::vector<std::string>* filelist);
|
||||
const YamlParserCalls* get_modelslist_parser_calls();
|
||||
|
||||
#endif
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _node_h_
|
||||
#define _node_h_
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
@@ -210,5 +209,3 @@ struct YamlNode
|
||||
{ 0, YDT_ARRAY, 1, NULL, {{ (nodes), {{ NULL }}}} }
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _yaml_parser_h_
|
||||
#define _yaml_parser_h_
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -102,5 +101,3 @@ public:
|
||||
|
||||
void set_eof() { eof = true; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _YAML_TREE_WALKER_H_
|
||||
#define _YAML_TREE_WALKER_H_
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "yaml_node.h"
|
||||
@@ -168,6 +167,3 @@ public:
|
||||
// utils
|
||||
uint32_t yaml_parse_enum(const struct YamlIdStr* choices, const char* val, uint8_t val_len);
|
||||
const char* yaml_output_enum(int32_t i, const struct YamlIdStr* choices);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+36
-19
@@ -90,7 +90,7 @@ void BitmapBuffer::setData(uint16_t *d)
|
||||
|
||||
void BitmapBuffer::clear(LcdFlags flags)
|
||||
{
|
||||
drawSolidFilledRect(0, 0, _width - offsetX, _height - offsetY, flags);
|
||||
drawSolidFilledRect(0, 0, _width, _height, flags);
|
||||
}
|
||||
|
||||
void BitmapBuffer::clearClippingRect()
|
||||
@@ -119,10 +119,36 @@ void BitmapBuffer::getClippingRect(coord_t &xmin, coord_t &xmax, coord_t &ymin,
|
||||
ymax = this->ymax;
|
||||
}
|
||||
|
||||
void BitmapBuffer::setOffset(coord_t offsetX, coord_t offsetY)
|
||||
bool BitmapBuffer::applyClippingRect(coord_t& x, coord_t& y, coord_t& w,
|
||||
coord_t& h) const
|
||||
{
|
||||
this->offsetX = offsetX;
|
||||
this->offsetY = offsetY;
|
||||
if (h < 0) {
|
||||
y += h;
|
||||
h = -h;
|
||||
}
|
||||
|
||||
if (w < 0) {
|
||||
x += w;
|
||||
w = -w;
|
||||
}
|
||||
|
||||
if (x >= xmax || y >= ymax) return false;
|
||||
|
||||
if (y < ymin) {
|
||||
h += y - ymin;
|
||||
y = ymin;
|
||||
}
|
||||
|
||||
if (x < xmin) {
|
||||
w += x - xmin;
|
||||
x = xmin;
|
||||
}
|
||||
|
||||
if (y + h > ymax) h = ymax - y;
|
||||
|
||||
if (x + w > xmax) w = xmax - x;
|
||||
|
||||
return data && h > 0 && w > 0;
|
||||
}
|
||||
|
||||
void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp,
|
||||
@@ -130,7 +156,6 @@ void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp,
|
||||
coord_t srch, float scale)
|
||||
{
|
||||
if (!data || !bmp) return;
|
||||
APPLY_OFFSET();
|
||||
if (x >= xmax || y >= ymax) return;
|
||||
|
||||
coord_t bmpw = bmp->width();
|
||||
@@ -182,7 +207,7 @@ void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp,
|
||||
}
|
||||
|
||||
if (scale == 0) {
|
||||
if (bmp->getFormat() == BMP_ARGB4444) {
|
||||
if (bmp->format == BMP_ARGB4444) {
|
||||
DMACopyAlphaBitmap(data, _width, _height, x, y, bmp->getData(), bmpw,
|
||||
bmph, srcx, srcy, srcw, srch);
|
||||
} else {
|
||||
@@ -211,11 +236,11 @@ void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp,
|
||||
const pixel_t *q = qstart;
|
||||
MOVE_PIXEL_RIGHT(q, int(j / scale));
|
||||
|
||||
if (bmp->getFormat() == BMP_RGB565) {
|
||||
if (bmp->format == BMP_RGB565) {
|
||||
RGB_SPLIT(*q, r, g, b);
|
||||
drawPixel(p, ARGB_JOIN(0xF, r >> 1, g >> 2, b >> 1));
|
||||
|
||||
} else { // bmp->getFormat() == BMP_ARGB4444
|
||||
} else { // bmp->format == BMP_ARGB4444
|
||||
drawPixel(p, *q);
|
||||
}
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
@@ -232,9 +257,9 @@ void BitmapBuffer::drawBitmap(coord_t x, coord_t y, const BitmapBuffer *bmp,
|
||||
const pixel_t *q = qstart;
|
||||
MOVE_PIXEL_RIGHT(q, int(j / scale));
|
||||
|
||||
if (bmp->getFormat() == BMP_RGB565) {
|
||||
if (bmp->format == BMP_RGB565) {
|
||||
drawPixel(p, *q);
|
||||
} else { // bmp->getFormat() == BMP_ARGB4444
|
||||
} else { // bmp->format == BMP_ARGB4444
|
||||
ARGB_SPLIT(*q, a, r, g, b);
|
||||
drawAlphaPixel(p, a, RGB_JOIN(r << 1, g << 2, b << 1));
|
||||
}
|
||||
@@ -267,8 +292,6 @@ void BitmapBuffer::drawHorizontalLine(coord_t x, coord_t y, coord_t w,
|
||||
{
|
||||
if (opacity == OPACITY_MAX) return;
|
||||
|
||||
APPLY_OFFSET();
|
||||
|
||||
coord_t h = 1;
|
||||
if (!applyClippingRect(x, y, w, h)) return;
|
||||
|
||||
@@ -320,8 +343,6 @@ void BitmapBuffer::drawVerticalLine(coord_t x, coord_t y, coord_t h,
|
||||
{
|
||||
if (opacity == OPACITY_MAX) return;
|
||||
|
||||
APPLY_OFFSET();
|
||||
|
||||
coord_t w = 1;
|
||||
if (!applyClippingRect(x, y, w, h)) return;
|
||||
|
||||
@@ -385,7 +406,6 @@ void BitmapBuffer::drawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h,
|
||||
{
|
||||
if (opacity == OPACITY_MAX) return;
|
||||
|
||||
APPLY_OFFSET();
|
||||
if (!applyClippingRect(x, y, w, h)) return;
|
||||
|
||||
if (SOLID != pat) {
|
||||
@@ -428,7 +448,6 @@ coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char *s,
|
||||
uint8_t len, LcdFlags flags)
|
||||
{
|
||||
if (!s) return x;
|
||||
MOVE_OFFSET();
|
||||
|
||||
// LVGL does not handle non-null terminated strings
|
||||
static char buffer[256];
|
||||
@@ -490,11 +509,9 @@ coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char *s,
|
||||
}
|
||||
#endif
|
||||
|
||||
RESTORE_OFFSET();
|
||||
|
||||
pos += p.x;
|
||||
|
||||
return ((flags & RIGHT) ? orig_pos : pos) - offsetX;
|
||||
return ((flags & RIGHT) ? orig_pos : pos);
|
||||
}
|
||||
|
||||
// Resize and convert to LVGL image data format with alpha blending to
|
||||
|
||||
+39
-109
@@ -27,18 +27,6 @@ constexpr uint8_t SOLID = 0xFF;
|
||||
constexpr uint8_t DOTTED = 0x55;
|
||||
constexpr uint8_t STASHED = 0x33;
|
||||
|
||||
#define MOVE_OFFSET() \
|
||||
coord_t offsetX = this->offsetX; \
|
||||
x += offsetX; \
|
||||
this->offsetX = 0; \
|
||||
coord_t offsetY = this->offsetY; \
|
||||
y += offsetY; \
|
||||
this->offsetY = 0
|
||||
#define APPLY_OFFSET() \
|
||||
x += this->offsetX; \
|
||||
y += this->offsetY
|
||||
#define RESTORE_OFFSET() this->offsetX = offsetX, this->offsetY = offsetY
|
||||
|
||||
#define MOVE_PIXEL_RIGHT(p, count) p += count
|
||||
|
||||
#define MOVE_TO_NEXT_RIGHT_PIXEL(p) MOVE_PIXEL_RIGHT(p, 1)
|
||||
@@ -73,8 +61,6 @@ class BitmapBuffer
|
||||
|
||||
inline void drawPixel(coord_t x, coord_t y, pixel_t value)
|
||||
{
|
||||
APPLY_OFFSET();
|
||||
|
||||
coord_t w = 1, h = 1;
|
||||
if (!applyClippingRect(x, y, w, h)) return;
|
||||
|
||||
@@ -86,8 +72,6 @@ class BitmapBuffer
|
||||
inline void drawAlphaPixel(coord_t x, coord_t y, uint8_t opacity,
|
||||
pixel_t value)
|
||||
{
|
||||
APPLY_OFFSET();
|
||||
|
||||
coord_t w = 1, h = 1;
|
||||
if (!applyClippingRect(x, y, w, h)) return;
|
||||
|
||||
@@ -118,35 +102,11 @@ class BitmapBuffer
|
||||
uint8_t pat = SOLID, LcdFlags flags = 0,
|
||||
uint8_t opacity = 0);
|
||||
|
||||
void invertRect(coord_t x, coord_t y, coord_t w, coord_t h,
|
||||
LcdFlags flags = 0);
|
||||
|
||||
void drawFilledTriangle(coord_t x1, coord_t y1, coord_t x2, coord_t y2,
|
||||
coord_t x3, coord_t y3, LcdFlags flags = 0,
|
||||
uint8_t opacity = 0);
|
||||
|
||||
void drawCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags = 0, coord_t thickness = 1);
|
||||
|
||||
void drawFilledCircle(coord_t x, coord_t y, coord_t radius,
|
||||
LcdFlags flags = 0);
|
||||
|
||||
void drawAnnulusSector(coord_t x, coord_t y, coord_t internalRadius,
|
||||
coord_t externalRadius, int startAngle, int endAngle,
|
||||
LcdFlags flags = 0);
|
||||
|
||||
void drawBitmapPatternPie(coord_t x0, coord_t y0, const MaskBitmap* img,
|
||||
LcdFlags flags, int startAngle, int endAngle);
|
||||
|
||||
static BitmapBuffer* loadBitmap(const char* filename,
|
||||
BitmapFormats fmt = BMP_INVALID);
|
||||
|
||||
void resizeToLVGL(coord_t w, coord_t h);
|
||||
|
||||
MaskBitmap* to8bitMask(size_t* size) const;
|
||||
|
||||
void drawBitmapPattern(coord_t x, coord_t y, const MaskBitmap* bmp,
|
||||
LcdFlags flags, coord_t offset = 0, coord_t width = 0);
|
||||
|
||||
coord_t drawSizedText(coord_t x, coord_t y, const char* s, uint8_t len,
|
||||
LcdFlags flags = 0);
|
||||
|
||||
@@ -156,60 +116,61 @@ class BitmapBuffer
|
||||
return drawSizedText(x, y, s, strlen(s), flags);
|
||||
}
|
||||
|
||||
coord_t drawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags = 0,
|
||||
uint8_t len = 0, const char* prefix = nullptr,
|
||||
const char* suffix = nullptr);
|
||||
|
||||
void drawBitmap(coord_t x, coord_t y, const BitmapBuffer* bmp,
|
||||
coord_t srcx = 0, coord_t srcy = 0, coord_t srcw = 0,
|
||||
coord_t srch = 0, float scale = 0);
|
||||
|
||||
void drawScaledBitmap(const BitmapBuffer* bitmap, coord_t x, coord_t y,
|
||||
coord_t w, coord_t h);
|
||||
|
||||
void drawTextLines(coord_t left, coord_t top, coord_t width, coord_t height,
|
||||
const char* str, LcdFlags flags);
|
||||
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags flags = 0);
|
||||
|
||||
coord_t drawSwitch(coord_t x, coord_t y, int32_t idx, LcdFlags flags = 0);
|
||||
|
||||
void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags flags = 0);
|
||||
|
||||
void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor,
|
||||
int32_t value, LcdFlags flags = 0);
|
||||
|
||||
void clearClippingRect();
|
||||
|
||||
void setClippingRect(coord_t xmin, coord_t xmax, coord_t ymin, coord_t ymax);
|
||||
|
||||
void getClippingRect(coord_t& xmin, coord_t& xmax, coord_t& ymin,
|
||||
coord_t& ymax);
|
||||
|
||||
void setOffset(coord_t offsetX, coord_t offsetY);
|
||||
|
||||
inline void clearOffset() { setOffset(0, 0); }
|
||||
|
||||
inline void reset()
|
||||
{
|
||||
clearOffset();
|
||||
clearClippingRect();
|
||||
}
|
||||
|
||||
coord_t getOffsetX() const { return offsetX; }
|
||||
|
||||
coord_t getOffsetY() const { return offsetY; }
|
||||
|
||||
inline uint8_t getFormat() const { return format; }
|
||||
|
||||
inline uint16_t width() const { return _width; }
|
||||
|
||||
inline uint16_t height() const { return _height; }
|
||||
|
||||
inline pixel_t* getData() const { return data; }
|
||||
|
||||
uint32_t getDataSize() const { return _width * _height * sizeof(pixel_t); }
|
||||
|
||||
// Lua API functions
|
||||
void setClippingRect(coord_t xmin, coord_t xmax, coord_t ymin, coord_t ymax);
|
||||
void getClippingRect(coord_t& xmin, coord_t& xmax, coord_t& ymin,
|
||||
coord_t& ymax);
|
||||
|
||||
MaskBitmap* to8bitMask(size_t* size) const;
|
||||
|
||||
void invertRect(coord_t x, coord_t y, coord_t w, coord_t h,
|
||||
LcdFlags flags = 0);
|
||||
|
||||
void drawFilledTriangle(coord_t x1, coord_t y1, coord_t x2, coord_t y2,
|
||||
coord_t x3, coord_t y3, LcdFlags flags = 0,
|
||||
uint8_t opacity = 0);
|
||||
void drawCircle(coord_t x, coord_t y, coord_t radius, LcdFlags flags = 0, coord_t thickness = 1);
|
||||
void drawFilledCircle(coord_t x, coord_t y, coord_t radius,
|
||||
LcdFlags flags = 0);
|
||||
void drawAnnulusSector(coord_t x, coord_t y, coord_t internalRadius,
|
||||
coord_t externalRadius, int startAngle, int endAngle,
|
||||
LcdFlags flags = 0);
|
||||
|
||||
void drawBitmapPatternPie(coord_t x0, coord_t y0, const MaskBitmap* img,
|
||||
LcdFlags flags, int startAngle, int endAngle);
|
||||
void drawBitmapPattern(coord_t x, coord_t y, const MaskBitmap* bmp,
|
||||
LcdFlags flags, coord_t offset = 0, coord_t width = 0);
|
||||
void drawScaledBitmap(const BitmapBuffer* bitmap, coord_t x, coord_t y,
|
||||
coord_t w, coord_t h);
|
||||
coord_t drawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags = 0,
|
||||
uint8_t len = 0, const char* prefix = nullptr,
|
||||
const char* suffix = nullptr);
|
||||
void drawTextLines(coord_t left, coord_t top, coord_t width, coord_t height,
|
||||
const char* str, LcdFlags flags);
|
||||
void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags flags = 0);
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags flags = 0);
|
||||
coord_t drawSwitch(coord_t x, coord_t y, int32_t idx, LcdFlags flags = 0);
|
||||
void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor,
|
||||
int32_t value, LcdFlags flags = 0);
|
||||
|
||||
protected:
|
||||
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit,
|
||||
LcdFlags flags = 0);
|
||||
@@ -223,37 +184,8 @@ class BitmapBuffer
|
||||
void drawDate(coord_t x, coord_t y, TelemetryItem& telemetryItem,
|
||||
LcdFlags att);
|
||||
|
||||
inline bool applyClippingRect(coord_t& x, coord_t& y, coord_t& w,
|
||||
coord_t& h) const
|
||||
{
|
||||
if (h < 0) {
|
||||
y += h;
|
||||
h = -h;
|
||||
}
|
||||
|
||||
if (w < 0) {
|
||||
x += w;
|
||||
w = -w;
|
||||
}
|
||||
|
||||
if (x >= xmax || y >= ymax) return false;
|
||||
|
||||
if (y < ymin) {
|
||||
h += y - ymin;
|
||||
y = ymin;
|
||||
}
|
||||
|
||||
if (x < xmin) {
|
||||
w += x - xmin;
|
||||
x = xmin;
|
||||
}
|
||||
|
||||
if (y + h > ymax) h = ymax - y;
|
||||
|
||||
if (x + w > xmax) w = xmax - x;
|
||||
|
||||
return data && h > 0 && w > 0;
|
||||
}
|
||||
bool applyClippingRect(coord_t& x, coord_t& y, coord_t& w,
|
||||
coord_t& h) const;
|
||||
|
||||
inline void drawPixel(pixel_t* p, pixel_t value)
|
||||
{
|
||||
@@ -290,8 +222,6 @@ class BitmapBuffer
|
||||
coord_t xmax;
|
||||
coord_t ymin = 0;
|
||||
coord_t ymax;
|
||||
coord_t offsetX = 0;
|
||||
coord_t offsetY = 0;
|
||||
pixel_t* data;
|
||||
pixel_t* data_end;
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
void BitmapBuffer::invertRect(coord_t x, coord_t y, coord_t w, coord_t h,
|
||||
LcdFlags flags)
|
||||
{
|
||||
APPLY_OFFSET();
|
||||
|
||||
if (!applyClippingRect(x, y, w, h)) return;
|
||||
|
||||
// No 'opacity' here, only 'color'
|
||||
@@ -333,12 +331,6 @@ bool BitmapBuffer::liangBarskyClipper(coord_t &x1, coord_t &y1, coord_t &x2,
|
||||
void BitmapBuffer::drawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2,
|
||||
uint8_t pat, LcdFlags flags)
|
||||
{
|
||||
// Offsets
|
||||
x1 += offsetX;
|
||||
y1 += offsetY;
|
||||
x2 += offsetX;
|
||||
y2 += offsetY;
|
||||
|
||||
if (!liangBarskyClipper(x1, y1, x2, y2)) return;
|
||||
|
||||
// TODO; Replace with LVGL line draw - currently does not support dotted line drawing
|
||||
@@ -493,8 +485,6 @@ void BitmapBuffer::drawFilledTriangle(coord_t x0, coord_t y0, coord_t x1,
|
||||
void BitmapBuffer::drawFilledCircle(coord_t x, coord_t y, coord_t radius,
|
||||
LcdFlags flags)
|
||||
{
|
||||
APPLY_OFFSET();
|
||||
|
||||
lv_draw_rect_dsc_t rect_dsc;
|
||||
lv_draw_rect_dsc_init(&rect_dsc);
|
||||
rect_dsc.bg_opa = LV_OPA_COVER;
|
||||
@@ -527,8 +517,6 @@ void BitmapBuffer::drawFilledCircle(coord_t x, coord_t y, coord_t radius,
|
||||
void BitmapBuffer::drawCircle(coord_t x, coord_t y, coord_t radius,
|
||||
LcdFlags flags, coord_t thickness)
|
||||
{
|
||||
APPLY_OFFSET();
|
||||
|
||||
lv_draw_rect_dsc_t rect_dsc;
|
||||
lv_draw_rect_dsc_init(&rect_dsc);
|
||||
rect_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
@@ -690,8 +678,6 @@ void BitmapBuffer::drawAnnulusSector(coord_t x, coord_t y,
|
||||
coord_t externalRadius, int startAngle,
|
||||
int endAngle, LcdFlags flags)
|
||||
{
|
||||
APPLY_OFFSET();
|
||||
|
||||
if (endAngle == startAngle)
|
||||
endAngle += 1;
|
||||
|
||||
@@ -731,7 +717,7 @@ MaskBitmap *BitmapBuffer::to8bitMask(size_t *size) const
|
||||
|
||||
const pixel_t *p = getPixelPtrAbs(0, 0);
|
||||
int ofs = 0;
|
||||
if (getFormat() == BMP_ARGB4444) {
|
||||
if (format == BMP_ARGB4444) {
|
||||
for (int i = width() * height(); i > 0; i--) {
|
||||
ARGB_SPLIT(*p, a __attribute__((unused)), r, g, b);
|
||||
int v = (r + g + b) / 3;
|
||||
@@ -760,8 +746,6 @@ void BitmapBuffer::drawBitmapPattern(coord_t x, coord_t y, const MaskBitmap *bmp
|
||||
LcdFlags flags, coord_t offset,
|
||||
coord_t width)
|
||||
{
|
||||
APPLY_OFFSET();
|
||||
|
||||
coord_t bmpw = bmp->width;
|
||||
coord_t bmph = bmp->height;
|
||||
|
||||
|
||||
+2
-3
@@ -54,8 +54,7 @@ Button::Button(Window* parent, const rect_t& rect,
|
||||
ButtonBase::ButtonBase(Window* parent, const rect_t& rect,
|
||||
std::function<uint8_t(void)> pressHandler,
|
||||
LvglCreate objConstruct) :
|
||||
FormField(parent, rect, 0,
|
||||
objConstruct ? objConstruct : lv_btn_create),
|
||||
FormField(parent, rect, objConstruct ? objConstruct : lv_btn_create),
|
||||
pressHandler(std::move(pressHandler))
|
||||
{
|
||||
}
|
||||
@@ -113,7 +112,7 @@ IconButton::IconButton(Window* parent, EdgeTxIcon icon, coord_t x, coord_t y,
|
||||
ButtonBase(parent, {x, y, EdgeTxStyles::UI_ELEMENT_HEIGHT, EdgeTxStyles::UI_ELEMENT_HEIGHT}, pressHandler, button_create)
|
||||
{
|
||||
padAll(PAD_ZERO);
|
||||
iconImage = new StaticIcon(this, 0, 0, icon, COLOR_THEME_SECONDARY1);
|
||||
iconImage = new StaticIcon(this, 0, 0, icon, COLOR_THEME_SECONDARY1_INDEX);
|
||||
iconImage->center(EdgeTxStyles::UI_ELEMENT_HEIGHT - 4, EdgeTxStyles::UI_ELEMENT_HEIGHT - 4);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ static void btn_matrix_event(lv_event_t* e)
|
||||
}
|
||||
|
||||
ButtonMatrix::ButtonMatrix(Window* parent, const rect_t& r) :
|
||||
FormField(parent, r, 0, btnmatrix_create)
|
||||
FormField(parent, r, btnmatrix_create)
|
||||
{
|
||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
||||
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ ChoiceBase::ChoiceBase(Window* parent, const rect_t& rect,
|
||||
std::function<int()> _getValue,
|
||||
std::function<void(int)> _setValue,
|
||||
ChoiceType type) :
|
||||
FormField(parent, rect, 0, choice_create),
|
||||
FormField(parent, rect, choice_create),
|
||||
vmin(vmin), vmax(vmax), menuTitle(title),
|
||||
_getValue(std::move(_getValue)),
|
||||
_setValue(std::move(_setValue))
|
||||
|
||||
+8
-8
@@ -51,7 +51,7 @@ BaseDialog::BaseDialog(Window* parent, const char* title,
|
||||
etx_solid_bg(content->getLvObj());
|
||||
lv_obj_center(content->getLvObj());
|
||||
|
||||
header = new StaticText(content, {0, 0, LV_PCT(100), 0}, title ? title : "", COLOR_THEME_PRIMARY2);
|
||||
header = new StaticText(content, {0, 0, LV_PCT(100), 0}, title ? title : "", COLOR_THEME_PRIMARY2_INDEX);
|
||||
etx_solid_bg(header->getLvObj(), COLOR_THEME_SECONDARY1_INDEX);
|
||||
header->padAll(PAD_SMALL);
|
||||
header->show(title != nullptr);
|
||||
@@ -102,11 +102,11 @@ MessageDialog::MessageDialog(Window* parent, const char* title,
|
||||
BaseDialog(parent, title, true)
|
||||
{
|
||||
messageWidget = new StaticText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT},
|
||||
message, messageFlags);
|
||||
message, COLOR_THEME_PRIMARY1_INDEX, messageFlags);
|
||||
|
||||
if (info) {
|
||||
infoWidget = new StaticText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT},
|
||||
info, infoFlags);
|
||||
info, COLOR_THEME_PRIMARY1_INDEX, infoFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,14 +116,14 @@ void MessageDialog::onClicked() { deleteLater(); }
|
||||
|
||||
DynamicMessageDialog::DynamicMessageDialog(
|
||||
Window* parent, const char* title, std::function<std::string()> textHandler,
|
||||
const char* message, const int lineHeight, const LcdFlags textFlags) :
|
||||
const char* message, const int lineHeight, LcdColorIndex color, LcdFlags textFlags) :
|
||||
BaseDialog(parent, title, true)
|
||||
{
|
||||
messageWidget = new StaticText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT},
|
||||
message, CENTERED | COLOR_THEME_PRIMARY1);
|
||||
message, COLOR_THEME_PRIMARY1_INDEX, CENTERED);
|
||||
|
||||
infoWidget = new DynamicText(form, {0, 0, LV_PCT(100), LV_SIZE_CONTENT},
|
||||
textHandler, textFlags);
|
||||
textHandler, color, textFlags);
|
||||
}
|
||||
|
||||
void DynamicMessageDialog::onClicked() { deleteLater(); }
|
||||
@@ -139,7 +139,7 @@ ConfirmDialog::ConfirmDialog(Window* parent, const char* title,
|
||||
cancelHandler(std::move(cancelHandler))
|
||||
{
|
||||
if (message) {
|
||||
new StaticText(form, {0, 0, LV_PCT(100), 0}, message, CENTERED);
|
||||
new StaticText(form, {0, 0, LV_PCT(100), 0}, message, COLOR_THEME_PRIMARY1_INDEX, CENTERED);
|
||||
}
|
||||
|
||||
auto box = new Window(form, rect_t{});
|
||||
@@ -185,7 +185,7 @@ LabelDialog::LabelDialog(Window *parent, const char *label, int length, const ch
|
||||
lv_obj_center(form->getLvObj());
|
||||
|
||||
auto hdr = new StaticText(form, {0, 0, LV_PCT(100), 0}, title,
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
etx_solid_bg(hdr->getLvObj(), COLOR_THEME_SECONDARY1_INDEX);
|
||||
hdr->padAll(PAD_MEDIUM);
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ class DynamicMessageDialog : public BaseDialog
|
||||
std::function<std::string()> textHandler,
|
||||
const char* message = "",
|
||||
const int lineHeight = EdgeTxStyles::PAGE_LINE_HEIGHT,
|
||||
const LcdFlags textFlags = CENTERED);
|
||||
LcdColorIndex color = COLOR_THEME_PRIMARY1_INDEX, LcdFlags textFlags = CENTERED);
|
||||
// Attn.: FONT(XXL) is not supported by DynamicMessageDialog
|
||||
|
||||
protected:
|
||||
|
||||
+1
-2
@@ -39,8 +39,7 @@ void FlexGridLayout::add(Window* w)
|
||||
}
|
||||
}
|
||||
|
||||
FormField::FormField(Window* parent, const rect_t& rect, LcdFlags textFlags,
|
||||
LvglCreate objConstruct) :
|
||||
FormField::FormField(Window* parent, const rect_t& rect, LvglCreate objConstruct) :
|
||||
Window(parent, rect, objConstruct)
|
||||
{
|
||||
setTextFlag(textFlags);
|
||||
|
||||
+1
-2
@@ -77,8 +77,7 @@ class FlexGridLayout
|
||||
class FormField : public Window
|
||||
{
|
||||
public:
|
||||
FormField(Window* parent, const rect_t& rect, LcdFlags textFlags = 0,
|
||||
LvglCreate objConstruct = nullptr);
|
||||
FormField(Window* parent, const rect_t& rect, LvglCreate objConstruct = nullptr);
|
||||
|
||||
virtual void changeEnd(bool forceChanged = false)
|
||||
{
|
||||
|
||||
+1
-1
@@ -327,7 +327,7 @@ class MenuWindowContent : public Window
|
||||
setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO, MENUS_WIDTH, LV_SIZE_CONTENT);
|
||||
|
||||
header = new StaticText(this, {0, 0, LV_PCT(100), 0}, "",
|
||||
COLOR_THEME_PRIMARY2);
|
||||
COLOR_THEME_PRIMARY2_INDEX);
|
||||
etx_solid_bg(header->getLvObj(), COLOR_THEME_SECONDARY1_INDEX);
|
||||
header->padAll(PAD_SMALL);
|
||||
header->hide();
|
||||
|
||||
+44
-150
@@ -26,21 +26,16 @@
|
||||
class NumberArea : public FormField
|
||||
{
|
||||
public:
|
||||
NumberArea(Window* parent, const rect_t& rect, int vmin, int vmax,
|
||||
std::function<int()> getValue,
|
||||
std::function<void(int)> setValue = nullptr,
|
||||
LcdFlags textFlags = 0) :
|
||||
FormField(parent, rect, textFlags, etx_textarea_create),
|
||||
vmin(vmin),
|
||||
vmax(vmax),
|
||||
_getValue(std::move(getValue)),
|
||||
_setValue(std::move(setValue))
|
||||
NumberArea(NumberEdit* parent, const rect_t& rect) :
|
||||
FormField(parent, rect, etx_textarea_create),
|
||||
numEdit(parent)
|
||||
{
|
||||
if (rect.w == 0) setWidth(DEF_W);
|
||||
|
||||
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||
|
||||
etx_obj_add_style(lvobj, styles->text_align_right, LV_PART_MAIN);
|
||||
if (parent->getTextFlags() & CENTERED)
|
||||
etx_obj_add_style(lvobj, styles->text_align_center, LV_PART_MAIN);
|
||||
else
|
||||
etx_obj_add_style(lvobj, styles->text_align_right, LV_PART_MAIN);
|
||||
|
||||
// Allow encoder acceleration
|
||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_ENCODER_ACCEL);
|
||||
@@ -71,45 +66,44 @@ class NumberArea : public FormField
|
||||
event);
|
||||
|
||||
if (editMode) {
|
||||
int value = numEdit->getValue();
|
||||
switch (event) {
|
||||
#if defined(HARDWARE_KEYS)
|
||||
case EVT_ROTARY_RIGHT: {
|
||||
int value = getValue();
|
||||
auto step = vstep;
|
||||
step += (rotaryEncoderGetAccel() * accelFactor) / 8;
|
||||
auto step = numEdit->step;
|
||||
step += (rotaryEncoderGetAccel() * numEdit->accelFactor) / 8;
|
||||
do {
|
||||
#if defined(USE_HATS_AS_KEYS)
|
||||
value -= step;
|
||||
#else
|
||||
value += step;
|
||||
#endif
|
||||
} while (isValueAvailable && !isValueAvailable(value) &&
|
||||
value <= vmax);
|
||||
if (value <= vmax) {
|
||||
setValue(value);
|
||||
} while (numEdit->isValueAvailable && !numEdit->isValueAvailable(value) &&
|
||||
value <= numEdit->vmax);
|
||||
if (value <= numEdit->vmax) {
|
||||
numEdit->setValue(value);
|
||||
} else {
|
||||
setValue(vmax);
|
||||
numEdit->setValue(numEdit->vmax);
|
||||
onKeyError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case EVT_ROTARY_LEFT: {
|
||||
int value = getValue();
|
||||
auto step = vstep;
|
||||
step += (rotaryEncoderGetAccel() * accelFactor) / 8;
|
||||
auto step = numEdit->step;
|
||||
step += (rotaryEncoderGetAccel() * numEdit->accelFactor) / 8;
|
||||
do {
|
||||
#if defined(USE_HATS_AS_KEYS)
|
||||
value += step;
|
||||
#else
|
||||
value -= step;
|
||||
#endif
|
||||
} while (isValueAvailable && !isValueAvailable(value) &&
|
||||
value >= vmin);
|
||||
if (value >= vmin) {
|
||||
setValue(value);
|
||||
} while (numEdit->isValueAvailable && !numEdit->isValueAvailable(value) &&
|
||||
value >= numEdit->vmin);
|
||||
if (value >= numEdit->vmin) {
|
||||
numEdit->setValue(value);
|
||||
} else {
|
||||
setValue(vmin);
|
||||
numEdit->setValue(numEdit->vmin);
|
||||
onKeyError();
|
||||
}
|
||||
return;
|
||||
@@ -117,35 +111,35 @@ class NumberArea : public FormField
|
||||
#endif
|
||||
|
||||
case EVT_VIRTUAL_KEY_PLUS:
|
||||
setValue(getValue() + vstep);
|
||||
numEdit->setValue(value + numEdit->step);
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_MINUS:
|
||||
setValue(getValue() - vstep);
|
||||
numEdit->setValue(value - numEdit->step);
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_FORWARD:
|
||||
setValue(getValue() + fastStep * vstep);
|
||||
numEdit->setValue(value + numEdit->fastStep * numEdit->step);
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_BACKWARD:
|
||||
setValue(getValue() - fastStep * vstep);
|
||||
numEdit->setValue(value - numEdit->fastStep * numEdit->step);
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_DEFAULT:
|
||||
setValue(vdefault);
|
||||
numEdit->setValue(numEdit->vdefault);
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_MAX:
|
||||
setValue(vmax);
|
||||
numEdit->setValue(numEdit->vmax);
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_MIN:
|
||||
setValue(vmin);
|
||||
numEdit->setValue(numEdit->vmin);
|
||||
break;
|
||||
|
||||
case EVT_VIRTUAL_KEY_SIGN:
|
||||
setValue(-getValue());
|
||||
numEdit->setValue(-value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -164,108 +158,21 @@ class NumberArea : public FormField
|
||||
}
|
||||
}
|
||||
|
||||
void setMin(int value) { vmin = value; }
|
||||
void setMax(int value) { vmax = value; }
|
||||
void setDefault(int value) { vdefault = value; }
|
||||
void setStep(int value) { vstep = value; }
|
||||
void setFastStep(int value) { fastStep = value; }
|
||||
void setAccelFactor(int value) { accelFactor = value; }
|
||||
void setValue(int value)
|
||||
{
|
||||
auto newValue = limit(vmin, value, vmax);
|
||||
if (newValue != currentValue) {
|
||||
currentValue = newValue;
|
||||
if (_setValue != nullptr) {
|
||||
_setValue(currentValue);
|
||||
}
|
||||
}
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
int32_t getValue() const { return _getValue != nullptr ? _getValue() : 0; }
|
||||
|
||||
void setPrefix(std::string value) { prefix = std::move(value); }
|
||||
|
||||
void setSuffix(std::string value) { suffix = std::move(value); }
|
||||
|
||||
void setZeroText(std::string value) { zeroText = std::move(value); }
|
||||
|
||||
void setAvailableHandler(std::function<bool(int)> handler)
|
||||
{
|
||||
isValueAvailable = std::move(handler);
|
||||
}
|
||||
|
||||
void setSetValueHandler(std::function<void(int)> handler)
|
||||
{
|
||||
_setValue = std::move(handler);
|
||||
}
|
||||
|
||||
void setGetValueHandler(std::function<int()> handler)
|
||||
{
|
||||
_getValue = std::move(handler);
|
||||
}
|
||||
|
||||
void setDisplayHandler(std::function<std::string(int value)> function)
|
||||
{
|
||||
displayFunction = std::move(function);
|
||||
}
|
||||
|
||||
void setCancelHandler(std::function<void(void)> handler)
|
||||
{
|
||||
cancelHandler = std::move(handler);
|
||||
}
|
||||
|
||||
void openKeyboard() { NumberKeyboard::show(this); }
|
||||
void directEdit() { FormField::onClicked(); }
|
||||
|
||||
void update()
|
||||
{
|
||||
if (_getValue == nullptr) return;
|
||||
currentValue = _getValue();
|
||||
updateDisplay();
|
||||
if (lvobj != nullptr)
|
||||
lv_textarea_set_text(lvobj, numEdit->getDisplayVal().c_str());
|
||||
}
|
||||
|
||||
static LAYOUT_VAL(DEF_W, 100, 100)
|
||||
|
||||
protected:
|
||||
int vdefault = 0;
|
||||
int vmin;
|
||||
int vmax;
|
||||
int vstep = 1;
|
||||
int fastStep = 10;
|
||||
int accelFactor = 4;
|
||||
int currentValue;
|
||||
std::string prefix;
|
||||
std::string suffix;
|
||||
std::string zeroText;
|
||||
std::function<int()> _getValue;
|
||||
std::function<void(int)> _setValue;
|
||||
std::function<std::string(int)> displayFunction;
|
||||
std::function<bool(int)> isValueAvailable;
|
||||
std::function<void(void)> cancelHandler = nullptr;
|
||||
|
||||
void updateDisplay()
|
||||
{
|
||||
if (lvobj != nullptr) {
|
||||
std::string str;
|
||||
if (displayFunction != nullptr) {
|
||||
str = displayFunction(currentValue);
|
||||
} else if (!zeroText.empty() && currentValue == 0) {
|
||||
str = zeroText;
|
||||
} else {
|
||||
str = formatNumberAsString(currentValue, textFlags, 0, prefix.c_str(),
|
||||
suffix.c_str());
|
||||
}
|
||||
lv_textarea_set_text(lvobj, str.c_str());
|
||||
}
|
||||
}
|
||||
NumberEdit* numEdit = nullptr;
|
||||
|
||||
void onCancel() override
|
||||
{
|
||||
if (cancelHandler)
|
||||
cancelHandler();
|
||||
else
|
||||
FormField::onCancel();
|
||||
onClicked();
|
||||
}
|
||||
|
||||
static void numberedit_cb(lv_event_t* e)
|
||||
@@ -304,7 +211,7 @@ NumberEdit::NumberEdit(Window* parent, const rect_t& rect, int vmin, int vmax,
|
||||
vmin(vmin),
|
||||
vmax(vmax)
|
||||
{
|
||||
if (rect.w == 0) setWidth(NumberArea::DEF_W);
|
||||
if (rect.w == 0) setWidth(DEF_W);
|
||||
|
||||
setTextFlag(textFlags);
|
||||
|
||||
@@ -323,32 +230,14 @@ void NumberEdit::openEdit()
|
||||
edit = new NumberArea(
|
||||
this,
|
||||
{-(PAD_MEDIUM + 2), -(PAD_TINY + 2),
|
||||
lv_obj_get_width(lvobj), lv_obj_get_height(lvobj)},
|
||||
this->vmin, this->vmax, _getValue, _setValue, textFlags);
|
||||
lv_obj_get_width(lvobj), lv_obj_get_height(lvobj)});
|
||||
edit->setChangeHandler([=]() {
|
||||
update();
|
||||
if (edit->hasFocus())
|
||||
lv_group_focus_obj(lvobj);
|
||||
edit->hide();
|
||||
});
|
||||
edit->setCancelHandler([=]() {
|
||||
edit->onClicked();
|
||||
});
|
||||
}
|
||||
edit->setTextFlag(textFlags);
|
||||
edit->setSetValueHandler(_setValue);
|
||||
edit->setGetValueHandler(_getValue);
|
||||
edit->setAvailableHandler(isValueAvailable);
|
||||
edit->setDisplayHandler(displayFunction);
|
||||
edit->setDefault(vdefault);
|
||||
edit->setMin(vmin);
|
||||
edit->setMax(vmax);
|
||||
edit->setStep(step);
|
||||
edit->setFastStep(fastStep);
|
||||
edit->setAccelFactor(accelFactor);
|
||||
edit->setPrefix(prefix);
|
||||
edit->setSuffix(suffix);
|
||||
edit->setZeroText(zeroText);
|
||||
edit->update();
|
||||
edit->show();
|
||||
lv_group_focus_obj(edit->getLvObj());
|
||||
@@ -369,7 +258,7 @@ void NumberEdit::update()
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
void NumberEdit::updateDisplay()
|
||||
std::string NumberEdit::getDisplayVal()
|
||||
{
|
||||
std::string str;
|
||||
if (displayFunction != nullptr) {
|
||||
@@ -380,7 +269,12 @@ void NumberEdit::updateDisplay()
|
||||
str = formatNumberAsString(currentValue, textFlags, 0, prefix.c_str(),
|
||||
suffix.c_str());
|
||||
}
|
||||
setText(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
void NumberEdit::updateDisplay()
|
||||
{
|
||||
setText(getDisplayVal());
|
||||
}
|
||||
|
||||
void NumberEdit::setValue(int value)
|
||||
@@ -393,5 +287,5 @@ void NumberEdit::setValue(int value)
|
||||
}
|
||||
}
|
||||
updateDisplay();
|
||||
if (edit) edit->setValue(value);
|
||||
if (edit) edit->update();
|
||||
}
|
||||
|
||||
@@ -91,7 +91,11 @@ class NumberEdit : public TextButton
|
||||
|
||||
int32_t getValue() const { return _getValue != nullptr ? _getValue() : 0; }
|
||||
|
||||
static LAYOUT_VAL(DEF_W, 100, 100)
|
||||
|
||||
protected:
|
||||
friend class NumberArea;
|
||||
|
||||
NumberArea* edit = nullptr;
|
||||
std::function<int()> _getValue;
|
||||
std::function<void(int)> _setValue;
|
||||
@@ -108,6 +112,8 @@ class NumberEdit : public TextButton
|
||||
std::function<std::string(int)> displayFunction;
|
||||
std::function<bool(int)> isValueAvailable;
|
||||
|
||||
std::string getDisplayVal();
|
||||
|
||||
void updateDisplay();
|
||||
void openEdit();
|
||||
};
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ Slider::Slider(Window* parent, coord_t width, int32_t vmin, int32_t vmax,
|
||||
padLeft(8);
|
||||
padRight(8);
|
||||
|
||||
slider = (new FormField(this, rect_t{}, 0, slider_create))->getLvObj();
|
||||
slider = (new FormField(this, rect_t{}, slider_create))->getLvObj();
|
||||
lv_obj_set_width(slider, lv_pct(100));
|
||||
|
||||
lv_obj_add_event_cb(slider, slider_changed_cb, LV_EVENT_VALUE_CHANGED, this);
|
||||
|
||||
+6
-6
@@ -26,7 +26,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StaticText::StaticText(Window* parent, const rect_t& rect, std::string txt,
|
||||
LcdFlags textFlags) :
|
||||
LcdColorIndex color, LcdFlags textFlags) :
|
||||
Window(parent, rect, lv_label_create), text(std::move(txt))
|
||||
{
|
||||
setTextFlag(textFlags);
|
||||
@@ -34,7 +34,7 @@ StaticText::StaticText(Window* parent, const rect_t& rect, std::string txt,
|
||||
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||
|
||||
etx_font(lvobj, FONT_INDEX(textFlags));
|
||||
etx_txt_color(lvobj, indexFromColor(textFlags));
|
||||
etx_txt_color(lvobj, color);
|
||||
|
||||
if (textFlags & CENTERED)
|
||||
etx_obj_add_style(lvobj, styles->text_align_center, LV_PART_MAIN);
|
||||
@@ -144,9 +144,9 @@ void DynamicNumber<int16_t>::updateText()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, EdgeTxIcon icon,
|
||||
LcdFlags color) :
|
||||
LcdColorIndex color) :
|
||||
Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create),
|
||||
currentColor(indexFromColor(color))
|
||||
currentColor(color)
|
||||
{
|
||||
setWindowFlag(NO_FOCUS);
|
||||
|
||||
@@ -158,9 +158,9 @@ StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, EdgeTxIcon icon,
|
||||
}
|
||||
|
||||
StaticIcon::StaticIcon(Window* parent, coord_t x, coord_t y, const char* filename,
|
||||
LcdFlags color) :
|
||||
LcdColorIndex color) :
|
||||
Window(parent, rect_t{x, y, 0, 0}, lv_canvas_create),
|
||||
currentColor(indexFromColor(color))
|
||||
currentColor(color)
|
||||
{
|
||||
setWindowFlag(NO_FOCUS);
|
||||
|
||||
|
||||
+8
-8
@@ -30,7 +30,7 @@ class StaticText : public Window
|
||||
{
|
||||
public:
|
||||
StaticText(Window *parent, const rect_t &rect, std::string text = "",
|
||||
LcdFlags textFlags = COLOR_THEME_PRIMARY1);
|
||||
LcdColorIndex color = COLOR_THEME_PRIMARY1_INDEX, LcdFlags textFlags = 0);
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() const override;
|
||||
@@ -44,7 +44,7 @@ class StaticText : public Window
|
||||
};
|
||||
|
||||
#define Subtitle(parent, text) \
|
||||
StaticText(parent, rect_t{}, text, COLOR_THEME_PRIMARY1 | FONT(BOLD))
|
||||
StaticText(parent, rect_t{}, text, COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD))
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -53,8 +53,8 @@ class DynamicText : public StaticText
|
||||
public:
|
||||
DynamicText(Window *parent, const rect_t &rect,
|
||||
std::function<std::string()> textHandler,
|
||||
LcdFlags textFlags = COLOR_THEME_PRIMARY1) :
|
||||
StaticText(parent, rect, "", textFlags),
|
||||
LcdColorIndex color = COLOR_THEME_PRIMARY1_INDEX, LcdFlags textFlags = 0) :
|
||||
StaticText(parent, rect, "", color, textFlags),
|
||||
textHandler(std::move(textHandler))
|
||||
{
|
||||
}
|
||||
@@ -75,9 +75,9 @@ class DynamicNumber : public StaticText
|
||||
public:
|
||||
DynamicNumber(Window *parent, const rect_t &rect,
|
||||
std::function<T()> numberHandler,
|
||||
LcdFlags textFlags = COLOR_THEME_PRIMARY1,
|
||||
LcdColorIndex color = COLOR_THEME_PRIMARY1_INDEX, LcdFlags textFlags = 0,
|
||||
const char *prefix = nullptr, const char *suffix = nullptr) :
|
||||
StaticText(parent, rect, "", textFlags),
|
||||
StaticText(parent, rect, "", color, textFlags),
|
||||
numberHandler(std::move(numberHandler)),
|
||||
prefix(prefix),
|
||||
suffix(suffix)
|
||||
@@ -122,9 +122,9 @@ class StaticIcon : public Window
|
||||
{
|
||||
public:
|
||||
StaticIcon(Window *parent, coord_t x, coord_t y, EdgeTxIcon icon,
|
||||
LcdFlags color);
|
||||
LcdColorIndex color);
|
||||
StaticIcon(Window *parent, coord_t x, coord_t y, const char* filename,
|
||||
LcdFlags color);
|
||||
LcdColorIndex color);
|
||||
|
||||
void deleteLater(bool detach = true, bool trash = true) override;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user