From 4b026b2693853951fef95335925e1366e26aa904 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sat, 8 Jun 2024 14:27:21 +0300 Subject: [PATCH 1/3] 2024.6.1: In `multicolor_text` mode, added the ability to reset to default color, improved documentation. --- README.md | 4 ++-- components/ehmtxv2/EHMTX.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 54b7860..fb52389 100644 --- a/README.md +++ b/README.md @@ -387,14 +387,14 @@ ehmtxv2: service: esphome.ulanzi_text_screen data: default_font: true - text: "Test Test #00FF00Test #FF0000Test #0000FFTest" + text: "Default Color Text #00FF00Green Color Text #FF0000Red Color Text #0000FFBlue Color Text #000000Default Color Text" lifetime: 2 screen_time: 10 r: 255 g: 255 b: 255 ``` -Shows text in different colors, `Test Test` in the default color `#FFFFFF` (r: 255, g:255, b: 255), followed by `Test` in green `#00FF00`, then `Test` in red `#FF0000` and finally `Test` in blue `#0000FF`. +Shows text in different colors, `Default Color Text` in the default color `#FFFFFF` (r: 255, g:255, b: 255), followed by `Green Color Text` in green `#00FF00`, then `Red Color Text` in red `#FF0000`, then `Blue Color Text` in blue `#0000FF` and finally `Default Color Text` in default color, due `#000000`. **icons2html** (optional, boolean): If true, generate the HTML-file (*filename*.html) to show all included icons. (default = `false`) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 3086d16..d870e54 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -2840,7 +2840,14 @@ namespace esphome int r, g, b; if (res.at(i).length() == 7 && std::regex_match(res.at(i), is_color) && sscanf(&res.at(i).c_str()[1], "%02x%02x%02x", &r, &g, &b)) { - c = Color(r, g ,b); + if (r + g + b > 0) + { + c = Color(r, g ,b); + } + else + { + c = color; + } } else { From 06c083c4e843ffb3cd488579d30d1979e384ecfd Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sat, 8 Jun 2024 14:43:40 +0300 Subject: [PATCH 2/3] 2024.6.1: Add WARNING for `multicolor_text` mode. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index fb52389..e053521 100644 --- a/README.md +++ b/README.md @@ -396,6 +396,12 @@ data: ``` Shows text in different colors, `Default Color Text` in the default color `#FFFFFF` (r: 255, g:255, b: 255), followed by `Green Color Text` in green `#00FF00`, then `Red Color Text` in red `#FF0000`, then `Blue Color Text` in blue `#0000FF` and finally `Default Color Text` in default color, due `#000000`. +> [!WARNING] +> In this mode, with a large number of color changes, or with long lines, a short-term decrease in performance is possible. +> +> ```[13:26:02][W][component:237]: Component display took a long time for an operation (55 ms).``` +> ```[13:26:02][W][component:238]: Components should block for at most 30 ms.``` + **icons2html** (optional, boolean): If true, generate the HTML-file (*filename*.html) to show all included icons. (default = `false`) **iconscache** (optional, boolean): If true, it caches icons in the `.cache\icons` folder and if it finds the specified icons in the cache, it uses them instead of trying to download them again from the Internet. (default = `false`) From b9793d2f88e0d03671c96b647040c2b4bc2c9910 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sat, 8 Jun 2024 15:33:44 +0300 Subject: [PATCH 3/3] 2024.6.1: Cosmetic --- components/ehmtxv2/EHMTX.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index d870e54..0cfd3c1 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -2637,8 +2637,8 @@ namespace esphome } else { - this->display->printf(x, ypos, font, c_, display::TextAlign::BASELINE_LEFT, "%s", parts.at(i).c_str()); - } + this->display->printf(x, ypos, font, c_, display::TextAlign::BASELINE_LEFT, "%s", parts.at(i).c_str()); + } } else if (i == 2) // Minutes {