Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update to Lvgl 8.4 #5038

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ MAIN_STACK_SIZE = 8192;
BOOTLOADER_SIZE = 0x20000;

/* Minimum Heap Size (indicative) */
MIN_HEAP_SIZE = 4096K;
MIN_HEAP_SIZE = 0;

/* SDRAM definitions */
SDRAM_START = DEFINED(__sdram_start) ? __sdram_start : 0xD0000000;
14 changes: 10 additions & 4 deletions radio/src/gui/colorlcd/LvglWrapper.cpp
Original file line number Diff line number Diff line change
@@ -331,13 +331,19 @@ static void init_lvgl_drivers()

void initLvglTheme()
{
static lv_theme_t theme;

/* Initialize the ETX theme */
lv_theme_t* th = etx_lv_theme_init(
NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
LV_FONT_DEFAULT);
theme.disp = NULL;
theme.color_primary = lv_palette_main(LV_PALETTE_BLUE);
theme.color_secondary = lv_palette_main(LV_PALETTE_RED);
theme.font_small = LV_FONT_DEFAULT;
theme.font_normal = LV_FONT_DEFAULT;
theme.font_large = LV_FONT_DEFAULT;
theme.flags = 0;

/* Assign the theme to the current display*/
lv_disp_set_theme(NULL, th);
lv_disp_set_theme(NULL, &theme);
}

LvglWrapper::LvglWrapper()
1 change: 0 additions & 1 deletion radio/src/gui/colorlcd/access_settings.cpp
Original file line number Diff line number Diff line change
@@ -370,7 +370,6 @@ RegisterDialog::RegisterDialog(Window* parent, uint8_t moduleIdx) :
start(); // clears registration data buffer
rx_name = new ModelTextEdit(line, rect_t{}, modSetup->registerRxName,
PXX2_LEN_RX_NAME);
// lv_textarea_set_text(rx_name->getLvObj(), STR_WAITING_FOR_RX);
rx_name->disable();

// Status
25 changes: 11 additions & 14 deletions radio/src/gui/colorlcd/channel_bar.cpp
Original file line number Diff line number Diff line change
@@ -41,11 +41,13 @@ ChannelBar::ChannelBar(Window* parent, const rect_t& rect,
lv_obj_set_pos(bar, width() / 2, 0);
lv_obj_set_size(bar, 0, height());

coord_t yo = (height() < 10) ? -1 : VAL_YO;

valText = lv_label_create(lvobj);
lv_obj_set_pos(valText, width() / 2 + 5, -2);
lv_obj_set_size(valText, 45, 12);
lv_obj_set_pos(valText, width() / 2 + VAL_XO, yo);
lv_obj_set_size(valText, VAL_W, VAL_H);
etx_obj_add_style(valText, styles->text_align_left, LV_PART_MAIN);
lv_obj_set_style_translate_x(valText, -54, LV_STATE_USER_1);
lv_obj_set_style_translate_x(valText, VAL_XT, LV_STATE_USER_1);
etx_obj_add_style(valText, styles->text_align_right, LV_STATE_USER_1);
etx_font(valText, FONT_XS_INDEX);
etx_txt_color(valText, indexFromColor(txtColor));
@@ -70,8 +72,6 @@ void ChannelBar::checkEvents()
if (value != newValue) {
value = newValue;

lv_obj_enable_style_refresh(false);

lv_label_set_text_fmt(valText, "%d%%", value);

if (newValue < 0)
@@ -89,9 +89,6 @@ void ChannelBar::checkEvents()

lv_obj_set_pos(bar, x, 0);
lv_obj_set_size(bar, size, height());

lv_obj_enable_style_refresh(true);
lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY);
}
}

@@ -216,31 +213,31 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
isInHeader ? COLOR_THEME_PRIMARY2 : COLOR_THEME_SECONDARY1;

outputChannelBar = new OutputChannelBar(
this, {LMARGIN, BAR_HEIGHT + TMARGIN, width() - LMARGIN, BAR_HEIGHT},
this, {ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT + ChannelBar::TMARGIN, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT},
channel, isInHeader);

new MixerChannelBar(
this,
{LMARGIN, (2 * BAR_HEIGHT) + TMARGIN + 1, width() - LMARGIN, BAR_HEIGHT},
{ChannelBar::LMARGIN, (2 * ChannelBar::BAR_HEIGHT) + ChannelBar::TMARGIN + 1, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT},
channel);

