From d0f584bb4a5e378c8dc4f589540e39836c7e0cf6 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sat, 8 Jun 2024 14:27:21 +0300 Subject: [PATCH] 2024.6.1: In `multicolor_text` mode, added the ability to reset to default color, improved documentation. --- README.md | 6 ++---- components/ehmtxv2/EHMTX.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 54b7860..cddc1cd 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`) @@ -931,8 +931,6 @@ ehmtxv2: **flip_flop_clock** (optional, boolean): Enables or disables flip_flop_clock clock mode. (default: false), works only in **advanced_clock** mode. -**flip_flop_speed** (optional, int): Set flip_flop_clock speed. (default: 2, range 1..10), works only in **advanced_clock** mode. - **advanced_bitmap** (optional, boolean): Enables or disables advanced bitmap mode. (default: false) [More info](#advanced-bitmap-mode) **default_font_yoffset** (optional, pixel): yoffset the text is aligned BASELINE_LEFT, the baseline defaults to `6` 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 {