From ece5146a907c07f30d928cc61310afa963b1f581 Mon Sep 17 00:00:00 2001 From: Emil Muratov Date: Thu, 29 Feb 2024 11:35:26 +0900 Subject: [PATCH] Widgets: add default color for clock widget, initialize LedFB_GFX pointer --- src/widgets.cpp | 6 ++++-- src/widgets.hpp | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/widgets.cpp b/src/widgets.cpp index 4f71906d..8ab36d5b 100644 --- a/src/widgets.cpp +++ b/src/widgets.cpp @@ -200,14 +200,14 @@ void ClockWidget::load_cfg(JsonVariantConst cfg){ clk.seconds_font_index = cfg[T_font2]; clk.show_seconds = cfg[T_seconds]; clk.twelwehr = cfg[T_tm_12h]; - clk.color = cfg[T_color1]; + clk.color = cfg[T_color1] | DEFAULT_TEXT_COLOR; // date date.show = cfg[T_enabled]; date.x = cfg[T_x2offset]; date.y = cfg[T_y2offset]; date.color = cfg[T_color2]; - date.font_index = cfg[T_font3]; + date.font_index = cfg[T_font3] | DEFAULT_TEXT_COLOR; if (!screen) return; // overlay is not loaded yet screen->setTextWrap(false); @@ -259,6 +259,8 @@ void ClockWidget::widgetRunner(){ // I will refresh it at least one minute just in case the date will change due to ntp events or else if (date.show && ( !date.fresh || (now - last_date>86400) ) ) _print_date(tm); + + last_date = now; } void ClockWidget::_print_clock(std::tm *tm){ diff --git a/src/widgets.hpp b/src/widgets.hpp index 9963c301..7260775d 100644 --- a/src/widgets.hpp +++ b/src/widgets.hpp @@ -121,7 +121,7 @@ class GenericGFXWidget : public GenericWidget { protected: - LedFB_GFX *screen; + LedFB_GFX *screen = nullptr; // буфер оверлея std::shared_ptr > overlay; @@ -148,10 +148,10 @@ struct Clock { bool twelwehr; // 12/24 hour clock bool fresh; // flag that indicates if date has been displayed yet or needs a refresh // max text bounds - needed to track max block size to cover the clock text - int16_t minX{32762}, minY{32762}; + int16_t minX{0x7fff}, minY{0x7fff}; uint16_t maxW{0}, maxH{0}; // same for seconds - int16_t sminX{32762}, sminY{32762}; + int16_t sminX{0x7fff}, sminY{0x7fff}; uint16_t smaxW{0}, smaxH{0}; };