diff --git a/radio/src/gui/colorlcd/layouts/layout_factory_impl.h b/radio/src/gui/colorlcd/layouts/layout_factory_impl.h index 1272b772f..30738471e 100644 --- a/radio/src/gui/colorlcd/layouts/layout_factory_impl.h +++ b/radio/src/gui/colorlcd/layouts/layout_factory_impl.h @@ -101,7 +101,7 @@ class Layout: public LayoutBase ViewMainDecoration* decoration = nullptr; // Decoration settings bitmask to detect updates - uint8_t decorationSettings = 0; + uint8_t decorationSettings = 255; // Last time we refreshed the window uint32_t lastRefresh = 0; diff --git a/radio/src/gui/colorlcd/view_main_decoration.cpp b/radio/src/gui/colorlcd/view_main_decoration.cpp index 0041acb8c..3e0bcbfbc 100644 --- a/radio/src/gui/colorlcd/view_main_decoration.cpp +++ b/radio/src/gui/colorlcd/view_main_decoration.cpp @@ -66,6 +66,13 @@ void ViewMainDecoration::setSlidersVisible(bool visible) sliders[SLIDERS_EXT2]->setWidth(visible ? TRIM_SQUARE_SIZE : 0); } #endif + + if (visible) { + visibilityMask |= VM_SLIDERS; + } + else { + visibilityMask &= ~VM_SLIDERS; + } } void ViewMainDecoration::setTrimsVisible(bool visible) @@ -75,11 +82,25 @@ void ViewMainDecoration::setTrimsVisible(bool visible) trims[TRIMS_LV]->setWidth(visible ? TRIM_SQUARE_SIZE : 0); trims[TRIMS_RV]->setWidth(visible ? TRIM_SQUARE_SIZE : 0); + + if (visible) { + visibilityMask |= VM_TRIMS; + } + else { + visibilityMask &= ~VM_TRIMS; + } } void ViewMainDecoration::setFlightModeVisible(bool visible) { flightMode->setHeight(visible ? FM_LABEL_HEIGHT : 0); + + if (visible) { + visibilityMask |= VM_FM; + } + else { + visibilityMask &= ~VM_FM; + } } void ViewMainDecoration::adjustDecoration() @@ -191,13 +212,14 @@ void ViewMainDecoration::adjustDecoration() rect_t ViewMainDecoration::getMainZone() const { + coord_t border = (getVisibilityMask() == VM_NONE ? + 0 : MAIN_ZONE_BORDER); rect_t zone = { - trims[TRIMS_LV]->right() + MAIN_ZONE_BORDER, - /*topbar->bottom() +*/ MAIN_ZONE_BORDER, + trims[TRIMS_LV]->right() + border, border, 0, 0 // let's compute them! }; - zone.w = trims[TRIMS_RV]->left() - MAIN_ZONE_BORDER - zone.x; + zone.w = trims[TRIMS_RV]->left() - border - zone.x; // min(trims[TRIMS_LH]->top(), flightMode->top()) if (trims[TRIMS_LH]->top() < flightMode->top()) @@ -205,7 +227,7 @@ rect_t ViewMainDecoration::getMainZone() const else zone.h = flightMode->top(); - zone.h -= MAIN_ZONE_BORDER + zone.y; + zone.h -= border + zone.y; return zone; } diff --git a/radio/src/gui/colorlcd/view_main_decoration.h b/radio/src/gui/colorlcd/view_main_decoration.h index d0e951d24..0fe743cfb 100644 --- a/radio/src/gui/colorlcd/view_main_decoration.h +++ b/radio/src/gui/colorlcd/view_main_decoration.h @@ -47,6 +47,19 @@ class ViewMainDecoration: public Window // (without decoration) rect_t getMainZone() const; + enum VisibilityMask { + VM_NONE = 0, + VM_TRIMS = 1 << 0, + VM_SLIDERS = 1 << 1, + VM_FM = 1 << 2, + VM_ALL = VM_TRIMS | VM_SLIDERS | VM_FM, + }; + + unsigned getVisibilityMask() const + { + return visibilityMask; + } + protected: #if defined(DEBUG_WINDOWS) @@ -78,6 +91,7 @@ class ViewMainDecoration: public Window Window* sliders[SLIDERS_MAX]; Window* trims[TRIMS_MAX]; Window* flightMode; + unsigned visibilityMask = VM_NONE; void createSliders(); void createTrims(); diff --git a/radio/src/gui/colorlcd/widget_settings.cpp b/radio/src/gui/colorlcd/widget_settings.cpp index 4d05cd7e1..35f34b55b 100644 --- a/radio/src/gui/colorlcd/widget_settings.cpp +++ b/radio/src/gui/colorlcd/widget_settings.cpp @@ -128,7 +128,6 @@ WidgetSettings::WidgetSettings(Window * parent, Widget * widget) : break; case ZoneOption::Color: - for (uint8_t part = 0; part < 3; part++) new ColorEdit(form, grid.getFieldSlot(), [=]() -> int { // getValue return (int) widget->getOptionValue(optIdx)->unsignedValue; diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index a7c8f0e0a..7167fc7e8 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -1888,8 +1888,10 @@ const luaR_value_entry opentxConstants[] = { { "TITLE_BGCOLOR", COLOR2FLAGS(TITLE_BGCOLOR_INDEX) }, // Synonyms of the above colors + { "TEXT_COLOR", COLOR2FLAGS(DEFAULT_COLOR_INDEX) }, { "TEXT_BGCOLOR", COLOR2FLAGS(DEFAULT_BGCOLOR_INDEX) }, - + { "WARNING_COLOR", COLOR2FLAGS(HIGHLIGHT_COLOR_INDEX) }, + { "WHITE", (double)WHITE }, { "GREY", (double)GREY }, { "DARKGREY", (double)DARKGREY }, diff --git a/radio/src/lua/widgets.cpp b/radio/src/lua/widgets.cpp index afb0f27da..9f2d130db 100644 --- a/radio/src/lua/widgets.cpp +++ b/radio/src/lua/widgets.cpp @@ -31,6 +31,8 @@ #define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (20000/100) #define LUA_WARNING_INFO_LEN 64 +constexpr int LUA_WIDGET_REFRESH = 1000 / 10; // 10 Hz + lua_State * lsWidgets = NULL; extern int custom_lua_atpanic(lua_State *L); @@ -177,6 +179,13 @@ class LuaWidget: public Widget free(errorMessage); } +#if defined(DEBUG_WINDOWS) + std::string getName() const override + { + return "LuaWidget"; + } +#endif + // Window interface void paint(BitmapBuffer * dc) override; @@ -191,7 +200,9 @@ class LuaWidget: public Widget protected: int luaWidgetDataRef; char * errorMessage; + uint32_t lastRefresh = 0; + void checkEvents() override; void setErrorMessage(const char * funcName); }; @@ -253,6 +264,21 @@ class LuaWidgetFactory: public WidgetFactory int backgroundFunction; }; +void LuaWidget::checkEvents() +{ + Widget::checkEvents(); + + uint32_t now = RTOS_GET_MS(); + if (now - lastRefresh >= LUA_WIDGET_REFRESH) { + lastRefresh = now; + invalidate(); + +#if defined(DEBUG_WINDOWS) + TRACE_WINDOWS("# refresh: %s", getWindowDebugString().c_str()); +#endif + } +} + void LuaWidget::paint(BitmapBuffer * dc) { refresh(dc);