Skip to content

Commit 59b9686

Browse files
philmozpfeerick
authored andcommitted
feat(color): telemetry queues for Lua, enhance default widget options (#5926)
1 parent 0461e42 commit 59b9686

30 files changed

+1054
-713
lines changed

radio/src/gui/colorlcd/libui/list_line_button.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void InputMixButtonBase::setSource(mixsrc_t idx)
109109
else
110110
lv_obj_clear_state(source, LV_STATE_USER_1);
111111

112-
lv_label_set_text(source, s);
112+
lv_label_set_text(source, s);
113113
}
114114

115115
void InputMixButtonBase::setOpts(const char* s)

radio/src/gui/colorlcd/mainview/layout.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class LayoutFactory
4949

5050
virtual const uint8_t* getBitmap() const = 0;
5151

52-
virtual const ZoneOption* getOptions() const = 0;
52+
virtual const ZoneOption* getLayoutOptions() const = 0;
5353

5454
virtual WidgetsContainer* create(
5555
Window* parent, LayoutPersistentData* persistentData) const = 0;

radio/src/gui/colorlcd/mainview/layout_factory_impl.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ class Layout: public LayoutBase
9898
return getOptionValue(LAYOUT_OPTION_MIRRORED)->boolValue;
9999
}
100100

101-
virtual bool isAppMode() const { return false; }
102-
103101
// Set decoration visibility
104102
void setTrimsVisible(bool visible);
105103
void setSlidersVisible(bool visible);
@@ -182,7 +180,7 @@ class BaseLayoutFactory: public LayoutFactory
182180

183181
const uint8_t* getBitmap() const override { return bitmap; }
184182

185-
const ZoneOption * getOptions() const override
183+
const ZoneOption * getLayoutOptions() const override
186184
{
187185
return options;
188186
}

radio/src/gui/colorlcd/mainview/screen_setup.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ void ScreenSetupPage::buildLayoutOptions()
327327
if (!factory) return;
328328

