From a278ea52abf4112a3f7fffb4791d56fcaefee48d Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Thu, 23 Nov 2023 21:09:38 +0200 Subject: [PATCH 1/6] 2023.9.1: Advanced Clock --- components/ehmtxv2/EHMTX.cpp | 79 ++++++++++++++++++++++++++++++ components/ehmtxv2/EHMTX.h | 12 ++++- components/ehmtxv2/EHMTX_queue.cpp | 62 +++++++++++++++-------- components/ehmtxv2/__init__.py | 7 +++ 4 files changed, 138 insertions(+), 22 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 37c9468a..f0b75f5c 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace esphome { @@ -32,6 +33,11 @@ namespace esphome this->vertical_scroll = false; #endif + #ifdef EHMTXv2_ADV_CLOCK + this->set_clock_color(); + this->set_adv_clock_color(); + #endif + for (uint8_t i = 0; i < MAXQUEUE; i++) { this->queue[i] = new EHMTX_queue(this); @@ -2070,6 +2076,79 @@ namespace esphome } } +#ifdef EHMTXv2_ADV_CLOCK + void EHMTX::set_adv_clock_color(int hr, int hg, int hb, int mr, int mg, int mb) + { + this->hour_color = Color((uint8_t)hr, (uint8_t)hg, (uint8_t)hb); + this->minutes_color = Color((uint8_t)mr, (uint8_t)mg, (uint8_t)mb); + ESP_LOGD(TAG, "advanced clock color hour: r: %d g: %d b: %d minutes: r: %d g: %d b: %d", hr, hg, hb, mr, mg, mb); + } + + bool EHMTX::draw_clock(esphome::display::BaseFont *font, Color color, int xpos, int ypos) + { + std::regex rgx {"^(%[HI])(.)(%M)(.)?(%S|%p)?$"}; + std::cmatch match; + if (!std::regex_search(EHMTXv2_TIME_FORMAT, match, rgx)) + return false; + + std::vector parts; + std::vector len; + std::string sep = ""; + + uint8_t full_length = 0; + + for (int i = 1; i < match.length(); i++) + { + std::string output = match[i].str(); + + if (output.length() > 0) + { + if (output.find("%") != std::string::npos) + { + if (output == "%p" && this->replace_time_date_active) // check for replace active + { + output = this->clock->now().strftime(output); + output = this->replace_time_date(output); + } + else + { + output = this->clock->now().strftime(output); + } + } + else if (sep == "") + { + sep = output; + } + + parts.push_back(output); + len.push_back(output.length() > 0 ? this->GetTextWidth(font, "%s", output.c_str()) : 0); + full_length += len.back(); + } + } + + uint8_t x = xpos - full_length / 2; + for (int i = 0; i < parts.size(); i++) + { + if (parts.at(i).length() > 0) + { + if (!(this->show_seconds && parts.at(i) == sep && (this->clock->now().second % 2 == 1))) + { + Color c_ = i == 0 ? this->hour_color : i == 2 ? this->minutes_color : color; + if (c_.r + c_.g + c_.b == C_BLACK) + { + c_ = color; + } + + this->display->printf(x, ypos, font, c_, display::TextAlign::BASELINE_LEFT, "%s", parts.at(i).c_str()); + } + x += len.at(i); + } + } + + return true; + } +#endif + void EHMTX::set_weekday_char_count(uint8_t i) { this->weekday_char_count = i; diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 4e91c928..03e0a262 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -113,12 +113,18 @@ namespace esphome PROGMEM Color bitmap[256]; PROGMEM Color cgauge[8]; PROGMEM EHMTX_Icon *icons[MAXICONS]; + #ifdef EHMTXv2_ADV_CLOCK + PROGMEM Color hour_color, minutes_color; + #endif #endif #ifdef USE_ESP8266 Color text_color, alarm_color, gauge_color, gauge_bgcolor,rindicator_color,lindicator_color, today_color, weekday_color, rainbow_color, clock_color, info_lcolor, info_rcolor; EHMTX_Icon *icons[MAXICONS]; uint8_t gauge_value; + #ifdef EHMTXv2_ADV_CLOCK + Color hour_color, minutes_color; + #endif #endif display::BaseFont *default_font; display::BaseFont *special_font; @@ -166,7 +172,7 @@ namespace esphome uint8_t find_icon(std::string name); uint8_t find_last_clock(); bool string_has_ending(std::string const &fullString, std::string const &ending); - void draw_day_of_week(int ypos = 0, bool small=false); + void draw_day_of_week(int ypos = 0, bool small = false); void show_all_icons(); float get_tick(); void tick(); @@ -200,6 +206,10 @@ namespace esphome void set_weekday_color(int r = CD_RED, int g = CD_GREEN, int b = CD_BLUE); void set_clock_color(int r = C_RED, int g = C_GREEN, int b = C_BLUE); void set_infotext_color(int lr = CG_GREY, int lg = CG_GREY, int lb = CG_GREY, int rr = CG_GREY, int rg = CG_GREY, int rb = CG_GREY, bool info_font = true, int y_offset = 0); + #ifdef EHMTXv2_ADV_CLOCK + bool draw_clock(esphome::display::BaseFont *font, Color color, int xpos = 0, int ypos = 0); + void set_adv_clock_color(int hr = C_BLACK, int hg = C_BLACK, int hb = C_BLACK, int mr = C_BLACK, int mg = C_BLACK, int mb = C_BLACK); + #endif void show_alarm(int r = CA_RED, int g = CA_GREEN, int b = CA_BLUE, int s = 2); void show_gauge(int v, int r = C_RED, int g = C_GREEN, int b = C_BLUE,int bgr = CG_GREY, int bgg = CG_GREY, int bgb = CG_GREY); // int because of register_service diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index f2f21ab5..57797b96 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -523,19 +523,28 @@ namespace esphome { color_ = (this->mode == MODE_RAINBOW_CLOCK) ? this->config_->rainbow_color : this->text_color; time_t ts = this->config_->clock->now().timestamp; - if (this->config_->replace_time_date_active) // check for replace active + #ifdef EHMTXv2_ADV_CLOCK + if (!this->config_->draw_clock(font, color_, xoffset + 15, this->ypos() + yoffset)) { - std::string time_new = this->config_->clock->now().strftime(EHMTXv2_TIME_FORMAT).c_str(); - time_new = this->config_->replace_time_date(time_new); - this->config_->display->printf(xoffset + 15, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str()); - } else { - this->config_->display->strftime(xoffset + 15, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_TIME_FORMAT, - this->config_->clock->now()); - } - if ((this->config_->clock->now().second % 2 == 0) && this->config_->show_seconds) - { - this->config_->display->draw_pixel_at(0, 0, color_); + #endif + if (this->config_->replace_time_date_active) // check for replace active + { + std::string time_new = this->config_->clock->now().strftime(EHMTXv2_TIME_FORMAT).c_str(); + time_new = this->config_->replace_time_date(time_new); + this->config_->display->printf(xoffset + 15, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str()); + } + else + { + this->config_->display->strftime(xoffset + 15, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_TIME_FORMAT, + this->config_->clock->now()); + } + if (this->config_->show_seconds && (this->config_->clock->now().second % 2 == 0)) + { + this->config_->display->draw_pixel_at(0, 0, color_); + } + #ifdef EHMTXv2_ADV_CLOCK } + #endif if (this->mode != MODE_RAINBOW_CLOCK) { this->config_->draw_day_of_week(this->ypos()); @@ -589,15 +598,24 @@ namespace esphome time_t ts = this->config_->clock->now().timestamp; if (this->mode == MODE_ICON_CLOCK) { - if (this->config_->replace_time_date_active) // check for replace active + #ifdef EHMTXv2_ADV_CLOCK + if (!this->config_->draw_clock(font, color_, xoffset + 19, this->ypos() + yoffset)) { - std::string time_new = this->config_->clock->now().strftime(EHMTXv2_TIME_FORMAT).c_str(); - time_new = this->config_->replace_time_date(time_new); - this->config_->display->printf(xoffset + 19, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str()); - } else { - this->config_->display->strftime(xoffset + 19, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_TIME_FORMAT, - this->config_->clock->now()); + #endif + if (this->config_->replace_time_date_active) // check for replace active + { + std::string time_new = this->config_->clock->now().strftime(EHMTXv2_TIME_FORMAT).c_str(); + time_new = this->config_->replace_time_date(time_new); + this->config_->display->printf(xoffset + 20, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str()); + } + else + { + this->config_->display->strftime(xoffset + 20, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_TIME_FORMAT, + this->config_->clock->now()); + } + #ifdef EHMTXv2_ADV_CLOCK } + #endif } else { @@ -605,9 +623,11 @@ namespace esphome { std::string time_new = this->config_->clock->now().strftime(EHMTXv2_DATE_FORMAT).c_str(); time_new = this->config_->replace_time_date(time_new); - this->config_->display->printf(xoffset + 19, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str()); - } else { - this->config_->display->strftime(xoffset + 19, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_DATE_FORMAT, + this->config_->display->printf(xoffset + 20, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str()); + } + else + { + this->config_->display->strftime(xoffset + 20, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_DATE_FORMAT, this->config_->clock->now()); } } diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index 659ff8e1..8767a26a 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -93,6 +93,7 @@ def rgb565_888(v565): CONF_SHOWDOW = "show_dow" CONF_RTL = "rtl" CONF_VERTICAL = "vertical_scroll" +CONF_CLOCK = "advanced_clock" CONF_FRAMEDURATION = "frame_duration" CONF_SCROLLCOUNT = "scroll_count" CONF_MATRIXCOMPONENT = "matrix_component" @@ -150,6 +151,9 @@ def rgb565_888(v565): ): cv.boolean, cv.Optional( CONF_VERTICAL, default=False + ): cv.boolean, + cv.Optional( + CONF_CLOCK, default=False ): cv.boolean, cv.Optional( CONF_SHOW_SECONDS, default=False @@ -521,6 +525,9 @@ def thumbnails(frames): if config[CONF_VERTICAL]: cg.add_define("EHMTXv2_USE_VERTICAL_SCROLL") + if config[CONF_CLOCK]: + cg.add_define("EHMTXv2_ADV_CLOCK") + if config[CONF_NIGHT_MODE_SCREENS]: cg.add_define("EHMTXv2_CONF_NIGHT_MODE_SCREENS",config[CONF_NIGHT_MODE_SCREENS]) From d956e0c87a9d064b1743c7d9134b797fe52f4d5e Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Thu, 23 Nov 2023 23:54:34 +0200 Subject: [PATCH 2/6] 2023.9.1: Advanced Clock --- components/ehmtxv2/EHMTX.cpp | 4 ++++ components/ehmtxv2/EHMTX.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index f0b75f5c..cf05974f 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -670,6 +670,10 @@ namespace esphome register_service(&EHMTX::fire_screen, "fire_screen", {"lifetime", "screen_time"}); #endif + #ifdef EHMTXv2_ADV_CLOCK + register_service(&EHMTX::set_adv_clock_color, "set_adv_clock_color", {"hr", "hg", "hb", "mr", "mg", "mb"}); + #endif + register_service(&EHMTX::text_screen_progress, "text_screen_progress", {"text", "value", "progress", "lifetime", "screen_time", "default_font", "value_color_as_progress", "r", "g", "b"}); register_service(&EHMTX::icon_screen_progress, "icon_screen_progress", {"icon_name", "text", "progress", "lifetime", "screen_time", "default_font", "r", "g", "b"}); register_service(&EHMTX::set_progressbar_color, "set_progressbar_color", {"icon_name", "mode", "r", "g", "b", "bg_r", "bg_g", "bg_b"}); diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 03e0a262..1005c7b7 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -207,8 +207,8 @@ namespace esphome void set_clock_color(int r = C_RED, int g = C_GREEN, int b = C_BLUE); void set_infotext_color(int lr = CG_GREY, int lg = CG_GREY, int lb = CG_GREY, int rr = CG_GREY, int rg = CG_GREY, int rb = CG_GREY, bool info_font = true, int y_offset = 0); #ifdef EHMTXv2_ADV_CLOCK - bool draw_clock(esphome::display::BaseFont *font, Color color, int xpos = 0, int ypos = 0); void set_adv_clock_color(int hr = C_BLACK, int hg = C_BLACK, int hb = C_BLACK, int mr = C_BLACK, int mg = C_BLACK, int mb = C_BLACK); + bool draw_clock(esphome::display::BaseFont *font, Color color, int xpos = 0, int ypos = 0); #endif void show_alarm(int r = CA_RED, int g = CA_GREEN, int b = CA_BLUE, int s = 2); From 1fed71b84c92d8ec708ff33bc6a9c6ed382ac442 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Fri, 24 Nov 2023 12:06:56 +0200 Subject: [PATCH 3/6] 2023.9.1: Advanced Clock - README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index fc0c6efa..b11f1f5c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ - Added `set_weekday_accent_on` and `set_weekday_accent_off` Turn on / off small days (accent) of the week when brightness is insufficient. - Added `icon_prognosis_screen` and `icon_prognosis_screen_rgb` Displays an icon, text, and a prognosis bar consisting of 24 dots of specified colors. https://github.com/lubeda/EspHoMaTriXv2/issues/149 - Added `vertical_scroll` to ehmtxv2 config. +- Added Advanced clock mode, [More info](https://github.com/lubeda/EspHoMaTriXv2/issues/164) ### EspHoMaTriX 2023.9.0 - Added the ability to display graph as defined in the YAML file @@ -622,6 +623,7 @@ This component is highly customizable. ehmtxv2:   id: rgb8x32   show_seconds: true + advanced_clock: false   matrix_component: ehmtx_display   time_component: ehmtx_time   icons2html: true @@ -652,6 +654,8 @@ ehmtxv2: **time_format** (optional, string): formats the date display with [strftime syntax](https://esphome.io/components/time.html?highlight=strftime), defaults `"%H:%M"` (use `"%I:%M%p"` for the US) +**advanced_clock** (optional, boolean): Enables or disables advanced clock mode. (default: false) [More info](https://github.com/lubeda/EspHoMaTriXv2/issues/164) + **default_font_yoffset** (optional, pixel): yoffset the text is aligned BASELINE_LEFT, the baseline defaults to `6` **default_font_xoffset** (optional, pixel): xoffset the text is aligned BASELINE_LEFT, the left defaults to `1` @@ -783,6 +787,7 @@ Numerous features are accessible with services from home assistant and lambdas t |`text_screen_progress`|"text", "value", "progress", "lifetime", "screen_time", "default_font", "value_color_as_progress", "r", "g", "b"|show the specified short text with value and with progress bar on bottom| |`icon_prognosis_screen`|"icon_name", "text", "prognosis", "lifetime", "screen_time", "default_font"|show an icon, text, and a prognosis bar consisting of 24 dots of specified colors| |`icon_prognosis_screen_rgb`|"icon_name", "text", "prognosis", "lifetime", "screen_time", "default_font", "r", "g", "b"|show an icon, text, and a prognosis bar consisting of 24 dots of specified colors| +|`set_adv_clock_color`|"hr", "hg", "hb", "mr", "mg", "mb"|available only in **advanced clock mode** `advanced_clock: true`, allows you to set the color for the Hours (hr, hg, hb) and Minutes (mr, mg, mb), color is set by analogy with `r,g,b`| #### Parameter description From 0157abad28cadb3e116818d4b93ba2ad4623aa47 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Fri, 24 Nov 2023 12:07:56 +0200 Subject: [PATCH 4/6] 2023.9.1: Advanced Clock - README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b11f1f5c..f092ada9 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ - Added `set_weekday_accent_on` and `set_weekday_accent_off` Turn on / off small days (accent) of the week when brightness is insufficient. - Added `icon_prognosis_screen` and `icon_prognosis_screen_rgb` Displays an icon, text, and a prognosis bar consisting of 24 dots of specified colors. https://github.com/lubeda/EspHoMaTriXv2/issues/149 - Added `vertical_scroll` to ehmtxv2 config. -- Added Advanced clock mode, [More info](https://github.com/lubeda/EspHoMaTriXv2/issues/164) +- Added Advanced clock mode `advanced_clock`, [More info](https://github.com/lubeda/EspHoMaTriXv2/issues/164) ### EspHoMaTriX 2023.9.0 - Added the ability to display graph as defined in the YAML file From bfd3d194a8b58b4f55ab591dd0f67a511f693c8c Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sun, 26 Nov 2023 17:03:19 +0200 Subject: [PATCH 5/6] 2023.9.1: Advanced Clock --- README.md | 5 ++++- components/ehmtxv2/EHMTX.cpp | 28 ++++++++++++++++++++------- components/ehmtxv2/EHMTX.h | 13 +++++++++---- components/ehmtxv2/EHMTX_queue.cpp | 31 ++++++++++++++++++++++-------- components/ehmtxv2/__init__.py | 11 ++++++++--- 5 files changed, 65 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index f092ada9..303f5a0b 100644 --- a/README.md +++ b/README.md @@ -654,6 +654,8 @@ ehmtxv2: **time_format** (optional, string): formats the date display with [strftime syntax](https://esphome.io/components/time.html?highlight=strftime), defaults `"%H:%M"` (use `"%I:%M%p"` for the US) +**time_format_big** (optional, string): formats the date display with [strftime syntax](https://esphome.io/components/time.html?highlight=strftime), defaults `"%H:%M:%S"`, work only in **advanced_clock** mode and sets the time format for a screen with a clock without an icon + **advanced_clock** (optional, boolean): Enables or disables advanced clock mode. (default: false) [More info](https://github.com/lubeda/EspHoMaTriXv2/issues/164) **default_font_yoffset** (optional, pixel): yoffset the text is aligned BASELINE_LEFT, the baseline defaults to `6` @@ -787,7 +789,8 @@ Numerous features are accessible with services from home assistant and lambdas t |`text_screen_progress`|"text", "value", "progress", "lifetime", "screen_time", "default_font", "value_color_as_progress", "r", "g", "b"|show the specified short text with value and with progress bar on bottom| |`icon_prognosis_screen`|"icon_name", "text", "prognosis", "lifetime", "screen_time", "default_font"|show an icon, text, and a prognosis bar consisting of 24 dots of specified colors| |`icon_prognosis_screen_rgb`|"icon_name", "text", "prognosis", "lifetime", "screen_time", "default_font", "r", "g", "b"|show an icon, text, and a prognosis bar consisting of 24 dots of specified colors| -|`set_adv_clock_color`|"hr", "hg", "hb", "mr", "mg", "mb"|available only in **advanced clock mode** `advanced_clock: true`, allows you to set the color for the Hours (hr, hg, hb) and Minutes (mr, mg, mb), color is set by analogy with `r,g,b`| +|`set_adv_clock_color`|"hr", "hg", "hb", "mr", "mg", "mb", "sr", "sg", "sb"|available only in **advanced clock mode** `advanced_clock: true`, allows you to set the color for the Hours (hr, hg, hb), Minutes (mr, mg, mb) and Spacer (sr, sg, sb), color is set by analogy with `r,g,b`. If the color is set as `black`, the standard color is used (see `set_clock_color`).| +|`set_clock_infotext_color`|"left_r", "left_g", "left_b", "right_r", "right_g", "right_b","default_font","y_offset"|set the special color for left and right char on info text on `icon clock` screen, work only in **advanced clock mode**| #### Parameter description diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index cf05974f..7a52d3e5 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -34,6 +34,9 @@ namespace esphome #endif #ifdef EHMTXv2_ADV_CLOCK + this->info_clock_lcolor = Color(CG_GREY, CG_GREY, CG_GREY); + this->info_clock_rcolor = Color(CG_GREY * 2, CG_GREY * 2, CG_GREY * 2); + this->set_clock_color(); this->set_adv_clock_color(); #endif @@ -671,7 +674,8 @@ namespace esphome #endif #ifdef EHMTXv2_ADV_CLOCK - register_service(&EHMTX::set_adv_clock_color, "set_adv_clock_color", {"hr", "hg", "hb", "mr", "mg", "mb"}); + register_service(&EHMTX::set_clock_infotext_color, "set_clock_infotext_color", {"left_r", "left_g", "left_b", "right_r", "right_g", "right_b", "default_font", "y_offset"}); + register_service(&EHMTX::set_adv_clock_color, "set_adv_clock_color", {"hr", "hg", "hb", "mr", "mg", "mb", "sr", "sg", "sb"}); #endif register_service(&EHMTX::text_screen_progress, "text_screen_progress", {"text", "value", "progress", "lifetime", "screen_time", "default_font", "value_color_as_progress", "r", "g", "b"}); @@ -2081,18 +2085,28 @@ namespace esphome } #ifdef EHMTXv2_ADV_CLOCK - void EHMTX::set_adv_clock_color(int hr, int hg, int hb, int mr, int mg, int mb) + void EHMTX::set_clock_infotext_color(int lr, int lg, int lb, int rr, int rg, int rb, bool df, int y_offset) + { + this->info_clock_lcolor = Color((uint8_t)lr, (uint8_t)lg, (uint8_t)lb); + this->info_clock_rcolor = Color((uint8_t)rr, (uint8_t)rg, (uint8_t)rb); + this->info_clock_font = df; + this->info_clock_y_offset = y_offset; + ESP_LOGD(TAG, "info clock text color left: r: %d g: %d b: %d right: r: %d g: %d b: %d y_offset %d", lr, lg, lb, rr, rg, rb, y_offset); + } + + void EHMTX::set_adv_clock_color(int hr, int hg, int hb, int mr, int mg, int mb, int sr, int sg, int sb) { this->hour_color = Color((uint8_t)hr, (uint8_t)hg, (uint8_t)hb); this->minutes_color = Color((uint8_t)mr, (uint8_t)mg, (uint8_t)mb); - ESP_LOGD(TAG, "advanced clock color hour: r: %d g: %d b: %d minutes: r: %d g: %d b: %d", hr, hg, hb, mr, mg, mb); + this->spacer_color = Color((uint8_t)sr, (uint8_t)sg, (uint8_t)sb); + ESP_LOGD(TAG, "advanced clock color hour: r: %d g: %d b: %d minutes: r: %d g: %d b: %d spacer: r: %d g: %d b: %d", hr, hg, hb, mr, mg, mb, sr, sg, sb); } - bool EHMTX::draw_clock(esphome::display::BaseFont *font, Color color, int xpos, int ypos) + bool EHMTX::draw_clock(std::string format, esphome::display::BaseFont *font, Color color, int xpos, int ypos) { std::regex rgx {"^(%[HI])(.)(%M)(.)?(%S|%p)?$"}; - std::cmatch match; - if (!std::regex_search(EHMTXv2_TIME_FORMAT, match, rgx)) + std::smatch match; + if (!std::regex_search(format, match, rgx)) return false; std::vector parts; @@ -2137,7 +2151,7 @@ namespace esphome { if (!(this->show_seconds && parts.at(i) == sep && (this->clock->now().second % 2 == 1))) { - Color c_ = i == 0 ? this->hour_color : i == 2 ? this->minutes_color : color; + Color c_ = i == 0 ? this->hour_color : i == 2 ? this->minutes_color : parts.at(i) == sep ? this->spacer_color : color; if (c_.r + c_.g + c_.b == C_BLACK) { c_ = color; diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 1005c7b7..b95f3f6b 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -108,13 +108,17 @@ namespace esphome void dump_config(); bool info_font = true; int8_t info_y_offset = 0; + #ifdef EHMTXv2_ADV_CLOCK + bool info_clock_font = true; + int8_t info_clock_y_offset = 0; + #endif #ifdef USE_ESP32 PROGMEM Color text_color, alarm_color, rindicator_color, lindicator_color, today_color, weekday_color, rainbow_color, clock_color, info_lcolor, info_rcolor; PROGMEM Color bitmap[256]; PROGMEM Color cgauge[8]; PROGMEM EHMTX_Icon *icons[MAXICONS]; #ifdef EHMTXv2_ADV_CLOCK - PROGMEM Color hour_color, minutes_color; + PROGMEM Color hour_color, minutes_color, spacer_color, info_clock_lcolor, info_clock_rcolor; #endif #endif @@ -123,7 +127,7 @@ namespace esphome EHMTX_Icon *icons[MAXICONS]; uint8_t gauge_value; #ifdef EHMTXv2_ADV_CLOCK - Color hour_color, minutes_color; + Color hour_color, minutes_color, spacer_color, info_clock_lcolor, info_clock_rcolor; #endif #endif display::BaseFont *default_font; @@ -207,8 +211,9 @@ namespace esphome void set_clock_color(int r = C_RED, int g = C_GREEN, int b = C_BLUE); void set_infotext_color(int lr = CG_GREY, int lg = CG_GREY, int lb = CG_GREY, int rr = CG_GREY, int rg = CG_GREY, int rb = CG_GREY, bool info_font = true, int y_offset = 0); #ifdef EHMTXv2_ADV_CLOCK - void set_adv_clock_color(int hr = C_BLACK, int hg = C_BLACK, int hb = C_BLACK, int mr = C_BLACK, int mg = C_BLACK, int mb = C_BLACK); - bool draw_clock(esphome::display::BaseFont *font, Color color, int xpos = 0, int ypos = 0); + void set_clock_infotext_color(int lr = CG_GREY, int lg = CG_GREY, int lb = CG_GREY, int rr = CG_GREY, int rg = CG_GREY, int rb = CG_GREY, bool info_font = true, int y_offset = 0); + void set_adv_clock_color(int hr = C_BLACK, int hg = C_BLACK, int hb = C_BLACK, int mr = C_BLACK, int mg = C_BLACK, int mb = C_BLACK, int sr = C_BLACK, int sg = C_BLACK, int sb = C_BLACK); + bool draw_clock(std::string format, esphome::display::BaseFont *font, Color color, int xpos = 0, int ypos = 0); #endif void show_alarm(int r = CA_RED, int g = CA_GREEN, int b = CA_BLUE, int s = 2); diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 57797b96..8d09542a 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -524,7 +524,7 @@ namespace esphome color_ = (this->mode == MODE_RAINBOW_CLOCK) ? this->config_->rainbow_color : this->text_color; time_t ts = this->config_->clock->now().timestamp; #ifdef EHMTXv2_ADV_CLOCK - if (!this->config_->draw_clock(font, color_, xoffset + 15, this->ypos() + yoffset)) + if (!this->config_->draw_clock(EHMTXv2_TIME_FORMAT_BIG, font, color_, xoffset + 15, this->ypos() + yoffset)) { #endif if (this->config_->replace_time_date_active) // check for replace active @@ -596,10 +596,11 @@ namespace esphome { color_ = this->text_color; time_t ts = this->config_->clock->now().timestamp; + if (this->mode == MODE_ICON_CLOCK) { #ifdef EHMTXv2_ADV_CLOCK - if (!this->config_->draw_clock(font, color_, xoffset + 19, this->ypos() + yoffset)) + if (!this->config_->draw_clock(EHMTXv2_TIME_FORMAT, font, color_, xoffset + 19, this->ypos() + yoffset)) { #endif if (this->config_->replace_time_date_active) // check for replace active @@ -639,6 +640,20 @@ namespace esphome if (this->icon_name.find("day") != std::string::npos || this->icon_name.find("weekday") != std::string::npos) { + int8_t i_y_offset = this->config_->info_y_offset; + Color i_lcolor = this->config_->info_rcolor; + Color i_rcolor = this->config_->info_rcolor; + + #ifdef EHMTXv2_ADV_CLOCK + if (this->mode == MODE_ICON_CLOCK) + { + i_y_offset = this->config_->info_clock_y_offset; + i_lcolor = this->config_->info_clock_rcolor; + i_rcolor = this->config_->info_clock_rcolor; + info_font = this->config_->info_clock_font ? this->config_->default_font : this->config_->special_font; + } + #endif + int mode = 0; std::size_t pos = icon_name.find("#"); if (pos != std::string::npos) @@ -686,12 +701,12 @@ namespace esphome if (mode == 5 && (d < 10)) { x_right = 4 - (r_width - 1) / 2; - this->config_->display->printf(x_right, this->ypos() + yoffset + this->config_->info_y_offset, info_font, this->config_->info_rcolor, display::TextAlign::BASELINE_LEFT, "%d", d % 10); + this->config_->display->printf(x_right, this->ypos() + yoffset + i_y_offset, info_font, i_rcolor, display::TextAlign::BASELINE_LEFT, "%d", d % 10); } else { - this->config_->display->printf(x_left, this->ypos() + yoffset + this->config_->info_y_offset - (mode != 3 ? 0 : 1), info_font, this->config_->info_lcolor, display::TextAlign::BASELINE_LEFT, "%d", d / 10 % 10); - this->config_->display->printf(x_right, this->ypos() + yoffset + this->config_->info_y_offset - (mode != 4 ? 0 : 1), info_font, this->config_->info_rcolor, display::TextAlign::BASELINE_LEFT, "%d", d % 10); + this->config_->display->printf(x_left, this->ypos() + yoffset + i_y_offset - (mode != 3 ? 0 : 1), info_font, i_lcolor, display::TextAlign::BASELINE_LEFT, "%d", d / 10 % 10); + this->config_->display->printf(x_right, this->ypos() + yoffset + i_y_offset - (mode != 4 ? 0 : 1), info_font, i_rcolor, display::TextAlign::BASELINE_LEFT, "%d", d % 10); } } else // if (this->icon_name.rfind("weekday", 0) == 0) @@ -728,8 +743,8 @@ namespace esphome x_right = x_right - r_width; break; } - this->config_->display->printf(x_left, this->ypos() + yoffset + this->config_->info_y_offset - (mode != 3 ? 0 : 1), info_font, this->config_->info_lcolor, display::TextAlign::BASELINE_LEFT, "%s", left.c_str()); - this->config_->display->printf(x_right, this->ypos() + yoffset + this->config_->info_y_offset - (mode != 4 ? 0 : 1), info_font, this->config_->info_rcolor, display::TextAlign::BASELINE_LEFT, "%s", right.c_str()); + this->config_->display->printf(x_left, this->ypos() + yoffset + i_y_offset - (mode != 3 ? 0 : 1), info_font, i_lcolor, display::TextAlign::BASELINE_LEFT, "%s", left.c_str()); + this->config_->display->printf(x_right, this->ypos() + yoffset + i_y_offset - (mode != 4 ? 0 : 1), info_font, i_rcolor, display::TextAlign::BASELINE_LEFT, "%s", right.c_str()); } else { @@ -738,7 +753,7 @@ namespace esphome // The symbol consists of a visible part, and an empty area to the right with a width of one point. uint8_t c_width = this->config_->GetTextWidth(info_font, "%s", weekday.c_str()); x_left = 4 - (c_width - 1) / 2; - this->config_->display->printf(x_left, this->ypos() + yoffset + this->config_->info_y_offset, info_font, this->config_->info_lcolor, display::TextAlign::BASELINE_LEFT, "%s", weekday.c_str()); + this->config_->display->printf(x_left, this->ypos() + yoffset + i_y_offset, info_font, i_lcolor, display::TextAlign::BASELINE_LEFT, "%s", weekday.c_str()); } } } diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index 8767a26a..c01e11a1 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -111,6 +111,7 @@ def rgb565_888(v565): CONF_SPECIAL_FONT_YOFFSET = "special_font_yoffset" CONF_PINGPONG = "pingpong" CONF_TIME_FORMAT = "time_format" +CONF_TIME_FORMAT_BIG = "time_format_big" CONF_DATE_FORMAT = "date_format" CONF_ON_START_RUNNING = "on_start_running" CONF_ON_EMPTY_QUEUE = "on_empty_queue" @@ -170,6 +171,9 @@ def rgb565_888(v565): cv.Optional( CONF_TIME_FORMAT, default="%H:%M" ): cv.string, + cv.Optional( + CONF_TIME_FORMAT_BIG, default="%H:%M:%S" + ): cv.string, cv.Optional( CONF_WEEKDAYTEXT, default="SOMODIMIDOFRSA" ): cv.string, @@ -260,7 +264,7 @@ def rgb565_888(v565): } ), cv.Optional(CONF_NIGHT_MODE_SCREENS, default=DEFAULT_NIGHT_MODE_SCREENS): cv.All( - cv.ensure_list(cv.one_of(1, 2, 3, 4, 5, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)), cv.Length(min=1, max=5) + cv.ensure_list(cv.one_of(1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)), cv.Length(min=1, max=5) ), cv.Required(CONF_ICONS): cv.All( cv.ensure_list( @@ -510,8 +514,9 @@ def thumbnails(frames): cg.add_define("EHMTXv2_DEFAULT_FONT_OFFSET_Y",config[CONF_DEFAULT_FONT_YOFFSET]) cg.add_define("EHMTXv2_SPECIAL_FONT_OFFSET_X",config[CONF_SPECIAL_FONT_XOFFSET]) cg.add_define("EHMTXv2_SPECIAL_FONT_OFFSET_Y",config[CONF_SPECIAL_FONT_YOFFSET]) - cg.add_define("EHMTXv2_DATE_FORMAT",config[CONF_DATE_FORMAT]) - cg.add_define("EHMTXv2_TIME_FORMAT",config[CONF_TIME_FORMAT]) + cg.add_define("EHMTXv2_DATE_FORMAT",config[CONF_DATE_FORMAT]) + cg.add_define("EHMTXv2_TIME_FORMAT",config[CONF_TIME_FORMAT]) + cg.add_define("EHMTXv2_TIME_FORMAT_BIG",config[CONF_TIME_FORMAT_BIG]) if config[CONF_SCROLL_SMALL_TEXT]: cg.add_define("EHMTXv2_SCROLL_SMALL_TEXT") From cdf50f918876c47dd0c2db2aa51a8f0df052ac74 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sun, 26 Nov 2023 18:31:00 +0200 Subject: [PATCH 6/6] 2023.9.1: Add Icon indicator. Shows the line indicator in the Icons area on the specified screens, in the specified color and at the specified vertical position. Co-authored-by: chertvl <38353584+chertvl@users.noreply.github.com> --- README.md | 28 +++++++++++++++++++ components/ehmtxv2/EHMTX.cpp | 49 ++++++++++++++++++++++++++++++++-- components/ehmtxv2/EHMTX.h | 9 +++++-- components/ehmtxv2/__init__.py | 8 ++++++ 4 files changed, 90 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 303f5a0b..335d2b8a 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ - Added `icon_prognosis_screen` and `icon_prognosis_screen_rgb` Displays an icon, text, and a prognosis bar consisting of 24 dots of specified colors. https://github.com/lubeda/EspHoMaTriXv2/issues/149 - Added `vertical_scroll` to ehmtxv2 config. - Added Advanced clock mode `advanced_clock`, [More info](https://github.com/lubeda/EspHoMaTriXv2/issues/164) +- Added `icon_indicator`, Shows the indicator in the Icons area on the specified screens, in the specified color and at the specified vertical position. ### EspHoMaTriX 2023.9.0 - Added the ability to display graph as defined in the YAML file @@ -699,6 +700,8 @@ Example: **night_mode_screens** (optional, screen array, default [2, 3, 16]): List of screens displayed in [night mode](#night-mode). +**icon_indicator_screens** (optional, screen array, default [15, 18]): List of screens on which the [icon indicator](#icon-indicator) will be displayed. + **boot_logo** (optional, string , only on ESP32): Display a fullscreen logo defined as rgb565 array. ```yaml @@ -791,6 +794,8 @@ Numerous features are accessible with services from home assistant and lambdas t |`icon_prognosis_screen_rgb`|"icon_name", "text", "prognosis", "lifetime", "screen_time", "default_font", "r", "g", "b"|show an icon, text, and a prognosis bar consisting of 24 dots of specified colors| |`set_adv_clock_color`|"hr", "hg", "hb", "mr", "mg", "mb", "sr", "sg", "sb"|available only in **advanced clock mode** `advanced_clock: true`, allows you to set the color for the Hours (hr, hg, hb), Minutes (mr, mg, mb) and Spacer (sr, sg, sb), color is set by analogy with `r,g,b`. If the color is set as `black`, the standard color is used (see `set_clock_color`).| |`set_clock_infotext_color`|"left_r", "left_g", "left_b", "right_r", "right_g", "right_b","default_font","y_offset"|set the special color for left and right char on info text on `icon clock` screen, work only in **advanced clock mode**| +|`show_icon_indicator`|"r", "g", "b", "size", "pos"|shows the line indicator in the Icons area on the specified screens, in the specified color and at the specified vertical position| +|`hide_icon_indicator`|none|hides the icon indicator| #### Parameter description @@ -812,6 +817,29 @@ Numerous features are accessible with services from home assistant and lambdas t When night mode is enabled, only the screens specified in `night_mode_screens` are displayed (**default:** 2, 3, 16) the other screens can be added, deleted, and will follow their life cycle but will not be displayed. Screen numbers in the table [mode](#modes). +### Icon Iindicator + +Shows the line indicator in the Icons area on the specified screens, in the specified color and at the specified vertical position. + +```yaml +ehmtxv2: +... + icon_indicator_screens: + - 15 +``` + +Home assistant service call: + +```yaml +service: esphome.ulanzi_show_icon_indicator +data: + r: 240 + g: 240 + b: 240 + size: 6 + pos: 7 +``` + ### Local lambdas #### Add screen to your display queue diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 7a52d3e5..7e60b79c 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -14,6 +14,8 @@ namespace esphome this->display_gauge = false; this->display_rindicator = 0; this->display_lindicator = 0; + this->display_icon_indicator = 0; + this->icon_indicator_y_pos = 7; this->display_alarm = 0; this->clock_time = 10; this->icon_count = 0; @@ -52,7 +54,7 @@ namespace esphome { if (size > 0) { - this->rindicator_color = Color((uint8_t)r , (uint8_t)g , (uint8_t)b ); + this->rindicator_color = Color((uint8_t)r , (uint8_t)g , (uint8_t)b); this->display_rindicator = size & 3; ESP_LOGD(TAG, "show rindicator size: %d r: %d g: %d b: %d", size, r, g, b); } @@ -66,7 +68,7 @@ namespace esphome { if (size > 0) { - this->lindicator_color = Color((uint8_t)r , (uint8_t)g , (uint8_t)b ); + this->lindicator_color = Color((uint8_t)r , (uint8_t)g , (uint8_t)b); this->display_lindicator = size & 3; ESP_LOGD(TAG, "show lindicator size: %d r: %d g: %d b: %d", size, r, g, b); } @@ -76,6 +78,21 @@ namespace esphome } } + void EHMTX::show_icon_indicator(int r, int g, int b, int size, int pos) + { + if (size > 0) + { + this->icon_indicator_color = Color((uint8_t)r , (uint8_t)g , (uint8_t)b); + this->display_icon_indicator = size; + this->icon_indicator_y_pos = pos; + ESP_LOGD(TAG, "show icon_indicator size: %d r: %d g: %d b: %d pos:", size, r, g, b, pos); + } + else + { + this->hide_icon_indicator(); + } + } + void EHMTX::hide_rindicator() { this->display_rindicator = 0; @@ -88,6 +105,12 @@ namespace esphome ESP_LOGD(TAG, "hide lindicator"); } + void EHMTX::hide_icon_indicator() + { + this->display_icon_indicator = 0; + ESP_LOGD(TAG, "hide icon indicator"); + } + void EHMTX::set_display_off() { this->show_display = false; @@ -669,6 +692,9 @@ namespace esphome register_service(&EHMTX::bitmap_stack, "bitmap_stack", {"icons", "lifetime", "screen_time"}); #endif + register_service(&EHMTX::show_icon_indicator, "show_icon_indicator", {"r", "g", "b", "size", "pos"}); + register_service(&EHMTX::hide_icon_indicator, "hide_icon_indicator"); + #ifdef USE_Fireplugin register_service(&EHMTX::fire_screen, "fire_screen", {"lifetime", "screen_time"}); #endif @@ -2356,6 +2382,23 @@ namespace esphome } } + void EHMTX::draw_icon_indicator() + { + if (this->display_icon_indicator > 0) + { + for (auto id : EHMTXv2_CONF_ICON_INDICATOR_SCREENS) + { + if (this->queue[this->screen_pointer]->mode == id) + { + this->display->line(4 - display_icon_indicator / 2, this->icon_indicator_y_pos, + 3 + display_icon_indicator / 2, this->icon_indicator_y_pos, + this->icon_indicator_color); + break; + } + } + } + } + void HOT EHMTX::draw() { if ((this->is_running) && (this->show_display) ) @@ -2392,6 +2435,8 @@ namespace esphome } } #endif + + this->draw_icon_indicator(); this->draw_alarm(); } } diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index b95f3f6b..3e8e994e 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -108,12 +108,13 @@ namespace esphome void dump_config(); bool info_font = true; int8_t info_y_offset = 0; + int8_t icon_indicator_y_pos = 7; #ifdef EHMTXv2_ADV_CLOCK bool info_clock_font = true; int8_t info_clock_y_offset = 0; #endif #ifdef USE_ESP32 - PROGMEM Color text_color, alarm_color, rindicator_color, lindicator_color, today_color, weekday_color, rainbow_color, clock_color, info_lcolor, info_rcolor; + PROGMEM Color text_color, alarm_color, rindicator_color, lindicator_color, today_color, weekday_color, rainbow_color, clock_color, info_lcolor, info_rcolor, icon_indicator_color; PROGMEM Color bitmap[256]; PROGMEM Color cgauge[8]; PROGMEM EHMTX_Icon *icons[MAXICONS]; @@ -123,7 +124,7 @@ namespace esphome #endif #ifdef USE_ESP8266 - Color text_color, alarm_color, gauge_color, gauge_bgcolor,rindicator_color,lindicator_color, today_color, weekday_color, rainbow_color, clock_color, info_lcolor, info_rcolor; + Color text_color, alarm_color, gauge_color, gauge_bgcolor, rindicator_color, lindicator_color, today_color, weekday_color, rainbow_color, clock_color, info_lcolor, info_rcolor, icon_indicator_color; EHMTX_Icon *icons[MAXICONS]; uint8_t gauge_value; #ifdef EHMTXv2_ADV_CLOCK @@ -134,6 +135,7 @@ namespace esphome display::BaseFont *special_font; int display_rindicator; int display_lindicator; + int display_icon_indicator; int display_alarm; uint8_t ticks_per_second=62; bool display_gauge; @@ -205,6 +207,7 @@ namespace esphome void show_rindicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 3); void show_lindicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 3); + void show_icon_indicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 6, int pos = 7); void set_text_color(int r = C_RED, int g = C_GREEN, int b = C_BLUE); void set_today_color(int r = C_RED, int g = C_GREEN, int b = C_BLUE); void set_weekday_color(int r = CD_RED, int g = CD_GREEN, int b = CD_BLUE); @@ -221,6 +224,7 @@ namespace esphome void hide_gauge(); void hide_rindicator(); void hide_lindicator(); + void hide_icon_indicator(); void hide_alarm(); void full_screen(std::string icon, int lifetime = D_LIFETIME, int screen_time = D_SCREEN_TIME); void icon_screen(std::string icon, std::string text, int lifetime = D_LIFETIME, int screen_time = D_SCREEN_TIME, bool default_font = true, int r = C_RED, int g = C_GREEN, int b = C_BLUE); @@ -258,6 +262,7 @@ namespace esphome void draw_alarm(); void draw_rindicator(); void draw_lindicator(); + void draw_icon_indicator(); void set_replace_time_date_active(bool b=false); void set_weekday_char_count(uint8_t i); diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index c01e11a1..42fc55e3 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -133,6 +133,8 @@ def rgb565_888(v565): CONF_GRAPH = "display_graph" CONF_NIGHT_MODE_SCREENS = "night_mode_screens" DEFAULT_NIGHT_MODE_SCREENS = [2,3,16] +CONF_ICON_INDICATOR_SCREENS = "icon_indicator_screens" +DEFAULT_ICON_INDICATOR_SCREENS = [15,18] EHMTX_SCHEMA = cv.Schema({ cv.Required(CONF_ID): cv.declare_id(EHMTX_), @@ -266,6 +268,9 @@ def rgb565_888(v565): cv.Optional(CONF_NIGHT_MODE_SCREENS, default=DEFAULT_NIGHT_MODE_SCREENS): cv.All( cv.ensure_list(cv.one_of(1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)), cv.Length(min=1, max=5) ), + cv.Optional(CONF_ICON_INDICATOR_SCREENS, default=DEFAULT_ICON_INDICATOR_SCREENS): cv.All( + cv.ensure_list(cv.one_of(1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)), cv.Length(min=1, max=5) + ), cv.Required(CONF_ICONS): cv.All( cv.ensure_list( { @@ -536,6 +541,9 @@ def thumbnails(frames): if config[CONF_NIGHT_MODE_SCREENS]: cg.add_define("EHMTXv2_CONF_NIGHT_MODE_SCREENS",config[CONF_NIGHT_MODE_SCREENS]) + if config[CONF_ICON_INDICATOR_SCREENS]: + cg.add_define("EHMTXv2_CONF_ICON_INDICATOR_SCREENS",config[CONF_ICON_INDICATOR_SCREENS]) + cg.add(var.set_show_day_of_week(config[CONF_SHOWDOW])) cg.add(var.set_show_seconds(config[CONF_SHOW_SECONDS]))