From b62daefb6569381d63ecae0bda78a67f2dcb6d6b Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 10 Jun 2023 11:59:49 +0200 Subject: [PATCH 01/10] prepare 2023.6.5 --- CHANGELOG.md | 4 ++++ README.md | 2 ++ components/ehmtxv2/EHMTX.cpp | 13 ++++++++++++- components/ehmtxv2/EHMTX.h | 2 +- components/ehmtxv2/__init__.py | 5 +++++ tests/ehtmxv2-special.yaml | 1 + 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6689ee3..1a7d3efa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2023.6.5 + +- introduced `blend_steps: ` + ## 2023.6.4 - introduced `scroll_small_text` diff --git a/README.md b/README.md index 2d75b46b..bf02a2a8 100644 --- a/README.md +++ b/README.md @@ -537,6 +537,8 @@ ehmtxv2: **show_dow** (optional, bool): draw the day of week rindicator on the bottom of the clock screen. Disable, e.g., if you want larger fonts, defaults to true. +**blend_steps** (optional, int): on screen transition you can blend in the new screen, a value of 16 works nice, defaults 0. + **time_component** (required, ID): ID of the time component. The display shows `!t!` until the time source is valid. **default_font** (required, ID): ID of the default font diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 4e183dcf..373afeb4 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -505,7 +505,8 @@ namespace esphome this->remove_expired_queue_element(); this->screen_pointer = this->find_last_clock(); this->scroll_step = 0; - + this->ticks_ = 0; + if (this->screen_pointer == MAXQUEUE) { this->screen_pointer = find_oldest_queue_element(); @@ -547,6 +548,16 @@ namespace esphome } } } + // blend handling + + #ifdef EHMTXv2_BLEND_STEPS + if (this->ticks_<=EHMTXv2_BLEND_STEPS) { + uint8_t b = this->brightness_; + float br = lerp((float)this->ticks_/ EHMTXv2_BLEND_STEPS, 0,(float) b/255); + this->display->get_light()->set_correction(br, br, br); + } + #endif + this->ticks_++; } else { diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index c340c1a4..d9cde6a6 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -22,7 +22,7 @@ const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); const uint16_t POLLINGINTERVAL = 250; -static const char *const EHMTX_VERSION = "2023.6.4"; +static const char *const EHMTX_VERSION = "2023.6.5"; static const char *const TAG = "EHMTXv2"; #ifndef USE_ESP8266 static const char *const EHMTX_LOGO = "[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,63519,63519,63519,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,0,0,0,0,2016,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,63488,0,63488,0,0,0,63519,0,0,0,0,2016,2016,0,0,0,65514,0,65514,0,0,0,31,0,0,0,64512,0,0,64512,0,63488,63488,0,63488,63488,0,0,63519,63519,63519,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,31,31,31,0,0,0,64512,64512,0,0,63488,63488,63488,63488,63488,0,0,63519,0,0,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,31,0,0,0,0,64512,64512,0,0,0,63488,63488,63488,0,0,0,63519,63519,63519,63519,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,0,31,31,0,64512,0,0,64512,0,0,0,63488,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"; diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index 9a7f53e4..d31e1fe3 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -73,6 +73,7 @@ def rgb565_svg(x,y,r,g,b): CONF_MATRIXCOMPONENT = "matrix_component" CONF_HTML = "icons2html" CONF_SCROLLINTERVAL = "scroll_interval" +CONF_BLENDSTEPS = "blend_steps" CONF_RAINBOWINTERVAL = "rainbow_interval" CONF_FRAMEINTERVAL = "frame_interval" CONF_DEFAULT_FONT_ID = "default_font_id" @@ -157,6 +158,8 @@ def rgb565_svg(x,y,r,g,b): ): cv.templatable(cv.int_range(min=-32, max=32)), cv.Optional(CONF_SCROLLINTERVAL, default="80" ): cv.templatable(cv.positive_int), + cv.Optional(CONF_BLENDSTEPS, default="0" + ): cv.templatable(cv.positive_int), cv.Optional(CONF_RAINBOWINTERVAL, default="32" ): cv.templatable(cv.positive_int), cv.Optional(CONF_SCROLLCOUNT, default="2" @@ -392,6 +395,8 @@ def thumbnails(frames): cg.add_define("EHMTXv2_TIME_FORMAT",config[CONF_TIME_FORMAT]) cg.add_define("EHMTXv2_SCROLL_SMALL_TEXT",config[CONF_SCROLL_SMALL_TEXT]) cg.add_define("EHMTXv2_ALLOW_EMPTY_SCREEN",config[CONF_ALLOW_EMPTY_SCREEN]) + if (config[CONF_BLENDSTEPS]) >0: + cg.add_define("EHMTXv2_BLEND_STEPS",config[CONF_BLENDSTEPS]) if config[CONF_RTL]: cg.add_define("EHMTXv2_USE_RTL") diff --git a/tests/ehtmxv2-special.yaml b/tests/ehtmxv2-special.yaml index b6c8239b..e321eb5e 100644 --- a/tests/ehtmxv2-special.yaml +++ b/tests/ehtmxv2-special.yaml @@ -123,6 +123,7 @@ ehmtxv2: scroll_small_text: true default_clock_font: false allow_empty_screen: true + blend_steps: 16 frame_interval: 210 rtl: true default_font_id: default_font From 216a3a5c2217d1a9d6206bec4f03e9886942f318 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 10 Jun 2023 14:03:16 +0200 Subject: [PATCH 02/10] lindicator rindicator alarm --- 8x32 iMAGE.xcf | Bin 8970 -> 9412 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/8x32 iMAGE.xcf b/8x32 iMAGE.xcf index aafe1322440990ef5db6b2482249f6bb7ba9f33f..8ececd6e4425953249ecd88f552e33428854422f 100644 GIT binary patch delta 523 zcmYjNJxIe)5YBrEwS|iPfok%SnAS?DbjcuY;tv&da&nAR9IVtL#l03p#7VeGad1_1 zkbstgxaev@!BHn6P<3&Zc*$$E5AOT!?z`jO-ND@b!r=_5U(KdS{7DF&c*{972^(Z0 z9pe#ea@K(J@IL2}9cYqyXbqI1LYGJj?kJPnTnjLa=o>y!gsAoa4RO3vKLtlpj5Og~ zV)6^G3D7`{@L2kCUZpJp?`Z>@O3qtoFP=!0OO>@!z8YY$T&!-wVki%v;zhj9+qx*P zL!2eSmcwKhy%d#CpeD1Tr3pU;%VGj4P)inQVMXxHbZ#zcw(Fv1Qx`S6M>A3LOcOPa zny7gidf4Y-4f@n$g5>#mSRVSOtiLn8kFp%PgJjyN$=iggH-Ccq9Q;ddJ2`eqsD6wW zR22QXy8&{~3H3)Os;MGPf54cbD4EV>gW^#{mA7RK$2L|e&H76xBO=dcPyJD;Y=eh_ IP$U2L3xv6JO#lD@ delta 374 zcmX@&+2uCDiLqg$vlye`DF!fL-U^}F%qC|snoB}B4AM6t4B2xKTJhNALyR7i_bacN zyp2gf_Bd1-h~j`^7Kj+rck_L=Ho?jAQcsv9gC{FW3v)s>O6CK3VoZ|l zn=PeF7@4I0B1=k30(s($hMOPDtYwswc>ppR3eX%c^9SsBSrMS)k8bXk4`-57FoLNC v(yBl#1H@2U75pYCi7_dpZI)0SZLpdtbQgAGFN From 12a4ba8b2488e6b1be6f2bc29c17c397da371d7c Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 10 Jun 2023 19:51:13 +0200 Subject: [PATCH 03/10] color_gauge (WIP) --- CHANGELOG.md | 3 +- components/ehmtxv2/EHMTX.cpp | 37 ++++++++++ components/ehmtxv2/EHMTX.h | 2 + copy2esphome/EHMTX_easy_color_gauge.yaml | 88 ++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 copy2esphome/EHMTX_easy_color_gauge.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a7d3efa..065d3a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## 2023.6.5 -- introduced `blend_steps: ` +- introduced `blend_steps: 16` +- introduced service color_gauge (WIP) ## 2023.6.4 diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 373afeb4..0d42a432 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -244,6 +244,30 @@ namespace esphome } } +#ifndef USE_ESP8266 + void EHMTX::color_gauge(std::string text) + { + ESP_LOGD(TAG, "color_gauge: %s",text.c_str()); + const size_t CAPACITY = JSON_ARRAY_SIZE(8); + StaticJsonDocument doc; + deserializeJson(doc, text); + JsonArray array = doc.as(); + uint8_t i=0; + for (JsonVariant v : array) + { + uint16_t buf = v.as(); + + unsigned char b = (((buf)&0x001F) << 3); + unsigned char g = (((buf)&0x07E0) >> 3); // Fixed: shift >> 5 and << 2 + unsigned char r = (((buf)&0xF800) >> 8); // shift >> 11 and << 3 + Color c = Color(r, g, b); + this->cgauge[i++] = c; + this->display_gauge = true; + } + } +#endif + +#ifdef USE_ESP8266 void EHMTX::draw_gauge() { if (this->display_gauge) @@ -253,6 +277,18 @@ namespace esphome this->display->line(0, 7, 0, this->gauge_value, this->gauge_color); } } +#else + void EHMTX::draw_gauge() + { + if (this->display_gauge) + { + for (uint8_t y=0;y<8;y++){ + this->display->draw_pixel_at(0, y, this->cgauge[y]); + } + this->display->line(1, 7, 1, 0, esphome::display::COLOR_OFF); + } + } +#endif void EHMTX::setup() { @@ -295,6 +331,7 @@ namespace esphome register_service(&EHMTX::set_brightness, "brightness", {"value"}); #ifndef USE_ESP8266 + register_service(&EHMTX::color_gauge, "color_gauge", {"colors"}); register_service(&EHMTX::bitmap_screen, "bitmap_screen", {"icon", "lifetime", "screen_time"}); register_service(&EHMTX::bitmap_small, "bitmap_small", {"icon", "text", "lifetime", "screen_time", "default_font", "r", "g", "b"}); #endif diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index d9cde6a6..0343c140 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -82,6 +82,7 @@ namespace esphome PROGMEM Color text_color, alarm_color, gauge_color, gauge_bgcolor, rindicator_color, lindicator_color,clock_color, today_color, weekday_color, rainbow_color; PROGMEM Color bitmap[256]; PROGMEM Color sbitmap[64]; + PROGMEM Color cgauge[8]; PROGMEM EHMTX_Icon *icons[MAXICONS]; #endif @@ -165,6 +166,7 @@ namespace esphome void blank_screen(int lifetime = D_LIFETIME, int screen_time = D_SCREEN_TIME); void bitmap_screen(std::string text, int lifetime = D_LIFETIME, int screen_time = D_SCREEN_TIME); + void color_gauge(std::string text); void bitmap_small(std::string, std::string,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); void rainbow_icon_screen(std::string icon_name, std::string text, int lifetime = D_LIFETIME, int screen_time = D_SCREEN_TIME, bool default_font = true); void rainbow_text_screen(std::string text, int lifetime = D_LIFETIME, int screen_time = D_SCREEN_TIME, bool default_font = true); diff --git a/copy2esphome/EHMTX_easy_color_gauge.yaml b/copy2esphome/EHMTX_easy_color_gauge.yaml new file mode 100644 index 00000000..abee53c3 --- /dev/null +++ b/copy2esphome/EHMTX_easy_color_gauge.yaml @@ -0,0 +1,88 @@ +blueprint: + name: |- + ehmtxv2: colored bar/gauge at the left side + description: |- + feed this function with eight rgb565 values, to convert from rgb888 see this: + {{ (((red | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((green | bitwise_and(0xfC)) / 4 )| int) * 32 + ((blue | bitwise_and(0xf8)) / 8 )| int }} + domain: script + + input: + ehmtx_device: + name: Which EspHoMaTriX-device to display at? + selector: + device: + integration: esphome + pix0_color: + name: Color of pixel 1 + selector: + color_rgb: + default: [240, 24, 240] + pix1_color: + name: Color of pixel 2 + selector: + color_rgb: + default: [240, 240, 24] + pix2_color: + name: Color of pixel 3 + selector: + color_rgb: + default: [24, 24, 240] + pix3_color: + name: Color of pixel 4 + selector: + color_rgb: + default: [240, 24, 24] + pix4_color: + name: Color of pixel 5 + selector: + color_rgb: + default: [24, 240, 24] + pix5_color: + name: Color of pixel 6 + selector: + color_rgb: + default: [120, 240, 240] + pix6_color: + name: Color of pixel 7 + selector: + color_rgb: + default: [240, 120, 240] + pix7_color: + name: Color of pixel 8 + selector: + color_rgb: + default: [240, 120, 120] + +variables: + display: !input ehmtx_device + pix0: !input pix0_color + pix1: !input pix1_color + pix2: !input pix2_color + pix3: !input pix3_color + pix4: !input pix4_color + pix5: !input pix5_color + pix6: !input pix6_color + pix7: !input pix7_color + c0: |- + {{ (((pix0[0] | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((pix0[1] | bitwise_and(0xfC)) / 4 )| int) * 32 + ((pix0[2] | bitwise_and(0xf8)) / 8 )| int }} + c1: |- + {{ (((pix1[0] | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((pix1[1] | bitwise_and(0xfC)) / 4 )| int) * 32 + ((pix1[2] | bitwise_and(0xf8)) / 8 )| int }} + c2: |- + {{ (((pix2[0] | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((pix2[1] | bitwise_and(0xfC)) / 4 )| int) * 32 + ((pix2[2] | bitwise_and(0xf8)) / 8 )| int }} + c3: |- + {{ (((pix3[0] | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((pix3[1] | bitwise_and(0xfC)) / 4 )| int) * 32 + ((pix3[2] | bitwise_and(0xf8)) / 8 )| int }} + c4: |- + {{ (((pix4[0] | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((pix4[1] | bitwise_and(0xfC)) / 4 )| int) * 32 + ((pix4[2] | bitwise_and(0xf8)) / 8 )| int }} + c5: |- + {{ (((pix5[0] | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((pix5[1] | bitwise_and(0xfC)) / 4 )| int) * 32 + ((pix5[2] | bitwise_and(0xf8)) / 8 )| int }} + c6: |- + {{ (((pix6[0] | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((pix6[1] | bitwise_and(0xfC)) / 4 )| int) * 32 + ((pix6[2] | bitwise_and(0xf8)) / 8 )| int }} + c7: |- + {{ (((pix7[0] | bitwise_and(0xf8)) / 8) | int ) * 2048 + (((pix7[1] | bitwise_and(0xfC)) / 4 )| int) * 32 + ((pix7[2] | bitwise_and(0xf8)) / 8 )| int }} + +sequence: + - service: |- + esphome.{{ device_attr(display, "name") }}_color_gauge + data: + colors: |- + [{{c0}},{{c1}},{{c2}},{{c3}},{{c4}},{{c5}},{{c6}},{{c7}}] From 3ebd756e5495f28d046355b31ea5795f96fcfa2c Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 11 Jun 2023 10:49:45 +0200 Subject: [PATCH 04/10] wiki for videos --- wiki/sucess-stories.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 wiki/sucess-stories.md diff --git a/wiki/sucess-stories.md b/wiki/sucess-stories.md new file mode 100644 index 00000000..b61d7c3e --- /dev/null +++ b/wiki/sucess-stories.md @@ -0,0 +1,5 @@ +# People who succesfully use EspHoMaTriX and EspHoMaTriXv2 + +## Videos in german +- [Wetterwarnungen](https://smarthomeyourself.de/wiki/templates/alle-aktuelle-wetterwarnungen-in-home-assistant-ausgeben-mit-templates/) + \ No newline at end of file From 6e6b388a7f49ec97d7f1108598a9b3d3c18e2043 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 11 Jun 2023 18:18:21 +0200 Subject: [PATCH 05/10] before removing extra offset --- CHANGELOG.md | 5 ---- components/ehmtxv2/EHMTX.cpp | 48 +++++++++++++++++++++--------- components/ehmtxv2/EHMTX.h | 5 ++-- components/ehmtxv2/EHMTX_queue.cpp | 4 +++ 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 065d3a6a..7cfcf991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,6 @@ - introduced `blend_steps: 16` - introduced service color_gauge (WIP) -## 2023.6.4 - -- introduced `scroll_small_text` -- introduced `allow_empty_screen` - ## 2023.6.3 - introduced `default_clock_font: true` diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 0d42a432..4ed8fb44 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -20,8 +20,6 @@ namespace esphome this->clock_color = Color(C_RED, C_GREEN, C_BLUE); this->rainbow_color = Color(CA_RED, CA_GREEN, CA_BLUE); this->alarm_color = Color(CA_RED, CA_GREEN, CA_BLUE); - this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE); - this->gauge_value = 0; this->next_action_time = 0; this->last_scroll_time = 0; this->screen_pointer = MAXQUEUE; @@ -232,18 +230,6 @@ namespace esphome ESP_LOGD(TAG, "hide gauge"); } - void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int bg_b) - { - this->display_gauge = false; - if (percent <= 100) - { - this->gauge_color = Color(r, g, b); - this->gauge_bgcolor = Color(bg_r, bg_g, bg_b); - this->display_gauge = true; - this->gauge_value = (uint8_t)(100 - percent) * 7 / 100; - } - } - #ifndef USE_ESP8266 void EHMTX::color_gauge(std::string text) { @@ -265,8 +251,42 @@ namespace esphome this->display_gauge = true; } } + + void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int bg_b) + { + if (percent <= 100) + { + Color c = Color(r, g, b); + Color bgc = Color(bg_r, bg_g, bg_b); + for (uint8_t i =0 ; i<8;i++){ + if (percent > i * 12.5) { + this->cgauge[7-i] = c; + } else { + this->cgauge[7-i] = bgc; + } + + } + this->display_gauge = true; + ESP_LOGD(TAG, "show_gauge 2 color %d", round(percent)); + } + + } +#else +void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int bg_b) + { + this->display_gauge = false; + if (percent <= 100) + { + this->gauge_color = Color(r, g, b); + this->gauge_bgcolor = Color(bg_r, bg_g, bg_b); + this->display_gauge = true; + this->gauge_value = (uint8_t)(100 - percent) * 7 / 100; + } + ESP_LOGD(TAG, "show_gauge 2 color %d", round(percent)); + } #endif + #ifdef USE_ESP8266 void EHMTX::draw_gauge() { diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 0343c140..26c6c3b8 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -79,7 +79,7 @@ namespace esphome uint16_t hue_ = 0; void dump_config(); #ifdef USE_ESP32 - PROGMEM Color text_color, alarm_color, gauge_color, gauge_bgcolor, rindicator_color, lindicator_color,clock_color, today_color, weekday_color, rainbow_color; + PROGMEM Color text_color, alarm_color, rindicator_color, lindicator_color,clock_color, today_color, weekday_color, rainbow_color; PROGMEM Color bitmap[256]; PROGMEM Color sbitmap[64]; PROGMEM Color cgauge[8]; @@ -89,6 +89,7 @@ namespace esphome #ifdef USE_ESP8266 Color text_color, alarm_color, gauge_color, gauge_bgcolor,rindicator_color,lindicator_color, clock_color, today_color, weekday_color, rainbow_color; EHMTX_Icon *icons[MAXICONS]; + uint8_t gauge_value; #endif display::Font *default_font; display::Font *special_font; @@ -99,7 +100,7 @@ namespace esphome bool display_gauge; bool is_running = false; bool show_date; - uint8_t gauge_value; + uint16_t clock_time; uint16_t scroll_step; diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 277ec587..11ab9b08 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -173,6 +173,10 @@ namespace esphome { extraoffset = TEXTSTARTOFFSET; } + if (this->config_->display_gauge) + { + extraoffset += 2; + } color_ = this->text_color; #ifdef EHMTXv2_USE_RTL this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, From c2427b6423b57193e387f06457c1bc2e90f51470 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 11 Jun 2023 18:25:01 +0200 Subject: [PATCH 06/10] color_guage --- CHANGELOG.md | 3 +- components/ehmtxv2/EHMTX_queue.cpp | 106 ++++++++++++----------------- 2 files changed, 46 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cfcf991..295fe06d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ## 2023.6.5 - introduced `blend_steps: 16` -- introduced service color_gauge (WIP) +- introduced service color_gauge +- fixed bitmap_small with gauge ## 2023.6.3 diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 11ab9b08..9dd744a5 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -105,18 +105,18 @@ namespace esphome result = startx + this->config_->scroll_step; } #else - #ifdef EHMTXv2_SCROLL_SMALL_TEXT - result = startx - this->config_->scroll_step + width; - #else - if (this->pixels_ < width) - { - result = startx + ceil((width - this->pixels_) / 2); - } - else - { - result = startx - this->config_->scroll_step + width; - } - #endif +#ifdef EHMTXv2_SCROLL_SMALL_TEXT + result = startx - this->config_->scroll_step + width; +#else + if (this->pixels_ < width) + { + result = startx + ceil((width - this->pixels_) / 2); + } + else + { + result = startx - this->config_->scroll_step + width; + } +#endif #endif return result; } @@ -148,7 +148,7 @@ namespace esphome display::Font *font = this->default_font ? this->config_->default_font : this->config_->special_font; int8_t yoffset = this->default_font ? EHMTXv2_DEFAULT_FONT_OFFSET_Y : EHMTXv2_SPECIAL_FONT_OFFSET_Y; int8_t xoffset = this->default_font ? EHMTXv2_DEFAULT_FONT_OFFSET_X : EHMTXv2_SPECIAL_FONT_OFFSET_X; - int8_t extraoffset = 0; + Color color_; if (this->config_->is_running) { @@ -169,37 +169,37 @@ namespace esphome } break; case MODE_BITMAP_SMALL: - if (this->pixels_ > TEXTSTARTOFFSET) - { - extraoffset = TEXTSTARTOFFSET; - } - if (this->config_->display_gauge) - { - extraoffset += 2; - } color_ = this->text_color; #ifdef EHMTXv2_USE_RTL - this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, - this->text.c_str()); + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, + this->text.c_str()); #else - this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, - this->text.c_str()); + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + this->text.c_str()); #endif if (this->config_->display_gauge) { this->config_->display->line(10, 0, 10, 7, esphome::display::COLOR_OFF); + for (uint8_t x = 0; x < 8; x++) + { + for (uint8_t y = 0; y < 8; y++) + { + this->config_->display->draw_pixel_at(x + 2, y, this->config_->sbitmap[x + y * 8]); + } + } } else { this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF); - } - for (uint8_t x = 0; x < 8; x++) - { - for (uint8_t y = 0; y < 8; y++) + for (uint8_t x = 0; x < 8; x++) { - this->config_->display->draw_pixel_at(x, y, this->config_->sbitmap[x + y * 8]); + for (uint8_t y = 0; y < 8; y++) + { + this->config_->display->draw_pixel_at(x, y, this->config_->sbitmap[x + y * 8]); + } } } + break; #endif case MODE_RAINBOW_CLOCK: @@ -230,7 +230,7 @@ namespace esphome { color_ = (this->mode == MODE_RAINBOW_DATE) ? this->config_->rainbow_color : this->config_->clock_color; time_t ts = this->config_->clock->now().timestamp; - this->config_->display->strftime(xoffset + 15, yoffset, font, color_, display::TextAlign::BASELINE_CENTER,EHMTXv2_DATE_FORMAT , + this->config_->display->strftime(xoffset + 15, yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_DATE_FORMAT, this->config_->clock->now()); if ((this->config_->clock->now().second % 2 == 0) && this->config_->show_seconds) { @@ -252,22 +252,13 @@ namespace esphome case MODE_ICON_SCREEN: case MODE_RAINBOW_ICON: { - if (this->pixels_ > TEXTSTARTOFFSET) - { - extraoffset = TEXTSTARTOFFSET; - } - if (this->config_->display_gauge) - { - extraoffset += 2; - } - color_ = (this->mode == MODE_RAINBOW_ICON) ? this->config_->rainbow_color : this->text_color; #ifdef EHMTXv2_USE_RTL - this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, - this->text.c_str()); + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, + this->text.c_str()); #else - this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, - this->text.c_str()); + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + this->text.c_str()); #endif if (this->config_->display_gauge) { @@ -283,22 +274,13 @@ namespace esphome break; case MODE_TEXT_SCREEN: case MODE_RAINBOW_TEXT: - - if (this->pixels_ > 32) - { - extraoffset = 32; - } - if (this->config_->display_gauge) - { - extraoffset += 2; - } color_ = (this->mode == MODE_RAINBOW_TEXT) ? this->config_->rainbow_color : this->text_color; #ifdef EHMTXv2_USE_RTL - this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, - this->text.c_str()); + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, + this->text.c_str()); #else - this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, - this->text.c_str()); + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + this->text.c_str()); #endif break; default: @@ -333,17 +315,17 @@ namespace esphome { this->config_->display->get_text_bounds(0, 0, text.c_str(), this->config_->special_font, display::TextAlign::LEFT, &x, &y, &w, &h); } - + this->pixels_ = w; - + switch (this->mode) { case MODE_RAINBOW_TEXT: case MODE_TEXT_SCREEN: #ifdef EHMTXv2_SCROLL_SMALL_TEXT - max_steps = (EHMTXv2_SCROLL_COUNT + 1) * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; - display_duration = ceil((max_steps * EHMTXv2_SCROLL_INTERVALL) / 1000); - this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; + max_steps = (EHMTXv2_SCROLL_COUNT + 1) * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; + display_duration = ceil((max_steps * EHMTXv2_SCROLL_INTERVALL) / 1000); + this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; #else if (this->pixels_ < 32) { From c11338591431b1e3b2fa9770534ec56a5aac1e34 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Wed, 14 Jun 2023 19:15:33 +0200 Subject: [PATCH 07/10] fixed del_screen --- CHANGELOG.md | 1 + components/ehmtxv2/EHMTX.cpp | 63 ++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 295fe06d..0261a1b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - introduced `blend_steps: 16` - introduced service color_gauge - fixed bitmap_small with gauge +- fixed del_screen with "*" ## 2023.6.3 diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 4ed8fb44..77852945 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -195,6 +195,7 @@ namespace esphome ESP_LOGW(TAG, "bitmap_screen is not available on ESP8266"); } #endif + uint8_t EHMTX::find_icon(std::string name) { for (uint8_t i = 0; i < this->icon_count; i++) @@ -233,12 +234,12 @@ namespace esphome #ifndef USE_ESP8266 void EHMTX::color_gauge(std::string text) { - ESP_LOGD(TAG, "color_gauge: %s",text.c_str()); + ESP_LOGD(TAG, "color_gauge: %s", text.c_str()); const size_t CAPACITY = JSON_ARRAY_SIZE(8); StaticJsonDocument doc; deserializeJson(doc, text); JsonArray array = doc.as(); - uint8_t i=0; + uint8_t i = 0; for (JsonVariant v : array) { uint16_t buf = v.as(); @@ -258,21 +259,23 @@ namespace esphome { Color c = Color(r, g, b); Color bgc = Color(bg_r, bg_g, bg_b); - for (uint8_t i =0 ; i<8;i++){ - if (percent > i * 12.5) { - this->cgauge[7-i] = c; - } else { - this->cgauge[7-i] = bgc; + for (uint8_t i = 0; i < 8; i++) + { + if (percent > i * 12.5) + { + this->cgauge[7 - i] = c; + } + else + { + this->cgauge[7 - i] = bgc; } - } this->display_gauge = true; ESP_LOGD(TAG, "show_gauge 2 color %d", round(percent)); } - } #else -void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int bg_b) + void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int bg_b) { this->display_gauge = false; if (percent <= 100) @@ -286,7 +289,6 @@ void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int } #endif - #ifdef USE_ESP8266 void EHMTX::draw_gauge() { @@ -302,7 +304,8 @@ void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int { if (this->display_gauge) { - for (uint8_t y=0;y<8;y++){ + for (uint8_t y = 0; y < 8; y++) + { this->display->draw_pixel_at(0, y, this->cgauge[y]); } this->display->line(1, 7, 1, 0, esphome::display::COLOR_OFF); @@ -563,7 +566,7 @@ void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int this->screen_pointer = this->find_last_clock(); this->scroll_step = 0; this->ticks_ = 0; - + if (this->screen_pointer == MAXQUEUE) { this->screen_pointer = find_oldest_queue_element(); @@ -596,7 +599,7 @@ void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int } else { - if(!EHMTXv2_ALLOW_EMPTY_SCREEN) + if (!EHMTXv2_ALLOW_EMPTY_SCREEN) { ESP_LOGW(TAG, "tick: nothing to do. Restarting clock display!"); this->clock_screen(24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); @@ -606,14 +609,15 @@ void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int } } // blend handling - - #ifdef EHMTXv2_BLEND_STEPS - if (this->ticks_<=EHMTXv2_BLEND_STEPS) { + +#ifdef EHMTXv2_BLEND_STEPS + if (this->ticks_ <= EHMTXv2_BLEND_STEPS) + { uint8_t b = this->brightness_; - float br = lerp((float)this->ticks_/ EHMTXv2_BLEND_STEPS, 0,(float) b/255); + float br = lerp((float)this->ticks_ / EHMTXv2_BLEND_STEPS, 0, (float)b / 255); this->display->get_light()->set_correction(br, br, br); } - #endif +#endif this->ticks_++; } else @@ -688,17 +692,26 @@ void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int if (this->queue[i]->mode == mode) { bool force = true; - ESP_LOGW(TAG, "del_screen: icon %s in position: %d mode %d", icon_name.c_str(), i, mode); + ESP_LOGD(TAG, "del_screen: icon %s in position: %s mode %d", icon_name.c_str(), this->queue[i]->icon_name.c_str(), mode); if ((mode == MODE_ICON_SCREEN) || (mode == MODE_FULL_SCREEN) || (mode == MODE_RAINBOW_ICON)) { - if (strcmp(this->queue[i]->icon_name.c_str(), icon_name.c_str()) != 0) + if (this->string_has_ending(icon_name, "*")) + { + std::string comparename = icon_name.substr(0, icon_name.length() - 1); + + if (this->queue[i]->icon_name.rfind(comparename, 0) != 0) + { + force = false; + } + } + else if(strcmp(this->queue[i]->icon_name.c_str(), icon_name.c_str()) != 0) { force = false; } } if (force) { - ESP_LOGW(TAG, "del_screen: force"); + ESP_LOGW(TAG, "del_screen: slot %d deleted",i); this->queue[i]->mode = MODE_EMPTY; this->queue[i]->endtime = 0; if (i == this->screen_pointer) @@ -1032,9 +1045,9 @@ void EHMTX::show_gauge(int percent, int r, int g, int b, int bg_r, int bg_g, int { ESP_LOGCONFIG(TAG, "show date"); } - #ifdef EHMTXv2_USE_RTL - ESP_LOGCONFIG(TAG, "RTL activated"); - #endif +#ifdef EHMTXv2_USE_RTL + ESP_LOGCONFIG(TAG, "RTL activated"); +#endif if (EHMTXv2_WEEK_START) { ESP_LOGCONFIG(TAG, "weekstart: monday"); From 65e6be054a9fd7ab10917bbbac8e5f8a9bed4a6b Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Wed, 14 Jun 2023 19:49:12 +0200 Subject: [PATCH 08/10] docu --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bf02a2a8..4d1e3758 100644 --- a/README.md +++ b/README.md @@ -802,7 +802,7 @@ For example, if you have multiple icons named weather_sunny, weather_rain & weat *Parameters:* - ```icon_name```: Icon `id` defined in the YAML (see installation) -- ```mode```: The mode is for internal purposes use `5`  for icon_screen +- ```mode```: The mode is a filter to select different screen types e. g. use `5`for icon_screen ##### modes @@ -810,14 +810,14 @@ For example, if you have multiple icons named weather_sunny, weather_rain & weat |----|----| |MODE_BLANK|1| |MODE_CLOCK | 2| -| MODE_DATE | 3| -| MODE_FULL_SCREEN | 4| -|MODE_ICON_SCREEN | 5| -|MODE_TEXT_SCREEN | 6| -|MODE_RAINBOW_ICON | 7| -|MODE_RAINBOW_TEXT |8| -| MODE_RAINBOW_CLOCK | 9| -| MODE_RAINBOW_DATE | 10| +|MODE_DATE | 3| +|MODE_FULL_SCREEN| 4| +|MODE_ICON_SCREEN| 5| +|MODE_TEXT_SCREEN| 6| +|MODE_RAINBOW_ICON| 7| +|MODE_RAINBOW_TEXT|8| +|MODE_RAINBOW_CLOCK| 9| +|MODE_RAINBOW_DATE| 10| **(D)** Service **display_on** / **display_off** From 465bb487ebbe8656a0ec7e3906b107581f36378b Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Fri, 16 Jun 2023 15:58:09 +0100 Subject: [PATCH 09/10] Improve blueprint device selection Added a Manufacturer (Ulanzi) and Model (EHMTXv2) within the ESPHome Project Name Added filtering on the blueprints to only show EspHome devices with model of EHMTXv2 Also made device name selection consistent on all blueprints --- copy2esphome/EHMTX_easy_delete.yaml | 4 +++- copy2esphome/EHMTX_easy_hide.yaml | 6 ++++-- copy2esphome/EHMTX_easy_show.yaml | 6 ++++-- copy2esphome/EHMTX_easy_state.yaml | 6 ++++-- copy2esphome/EHMTX_extended_state.yaml | 6 ++++-- copy2esphome/ulanzi-easy.yaml | 3 +++ 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/copy2esphome/EHMTX_easy_delete.yaml b/copy2esphome/EHMTX_easy_delete.yaml index a96f9abe..72ec0546 100644 --- a/copy2esphome/EHMTX_easy_delete.yaml +++ b/copy2esphome/EHMTX_easy_delete.yaml @@ -8,7 +8,9 @@ blueprint: name: Which EspHoMaTriXv2 device to use selector: device: - integration: esphome + filter: + - integration: esphome + model: EHMTXv2 trigger_sensor: name: Which state change triggers the automation? selector: diff --git a/copy2esphome/EHMTX_easy_hide.yaml b/copy2esphome/EHMTX_easy_hide.yaml index abf657fc..ea9dcb7a 100644 --- a/copy2esphome/EHMTX_easy_hide.yaml +++ b/copy2esphome/EHMTX_easy_hide.yaml @@ -5,10 +5,12 @@ blueprint: domain: automation input: ehmtx_device: - name: Which display to use + name: Which EspHoMaTriXv2 device to use selector: device: - integration: esphome + filter: + - integration: esphome + model: EHMTXv2 trigger_sensor: name: Which state change triggers this automation selector: diff --git a/copy2esphome/EHMTX_easy_show.yaml b/copy2esphome/EHMTX_easy_show.yaml index c34d5339..988729d2 100644 --- a/copy2esphome/EHMTX_easy_show.yaml +++ b/copy2esphome/EHMTX_easy_show.yaml @@ -5,10 +5,12 @@ blueprint: domain: automation input: ehmtx_device: - name: Which device to display at? + name: Which EspHoMaTriXv2 device to use selector: device: - integration: esphome + filter: + - integration: esphome + model: EHMTXv2 trigger_sensor: name: Which state-change triggers the screen element selector: diff --git a/copy2esphome/EHMTX_easy_state.yaml b/copy2esphome/EHMTX_easy_state.yaml index a275865f..035634b6 100644 --- a/copy2esphome/EHMTX_easy_state.yaml +++ b/copy2esphome/EHMTX_easy_state.yaml @@ -5,10 +5,12 @@ blueprint: domain: automation input: ehmtx_device: - name: Which EspHoMaTriX-device to display at? + name: Which EspHoMaTriXv2 device to use selector: device: - integration: esphome + filter: + - integration: esphome + model: EHMTXv2 trigger_sensor: name: Which sensor state to show? description: This sensor state will be displayed. diff --git a/copy2esphome/EHMTX_extended_state.yaml b/copy2esphome/EHMTX_extended_state.yaml index a47d7a3c..d93cdbff 100644 --- a/copy2esphome/EHMTX_extended_state.yaml +++ b/copy2esphome/EHMTX_extended_state.yaml @@ -5,10 +5,12 @@ blueprint: domain: automation input: ehmtx_device: - name: Which EspHoMaTriX-device to display at? + name: Which EspHoMaTriXv2 device to use selector: device: - integration: esphome + filter: + - integration: esphome + model: EHMTXv2 trigger_sensor: name: Which sensor state to show? description: This sensor state will be displayed. diff --git a/copy2esphome/ulanzi-easy.yaml b/copy2esphome/ulanzi-easy.yaml index 87321520..003d7d76 100644 --- a/copy2esphome/ulanzi-easy.yaml +++ b/copy2esphome/ulanzi-easy.yaml @@ -59,6 +59,9 @@ external_components: esphome: comment: "EHMTXv2 from LuBeDa" name: $devicename + project: + name: "Ulanzi.EHMTXv2" + version: "2.0.0" on_boot: then: - ds1307.read_time: From c8c586b23c2d1192b35269982c5abb0e4ed01411 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 17 Jun 2023 07:58:06 +0200 Subject: [PATCH 10/10] docu --- CHANGELOG.md | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0261a1b1..8aec96ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - introduced service color_gauge - fixed bitmap_small with gauge - fixed del_screen with "*" +- improved blueprint selection @andrew-codechimp ## 2023.6.3 diff --git a/README.md b/README.md index 4d1e3758..3ee5e7d9 100644 --- a/README.md +++ b/README.md @@ -1109,7 +1109,7 @@ THE SOFTWARE IS PROVIDED “AS IS”, use at your own risk! ## Thanks - **[blakadder](https://github.com/blakadder)** for his contribution (cleanup README.md, fixed sample) -- **[andrew-codechimp](https://github.com/andrew-codechimp)** for his contribution (display on/off & del_screen "*" & show_clock with 0) +- **[andrew-codechimp](https://github.com/andrew-codechimp)** for his contribution (display on/off & del_screen "*" & show_clock with 0) and improved blueprint slelection - **[jd1](https://github.com/jd1)** for his contributions - **[aptonline](https://github.com/aptonline)** for his work on the Ulanzi hardware - **[wsbtak](https://github.com/wsbtak)** for the work on the Ulanzi hardware