// Channel number
char chanString[] = TR_CH "32 ";
strAppendSigned(&chanString[2], channel + 1, 2);
new StaticText(this, {LMARGIN, 0, LV_SIZE_CONTENT, 12}, chanString,
new StaticText(this, {ChannelBar::LMARGIN, 0, LV_SIZE_CONTENT, 12}, chanString,
textColor | 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, {LMARGIN + 45, 0, LV_SIZE_CONTENT, 12}, nm,
new StaticText(this, {ChannelBar::LMARGIN + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm,
textColor | FONT(XS) | LEFT);
}

// Channel value in µS
new DynamicNumber<int16_t>(
this, {width() - 45, 0, 45, 12},
this, {width() - ChannelBar::VAL_W, 0, ChannelBar::VAL_W, ChannelBar::VAL_H},
[=] { return PPM_CH_CENTER(channel) + channelOutputs[channel] / 2; },
textColor | FONT(XS) | RIGHT, "", STR_US);

@@ -254,7 +251,7 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
// Channel reverted icon
LimitData* ld = limitAddress(channel);
if (ld && ld->revert) {
new StaticIcon(this, 0, 25, ICON_CHAN_MONITOR_INVERTED,
new StaticIcon(this, 0, ICON_SZ, ICON_CHAN_MONITOR_INVERTED,
textColor);
}
}
17 changes: 12 additions & 5 deletions radio/src/gui/colorlcd/channel_bar.h
Original file line number Diff line number Diff line change
@@ -23,18 +23,23 @@

#include "opentx.h"

constexpr coord_t ROW_HEIGHT = 42;
constexpr coord_t BAR_HEIGHT = 13;
constexpr coord_t LMARGIN = 15;
constexpr coord_t TMARGIN = 2;

class ChannelBar : public Window
{
public:
ChannelBar(Window* parent, const rect_t& rect,
std::function<int16_t()> getValue, LcdFlags barColor,
LcdFlags textColor = COLOR_THEME_SECONDARY1);

static LAYOUT_VAL(BAR_HEIGHT, 13, 13)
static LAYOUT_VAL(LMARGIN, 15, 15)
static LAYOUT_VAL(TMARGIN, 2, 2)

static LAYOUT_VAL(VAL_W, 45, 45)
static LAYOUT_VAL(VAL_H, 12, 12)
static LAYOUT_VAL(VAL_XO, 5, 5)
static LAYOUT_VAL(VAL_YO, -2, -2)
static LAYOUT_VAL(VAL_XT, -54, -54)

protected:
int16_t value = -10000;
std::function<int16_t()> getValue;
@@ -78,6 +83,8 @@ class ComboChannelBar : public Window
ComboChannelBar(Window* parent, const rect_t& rect, uint8_t channel,
bool isInHeader = false);

static LAYOUT_VAL(ICON_SZ, 25, 25)

protected:
uint8_t channel;
OutputChannelBar* outputChannelBar = nullptr;
25 changes: 10 additions & 15 deletions radio/src/gui/colorlcd/color_editor.cpp
Original file line number Diff line number Diff line change
@@ -23,11 +23,6 @@
#include "button.h"
#include "themes/etx_lv_theme.h"

constexpr int BAR_MARGIN = 5;

constexpr int BAR_TOP_MARGIN = 5;
constexpr int BAR_HEIGHT_OFFSET = BAR_TOP_MARGIN + 25;

static const char* const RGBChars[MAX_BARS] = {"R", "G", "B"};
static const char* const HSVChars[MAX_BARS] = {"H", "S", "V"};

@@ -170,12 +165,12 @@ class ColorBar : public Window

// draw cursor
lv_area_t cursor_area;
cursor_area.x1 = area->x1 + (lv_area_get_width(area) / 2) - 5;
cursor_area.x2 = cursor_area.x1 + 10 - 1;
cursor_area.x1 = area->x1 + (lv_area_get_width(area) / 2) - ColorEditor::CRSR_SZ / 2;
cursor_area.x2 = cursor_area.x1 + ColorEditor::CRSR_SZ - 1;

auto pos = bar->valueToScreen(bar->value);
cursor_area.y1 = area->y1 + pos - 3;
cursor_area.y2 = cursor_area.y1 + 10 - 1;
cursor_area.y1 = area->y1 + pos - ColorEditor::CRSR_YO;
cursor_area.y2 = cursor_area.y1 + ColorEditor::CRSR_SZ - 1;

lv_draw_rect_dsc_t cursor_dsc;
lv_draw_rect_dsc_init(&cursor_dsc);
@@ -274,12 +269,12 @@ BarColorType::BarColorType(Window* parent)

int leftPos = 0;
rect_t r;
r.y = BAR_TOP_MARGIN;
r.w = spacePerBar - BAR_MARGIN - 5;
r.h = parent->height() - BAR_HEIGHT_OFFSET;
r.y = ColorEditor::BAR_TOP_MARGIN;
r.w = spacePerBar - ColorEditor::BAR_MARGIN - 5;
r.h = parent->height() - (ColorEditor::BAR_TOP_MARGIN + ColorEditor::BAR_HEIGHT_OFFSET);

for (int i = 0; i < MAX_BARS; i++) {
r.x = leftPos + BAR_MARGIN;
r.x = leftPos + ColorEditor::BAR_MARGIN;

bars[i] = new ColorBar(parent, r);
leftPos += spacePerBar;
@@ -289,8 +284,8 @@ BarColorType::BarColorType(Window* parent)
auto x = bar->left();
auto y = bar->bottom();

barLabels[i] = create_bar_label(parent->getLvObj(), x, y + 9);
barValLabels[i] = create_bar_value_label(parent->getLvObj(), x + 10, y + 3);
barLabels[i] = create_bar_label(parent->getLvObj(), x, y + ColorEditor::LBL_YO);
barValLabels[i] = create_bar_value_label(parent->getLvObj(), x + ColorEditor::VAL_XO, y + ColorEditor::VAL_YO);
}
}

9 changes: 9 additions & 0 deletions radio/src/gui/colorlcd/color_editor.h
Original file line number Diff line number Diff line change
@@ -45,6 +45,15 @@ class ColorEditor : public Window

void setColorEditorType(COLOR_EDITOR_TYPE colorType);

static LAYOUT_VAL(BAR_MARGIN, 5, 5)
static LAYOUT_VAL(BAR_TOP_MARGIN, 5, 5)
static LAYOUT_VAL(BAR_HEIGHT_OFFSET, 25, 25)
static LAYOUT_VAL(LBL_YO, 9, 9)
static LAYOUT_VAL(VAL_XO, 10, 10)
static LAYOUT_VAL(VAL_YO, 3, 3)
static LAYOUT_VAL(CRSR_SZ, 10, 10)
static LAYOUT_VAL(CRSR_YO, 3, 3)

protected:
ColorType* _colorType = nullptr;
std::function<void(uint32_t)> _setValue;
33 changes: 17 additions & 16 deletions radio/src/gui/colorlcd/color_picker.cpp
Original file line number Diff line number Diff line change
@@ -25,26 +25,18 @@
#include "color_list.h"
#include "themes/etx_lv_theme.h"

// based on LVGL default switch size
constexpr lv_coord_t COLOR_PAD_WIDTH = (4 * LV_DPI_DEF) / 10;
constexpr lv_coord_t COLOR_PAD_HEIGHT = 32;

#if LCD_W > LCD_H
#if !PORTRAIT_LCD
// Landscape
static const lv_coord_t col_dsc[] = {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};

#define COLOR_EDIT_WIDTH LCD_W * 0.8

#else
// Portrait
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT,
LV_GRID_TEMPLATE_LAST};

#define COLOR_EDIT_WIDTH LCD_W * 0.7

#endif

class ColorEditorPopup : public BaseDialog
@@ -74,7 +66,7 @@ class ColorEditorPopup : public BaseDialog
FlexGridLayout grid(col_dsc, row_dsc);
auto line = form->newLine(grid);

rect_t r{0, 0, 7 * LV_DPI_DEF / 5, 7 * LV_DPI_DEF / 5};
rect_t r{0, 0, CE_SZ, CE_SZ};
auto cedit =
new ColorEditor(line, r, color, [=](uint32_t c) { updateColor(c); });
lv_obj_set_style_grid_cell_x_align(cedit->getLvObj(), LV_GRID_ALIGN_CENTER,
@@ -94,7 +86,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, 100, 0}, "", COLOR_THEME_PRIMARY1 | FONT(L));
hexStr = new StaticText(hbox, {0, 0, CVAL_W, 0}, "", COLOR_THEME_PRIMARY1 | FONT(L));

