Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024.6.1: In multicolor_text mode, added the ability to reset to default color, improved documentation. #238

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,20 @@ 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`.

> [!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`)

Expand Down
13 changes: 10 additions & 3 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
Loading