Skip to content

Commit

Permalink
Widgets: add default color for clock widget, initialize LedFB_GFX poi…
Browse files Browse the repository at this point in the history
…nter
  • Loading branch information
vortigont committed Feb 29, 2024
1 parent dbf39f3 commit ece5146
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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){
Expand Down
6 changes: 3 additions & 3 deletions src/widgets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class GenericGFXWidget : public GenericWidget {


protected:
LedFB_GFX *screen;
LedFB_GFX *screen = nullptr;
// буфер оверлея
std::shared_ptr<LedFB<CRGB> > overlay;

Expand All @@ -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};
};

Expand Down

0 comments on commit ece5146

Please sign in to comment.