updateColor(color);

@@ -135,29 +127,38 @@ class ColorEditorPopup : public BaseDialog
hsvBtn->check(true);

hbox = new Window(vbox, rect_t{});
hbox->padTop(60);
hbox->setFlexLayout(LV_FLEX_FLOW_ROW, 20);
hbox->padTop(BTN_PAD_TOP);
hbox->setFlexLayout(LV_FLEX_FLOW_ROW, BTN_PAD_ROW);
lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER,
LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_SPACE_BETWEEN);
lv_obj_set_flex_grow(hbox->getLvObj(), 1);

new TextButton(hbox, rect_t{0, 0, 80, 0}, STR_CANCEL, [=]() -> int8_t {
new TextButton(hbox, rect_t{0, 0, BTN_W, 0}, STR_CANCEL, [=]() -> int8_t {
this->deleteLater();
return 0;
});

new TextButton(hbox, rect_t{0, 0, 80, 0}, STR_SAVE, [=]() -> int8_t {
new TextButton(hbox, rect_t{0, 0, BTN_W, 0}, STR_SAVE, [=]() -> int8_t {
if (_setValue) _setValue(m_color);
this->deleteLater();
return 0;
});
}

static LAYOUT_VAL(CE_SZ, 182, 182)
static LAYOUT_VAL(COLOR_EDIT_WIDTH, LCD_W * 0.8, LCD_W * 0.7)
static LAYOUT_VAL(COLOR_PAD_WIDTH, 52, 52)
static LAYOUT_VAL(COLOR_PAD_HEIGHT, 32, 32)
static LAYOUT_VAL(CVAL_W, 100, 100)
static LAYOUT_VAL(BTN_W, 80, 80)
static LAYOUT_VAL(BTN_PAD_TOP, 60, 60)
static LAYOUT_VAL(BTN_PAD_ROW, 20, 20)
};

ColorPicker::ColorPicker(Window* parent, const rect_t& rect,
std::function<uint16_t()> getValue,
std::function<void(uint16_t)> setValue) :
Button(parent, {0, 0, COLOR_PAD_WIDTH, COLOR_PAD_HEIGHT}),
Button(parent, {0, 0, ColorEditorPopup::COLOR_PAD_WIDTH, ColorEditorPopup::COLOR_PAD_HEIGHT}),
setValue(std::move(setValue))
{
updateColor(getValue());
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/curve_param.cpp
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,

// CURVE_REF_DIFF
// CURVE_REF_EXPO
value_edit = new GVarNumberEdit(this, rect_t{}, -100, 100, GET_DEFAULT(ref->value), setRefValue);
value_edit = new GVarNumberEdit(this, -100, 100, GET_DEFAULT(ref->value), setRefValue);
value_edit->setSuffix("%");

// CURVE_REF_FUNC
6 changes: 3 additions & 3 deletions radio/src/gui/colorlcd/curveedit.cpp
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ CurveDataEdit::CurveDataEdit(Window* parent, const rect_t& rect,
etx_scrollbar(lvobj);
}

#if LCD_W > LCD_H
#if !PORTRAIT_LCD
#define NUM_BTN_WIDTH 44
#else
#define NUM_BTN_WIDTH 48
@@ -277,7 +277,7 @@ void CurveEditWindow::buildBody(Window* window)
lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN,
LV_GRID_ALIGN_SPACE_BETWEEN);

#if LCD_H > LCD_W // portrait
#if PORTRAIT_LCD
lv_obj_set_flex_flow(line->getLvObj(), LV_FLEX_FLOW_COLUMN);
coord_t curveWidth = window->width() - 88;
coord_t boxWidth = window->width();
@@ -310,7 +310,7 @@ void CurveEditWindow::buildBody(Window* window)

// Name
new StaticText(iLine, rect_t{}, STR_NAME);
new ModelTextEdit(iLine, rect_t{0, 0, 100, 0}, curve.name,
new ModelTextEdit(iLine, rect_t{}, curve.name,
sizeof(curve.name));

// Smooth
6 changes: 3 additions & 3 deletions radio/src/gui/colorlcd/custom_failsafe.cpp
Original file line number Diff line number Diff line change
@@ -36,12 +36,12 @@ class ChannelFailsafeBargraph : public Window
etx_obj_add_style(lvobj, styles->border_thin, LV_PART_MAIN);
etx_obj_add_style(lvobj, styles->border_color_black, LV_PART_MAIN);

outputsBar = new OutputChannelBar(this, {0, 1, width() - 2, BAR_HEIGHT},
outputsBar = new OutputChannelBar(this, {0, 1, width() - 2, ChannelBar::BAR_HEIGHT},
channel, false, false);
outputsBar->hide();

failsafeBar = new ChannelBar(
this, {0, BAR_HEIGHT + 3, width() - 2, BAR_HEIGHT},
this, {0, ChannelBar::BAR_HEIGHT + 3, width() - 2, ChannelBar::BAR_HEIGHT},
[=] { return calcRESXto100(g_model.failsafeChannels[channel]); },
COLOR_THEME_WARNING, COLOR_THEME_WARNING);
failsafeBar->hide();
@@ -187,7 +187,7 @@ static void set_failsafe(lv_event_t* e)
if (combo) combo->update();
}

#if LCD_H > LCD_W
#if PORTRAIT_LCD
#define FS_BARGRAPH_WIDTH (LV_DPI_DEF / 2)
#else
#define FS_BARGRAPH_WIDTH (LV_DPI_DEF)
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/file_carosell.cpp
Original file line number Diff line number Diff line change
@@ -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, PAGE_LINE_HEIGHT}, "", CENTERED | FONT(L) | COLOR_THEME_PRIMARY1);
message = new StaticText(this, {0, rect.h/2, rect.w, EdgeTxStyles::PAGE_LINE_HEIGHT}, "", CENTERED | FONT(L) | COLOR_THEME_PRIMARY1);

setFileNames(fileNames);
}
Loading