Skip to content

Commit

Permalink
prep 2024.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lubeda committed Dec 11, 2024
1 parent 07e9dd1 commit 31d78aa
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 113 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2024.12.1
- prepared for esphome 2024.12.0
- removed multicolor_text

## 2024.5.0
- changed on_empty_queue behavior (triggered every 15 sec after first occurance)

Expand Down
46 changes: 17 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@
> [!TIP]
> If you like this project, please donate a star on GitHub and consider [sponsoring](https://www.paypal.com/donate/?hosted_button_id=FZDKSLQ46HJTU) me 🙏 !
## Important breaking news

The latest esphome releases introduced a lot of problems with my code. So my advice alway use the latest version of this tool and use it directly from the repo, like this:

```yaml
external_components:
- source:
type: git
url: https://github.com/lubeda/EspHoMaTriXv2
ref: 2024.12.1
refresh: 60s
components: [ ehmtxv2 ]
```
Use the `ref` parameter to select the right version. **But** when there are breaking changes in esphome you have to expect breaking changes in EspHoMaTriX too (at least some funnny workarounds)

## Important breaking news for ulanzi TC001 users

With the ulanzi-hardware and esphome 2024.2.0 you have to remove all the rtttl stuff to make things work!!!
Expand Down Expand Up @@ -373,35 +389,6 @@ Example:

**rainbow_shimmer** (optional, boolean): If true, enables color shimmer when displaying text in rainbow modes.

**multicolor_text** (optional, boolean): If true, enables text multi color support when displaying text.

Example:
```Yaml
ehmtxv2:
id: rgb8x32
...
multicolor_text: true
```

```Yaml
service: esphome.ulanzi_text_screen
data:
default_font: true
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, `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`)
Expand Down Expand Up @@ -1849,3 +1836,4 @@ THE SOFTWARE IS PROVIDED “AS IS”, use at your own risk!
## Special thanks to all sponsors
As of the 6/1/2024 there were only six of them. 😿
67 changes: 0 additions & 67 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2890,74 +2890,7 @@ namespace esphome

void EHMTX::draw_text(std::string text, esphome::display::BaseFont *font, Color color, int xpos, int ypos)
{
#ifdef EHMTXv2_MULTICOLOR_TEXT
std::size_t pos = text.find("#");
if (pos == std::string::npos)
{
this->display->print(xpos, ypos, font, color, esphome::display::TextAlign::BASELINE_LEFT, text.c_str());
return;
}

std::regex regex ("(#[A-Fa-f0-9]{6})|(.+?)");

std::regex_iterator<std::string::iterator> next ( text.begin(), text.end(), regex );
std::regex_iterator<std::string::iterator> end;

std::vector<std::string> res;

std::string iter = "";
while (next != end)
{
std::string part = next->str();
if (part.length() == 7)
{
if (iter.length() > 0)
{
res.push_back (iter);
iter = "";
}
res.push_back (part);
}
else
{
iter += part;
}
next++;
}
if (iter.length() > 0)
{
res.push_back (iter);
}

Color c = color;
int x = xpos;
std::regex is_color ("^#[A-Fa-f0-9]{6}$");
for (int i = 0; i < res.size(); i++)
{
if (res.at(i).length() > 0)
{
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))
{
if (r + g + b > 0)
{
c = Color(r, g ,b);
}
else
{
c = color;
}
}
else
{
this->display->print(x, ypos, font, c, esphome::display::TextAlign::BASELINE_LEFT, res.at(i).c_str());
x += this->GetTextWidth(font, "%s", res.at(i).c_str());
}
}
}
#else
this->display->print(xpos, ypos, font, color, esphome::display::TextAlign::BASELINE_LEFT, text.c_str());
#endif
}

#ifdef EHMTXv2_RAINBOW_SHIMMER
Expand Down
7 changes: 0 additions & 7 deletions components/ehmtxv2/EHMTX_queue.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include "esphome.h"
#ifdef EHMTXv2_MULTICOLOR_TEXT
#include <regex>
#endif

namespace esphome
{
Expand Down Expand Up @@ -1232,10 +1229,6 @@ namespace esphome
uint16_t max_steps = 0;

std::string text_ = text;
#ifdef EHMTXv2_MULTICOLOR_TEXT
std::regex color_re("(#[A-Fa-f0-9]{6})");
text_ = std::regex_replace(text, color_re, "");
#endif

if (this->default_font)
{
Expand Down
7 changes: 0 additions & 7 deletions components/ehmtxv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def rgb565_888(v565):
CONF_BLENDSTEPS = "blend_steps"
CONF_RAINBOWINTERVAL = "rainbow_interval"
CONF_RAINBOWSHIMMER = "rainbow_shimmer"
CONF_MULTICOLOR_TEXT = "multicolor_text"
CONF_FRAMEINTERVAL = "frame_interval"
CONF_DEFAULT_FONT_ID = "default_font_id"
CONF_DEFAULT_FONT = "default_font"
Expand Down Expand Up @@ -242,8 +241,6 @@ def rgb565_888(v565):
): cv.templatable(cv.positive_int),
cv.Optional(CONF_RAINBOWSHIMMER, default=False
): cv.boolean,
cv.Optional(CONF_MULTICOLOR_TEXT, default=False
): cv.boolean,
cv.Optional(CONF_SCROLLCOUNT, default="2"
): cv.templatable(cv.positive_int),
cv.Optional(
Expand Down Expand Up @@ -616,10 +613,6 @@ def thumbnails(frames):
cg.add_define("EHMTXv2_RAINBOW_SHIMMER")
logging.info(f"[X] Rainbow shimmer")

if config[CONF_MULTICOLOR_TEXT]:
cg.add_define("EHMTXv2_MULTICOLOR_TEXT")
logging.info(f"[X] Multi color text")

if config[CONF_SCROLL_SMALL_TEXT]:
cg.add_define("EHMTXv2_SCROLL_SMALL_TEXT")

Expand Down
5 changes: 2 additions & 3 deletions install/ulanzi-easy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ external_components:
- source:
type: git
url: https://github.com/lubeda/EspHoMaTriXv2
ref: "2024.12.0"
ref: "2024.12.1"
refresh: 600s
components: [ ehmtxv2 ]

Expand All @@ -67,7 +67,7 @@ esphome:
name: $devicename
project:
name: "Ulanzi.EHMTXv2"
version: "2024.12.0"
version: "2024.12.1"
on_boot:
then:
- ds1307.read_time:
Expand Down Expand Up @@ -229,7 +229,6 @@ ehmtxv2:
show_seconds: false
default_font_id: px6_font
default_font_yoffset: 7
multicolor_text: true
special_font_id: px6_font
special_font_yoffset: 7
# until here
Expand Down

0 comments on commit 31d78aa

Please sign in to comment.