329329
int index = 0;
330-
for (auto* option = factory->getOptions(); option->name; option++, index++) {
330+
for (auto* option = factory->getLayoutOptions(); option->name; option++, index++) {
331331
auto layoutData = &g_model.screenData[customScreenIndex].layoutData;
332332
ZoneOptionValue* value = &layoutData->options[index].value;
333333

radio/src/gui/colorlcd/mainview/widget.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ void Widget::openMenu()
5757
return;
5858
}
5959

60-
if (getOptions() || fsAllowed) {
60+
if (hasOptions() || fsAllowed) {
6161
Menu* menu = new Menu();
6262
menu->setTitle(getFactory()->getDisplayName());
6363
if (fsAllowed) {
6464
menu->addLine(STR_WIDGET_FULLSCREEN, [&]() { setFullscreen(true); });
6565
}
66-
if (getOptions() && getOptions()->name) {
66+
if (hasOptions()) {
6767
menu->addLine(STR_WIDGET_SETTINGS,
6868
[=]() { new WidgetSettings(this); });
6969
}
@@ -146,9 +146,9 @@ bool Widget::onLongPress()
146146
return true;
147147
}
148148

149-
const ZoneOption* Widget::getOptions() const
149+
const ZoneOption* Widget::getOptionDefinitions() const
150150
{
151-
return getFactory()->getOptions();
151+
return getFactory()->getDefaultOptions();
152152
}
153153

154154
void Widget::enableFocus(bool enable)
@@ -253,6 +253,7 @@ void WidgetFactory::initPersistentData(Widget::PersistentData* persistentData,
253253
{
254254
if (setDefault) {
255255
memset(persistentData, 0, sizeof(Widget::PersistentData));
256+
parseOptionDefaults();
256257
}
257258
if (options) {
258259
int i = 0;

radio/src/gui/colorlcd/mainview/widget.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class Widget : public ButtonBase
4242

4343
const WidgetFactory* getFactory() const { return factory; }
4444

45-
const ZoneOption* getOptions() const;
45+
const ZoneOption* getOptionDefinitions() const;
46+
bool hasOptions() const { return getOptionDefinitions() && getOptionDefinitions()->name; }
4647

4748
virtual const char* getErrorMessage() const { return nullptr; }
4849

@@ -117,7 +118,8 @@ class WidgetFactory
117118

118119
const char* getName() const { return name; }
119120

120-
const ZoneOption* getOptions() const { return options; }
121+
const ZoneOption* getDefaultOptions() const { return options; }
122+
virtual const void parseOptionDefaults() const {}
121123

122124
const char* getDisplayName() const
123125
{

radio/src/gui/colorlcd/mainview/widget_settings.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ WidgetSettings::WidgetSettings(Widget* w) :
4949
FlexGridLayout grid(line_col_dsc, line_row_dsc, PAD_TINY);
5050

5151
uint8_t optIdx = 0;
52-
auto opt = widget->getOptions();
52+
auto opt = widget->getOptionDefinitions();
53+
5354
while (opt && opt->name != nullptr) {
5455
auto line = form->newLine(grid);
5556

radio/src/gui/colorlcd/mainview/widgets_container.h

+1
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@ class WidgetsContainer: public Window
8585
virtual void runBackground() = 0;
8686

8787
virtual bool isLayout() { return false; }
88+
virtual bool isAppMode() const { return false; }
8889
bool isWidgetsContainer() override { return true; }
8990
};

radio/src/gui/colorlcd/mainview/widgets_setup.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SetupWidgetsPageSlot::SetupWidgetsPageSlot(Window* parent, const rect_t& rect,
4141
menu->addLine(STR_SELECT_WIDGET,
4242
[=]() { addNewWidget(container, slotIndex); });
4343
auto widget = container->getWidget(slotIndex);
44-
if (widget->getOptions() && widget->getOptions()->name)
44+
if (widget->hasOptions())
4545
menu->addLine(STR_WIDGET_SETTINGS,
4646
[=]() { new WidgetSettings(widget); });
4747
menu->addLine(STR_REMOVE_WIDGET,
@@ -103,7 +103,7 @@ void SetupWidgetsPageSlot::addNewWidget(WidgetsContainer* container,
103103
menu->addLine(factory->getDisplayName(), [=]() {
104104
container->createWidget(slotIndex, factory);
105105
auto widget = container->getWidget(slotIndex);
106-
if (widget->getOptions() && widget->getOptions()->name)
106+
if (widget->hasOptions())
107107
new WidgetSettings(widget);
108108
});
109109
if (cur && strcmp(cur, factory->getDisplayName()) == 0)

radio/src/gui/colorlcd/standalone_lua.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ StandaloneLuaWindow::StandaloneLuaWindow(bool useLvgl, int initFn, int runFn) :
133133

134134
etx_solid_bg(lvobj);
135135

136+
luaScriptManager = this;
137+
136138
if (useLvglLayout()) {
137139
padAll(PAD_ZERO);
138140
etx_scrollbar(lvobj);
@@ -146,8 +148,6 @@ StandaloneLuaWindow::StandaloneLuaWindow(bool useLvgl, int initFn, int runFn) :
146148
lv_obj_set_style_text_align(lbl, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
147149
lv_obj_set_style_pad_top(lbl, (LCD_H - EdgeTxStyles::PAGE_LINE_HEIGHT) / 2, LV_PART_MAIN);
148150
lv_label_set_text(lbl, STR_LOADING);
149-
150-
luaLvglManager = this;
151151
} else {
152152
lcdBuffer = new BitmapBuffer(BMP_RGB565, LCD_W, LCD_H);
153153

@@ -218,7 +218,7 @@ void StandaloneLuaWindow::deleteLater(bool detach, bool trash)
218218
if (lcdBuffer) delete lcdBuffer;
219219
lcdBuffer = nullptr;
220220

221-
luaLvglManager = nullptr;
221+
luaScriptManager = nullptr;
222222

223223
Layer::pop(this);
224224
Layer::back()->show();
@@ -320,13 +320,13 @@ void StandaloneLuaWindow::checkEvents()
320320
luaLcdAllowed = false;
321321
}
322322

323-
void StandaloneLuaWindow::onClicked() { Keyboard::hide(false); LuaEventHandler::onClicked(); }
323+
void StandaloneLuaWindow::onClicked() { Keyboard::hide(false); LuaScriptManager::onClickedEvent(); }
324324

325-
void StandaloneLuaWindow::onCancel() { LuaEventHandler::onCancel(); }
325+
void StandaloneLuaWindow::onCancel() { LuaScriptManager::onCancelEvent(); }
326326

327327
void StandaloneLuaWindow::onEvent(event_t evt)
328328
{
329-
LuaEventHandler::onLuaEvent(evt);
329+
LuaScriptManager::onLuaEvent(evt);
330330
}
331331

332332
void StandaloneLuaWindow::popupPaint(BitmapBuffer* dc, coord_t x, coord_t y, coord_t w, coord_t h,

radio/src/gui/colorlcd/standalone_lua.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
extern void luaExecStandalone(const char * filename);
3030

31-
class StandaloneLuaWindow : public Window, public LuaEventHandler, public LuaLvglManager
31+
class StandaloneLuaWindow : public Window, public LuaScriptManager
3232
{
3333
static StandaloneLuaWindow* _instance;
3434

radio/src/lua/api_colorlcd.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#define BITMAP_METATABLE "BITMAP*"
3737

3838
BitmapBuffer* luaLcdBuffer = nullptr;
39-
LuaWidget *runningFS = nullptr;
4039

4140
/*luadoc
4241
@function lcd.refresh()
@@ -1386,8 +1385,8 @@ Exit full screen widget mode.
13861385
*/
13871386
static int luaLcdExitFullScreen(lua_State *L)
13881387
{
1389-
if (runningFS)
1390-
runningFS->closeFullscreen();
1388+
if (luaScriptManager)
1389+
luaScriptManager->exitFullscreen();
13911390
return 0;
13921391
}
13931392

0 commit comments

Comments
 (0)