From 24657e62db42a08b44ad93bf8b184a61fc6452f4 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Mon, 23 Oct 2023 12:48:22 +0300 Subject: [PATCH 1/3] 2023.9.1-117: Add a pseudo-icon - blank --- components/ehmtxv2/EHMTX.cpp | 5 +++++ components/ehmtxv2/EHMTX.h | 5 +++-- components/ehmtxv2/EHMTX_queue.cpp | 25 ++++++++++++++++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 0745f432..067c5f1b 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -341,6 +341,11 @@ namespace esphome uint8_t EHMTX::find_icon(std::string name) { + if (name == "blank") + { + return BLANKICON; + } + for (uint8_t i = 0; i < this->icon_count; i++) { if (strcmp(this->icons[i]->name.c_str(), name.c_str()) == 0) diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index e64e93f0..c85f3a0c 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -20,7 +20,8 @@ const uint8_t C_BLACK = 0; const uint8_t D_LIFETIME = 5; const uint8_t D_SCREEN_TIME = 10; -const uint8_t MAXICONS = 90; +const uint8_t BLANKICON = -1; +const uint8_t MAXICONS = 90; // Max 127 icon due int8_t const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); @@ -260,7 +261,7 @@ namespace esphome bool default_font; time_t endtime; time_t last_time; - uint8_t icon; + int8_t icon; uint16_t scroll_reset; show_mode mode; int8_t progress; diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 9e4ff6aa..69e5b9cb 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -283,7 +283,10 @@ namespace esphome else { this->config_->display->graph(8, 0, this->config_->graph); - this->config_->display->image(0, 0, this->config_->icons[this->icon]); + if (this->icon > BLANKICON) + { + this->config_->display->image(0, 0, this->config_->icons[this->icon]); + } } break; #endif @@ -418,7 +421,10 @@ namespace esphome this->config_->clock->now()); } } - this->config_->display->image(0, 0, this->config_->icons[this->icon]); + if (this->icon > BLANKICON) + { + this->config_->display->image(0, 0, this->config_->icons[this->icon]); + } this->config_->draw_day_of_week(true); if (this->icon_name.find("day") != std::string::npos || this->icon_name.find("weekday") != std::string::npos) @@ -548,7 +554,10 @@ namespace esphome if (this->mode == MODE_ICON_PROGRESS) { this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF); - this->config_->display->image(0, 0, this->config_->icons[this->icon]); + if (this->icon > BLANKICON) + { + this->config_->display->image(0, 0, this->config_->icons[this->icon]); + } if (this->progress != 0) { @@ -568,13 +577,19 @@ namespace esphome { if (this->config_->display_gauge) { - this->config_->display->image(2, 0, this->config_->icons[this->icon]); + if (this->icon > BLANKICON) + { + this->config_->display->image(2, 0, this->config_->icons[this->icon]); + } this->config_->display->line(10, 0, 10, 7, esphome::display::COLOR_OFF); } else { this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF); - this->config_->display->image(0, 0, this->config_->icons[this->icon]); + if (this->icon > BLANKICON) + { + this->config_->display->image(0, 0, this->config_->icons[this->icon]); + } } } break; From 421a8badf8ddf4853d0dc85360fa3a15f35df42d Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Mon, 23 Oct 2023 12:50:50 +0300 Subject: [PATCH 2/3] 2023.9.1-117: Add a pseudo-icon - blank --- README.md | 1 + components/ehmtxv2/EHMTX.cpp | 28 ++++++++++++++-------------- components/ehmtxv2/EHMTX.h | 6 +++--- components/ehmtxv2/EHMTX_queue.cpp | 19 +++++++++++-------- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index a16fd0e0..751b3499 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ - `icon_screen_progress(iconname, text, progress, lifetime, screen_time, default_font, r, g, b)` - Added `replace_time_date_to:` and `replace_time_date_from:` which allow replacing the system date & time text (anything!) - Added `bitmap_small` and `rainbow_bitmap_small` screen. +- Added a pseudo-icon `blank` - empty icon, no display. ### EspHoMaTriX 2023.9.0 - Added the ability to display graph as defined in the YAML file diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 067c5f1b..8147ee4d 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -1016,9 +1016,9 @@ namespace esphome { uint8_t icon = this->find_icon(iconname.c_str()); - if (icon >= this->icon_count) + if (icon == MAXICONS) { - ESP_LOGW(TAG, "icon %d not found => default: 0", icon); + ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, iconname.c_str()); icon = 0; for (auto *t : on_icon_error_triggers_) { @@ -1054,9 +1054,9 @@ namespace esphome uint8_t icon = this->find_icon(ic.c_str()); - if (icon >= this->icon_count) + if (icon == MAXICONS) { - ESP_LOGW(TAG, "icon %d not found => default: 0", icon); + ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str()); icon = 0; for (auto *t : on_icon_error_triggers_) { @@ -1088,9 +1088,9 @@ namespace esphome uint8_t icon = this->find_icon(ic.c_str()); - if (icon >= this->icon_count) + if (icon == MAXICONS) { - ESP_LOGW(TAG, "icon %d not found => default: 0", icon); + ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str()); icon = 0; for (auto *t : on_icon_error_triggers_) { @@ -1134,9 +1134,9 @@ namespace esphome uint8_t icon = this->find_icon(ic.c_str()); - if (icon >= this->icon_count) + if (icon == MAXICONS) { - ESP_LOGW(TAG, "icon %d not found => default: 0", icon); + ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str()); icon = 0; for (auto *t : on_icon_error_triggers_) { @@ -1167,9 +1167,9 @@ namespace esphome uint8_t icon = this->find_icon(ic.c_str()); - if (icon >= this->icon_count) + if (icon == MAXICONS) { - ESP_LOGW(TAG, "icon %d not found => default: 0", icon); + ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str()); icon = 0; for (auto *t : on_icon_error_triggers_) { @@ -1200,9 +1200,9 @@ namespace esphome uint8_t icon = this->find_icon(ic.c_str()); - if (icon >= this->icon_count) + if (icon == MAXICONS) { - ESP_LOGW(TAG, "icon %d not found => default: 0", icon); + ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str()); icon = 0; for (auto *t : on_icon_error_triggers_) { @@ -1328,7 +1328,7 @@ namespace esphome { uint8_t icon = this->find_icon(iconname.c_str()); - if (icon >= this->icon_count) + if (icon == MAXICONS) { ESP_LOGW(TAG, "full screen: icon %d not found => default: 0", icon); for (auto *t : on_icon_error_triggers_) @@ -1508,7 +1508,7 @@ namespace esphome { uint8_t icon = this->find_icon(iconname.c_str()); - if (icon >= this->icon_count) + if (icon == MAXICONS) { ESP_LOGW(TAG, "graph screen with icon: icon %d not found => default: 0", icon); for (auto *t : on_icon_error_triggers_) diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index c85f3a0c..005d2ede 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -20,8 +20,8 @@ const uint8_t C_BLACK = 0; const uint8_t D_LIFETIME = 5; const uint8_t D_SCREEN_TIME = 10; -const uint8_t BLANKICON = -1; -const uint8_t MAXICONS = 90; // Max 127 icon due int8_t +const uint8_t MAXICONS = 90; +const uint8_t BLANKICON = MAXICONS + 1; const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); @@ -261,7 +261,7 @@ namespace esphome bool default_font; time_t endtime; time_t last_time; - int8_t icon; + uint8_t icon; uint16_t scroll_reset; show_mode mode; int8_t progress; diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 69e5b9cb..b4858311 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -233,10 +233,13 @@ namespace esphome this->config_->last_rainbow_time = millis(); } - if (millis() - this->config_->last_anim_time >= this->config_->icons[this->icon]->frame_duration) + if (this->icon < this->config_->icon_count) { - this->config_->icons[this->icon]->next_frame(); - this->config_->last_anim_time = millis(); + if (millis() - this->config_->last_anim_time >= this->config_->icons[this->icon]->frame_duration) + { + this->config_->icons[this->icon]->next_frame(); + this->config_->last_anim_time = millis(); + } } } @@ -283,7 +286,7 @@ namespace esphome else { this->config_->display->graph(8, 0, this->config_->graph); - if (this->icon > BLANKICON) + if (this->icon != BLANKICON) { this->config_->display->image(0, 0, this->config_->icons[this->icon]); } @@ -421,7 +424,7 @@ namespace esphome this->config_->clock->now()); } } - if (this->icon > BLANKICON) + if (this->icon != BLANKICON) { this->config_->display->image(0, 0, this->config_->icons[this->icon]); } @@ -554,7 +557,7 @@ namespace esphome if (this->mode == MODE_ICON_PROGRESS) { this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF); - if (this->icon > BLANKICON) + if (this->icon != BLANKICON) { this->config_->display->image(0, 0, this->config_->icons[this->icon]); } @@ -577,7 +580,7 @@ namespace esphome { if (this->config_->display_gauge) { - if (this->icon > BLANKICON) + if (this->icon != BLANKICON) { this->config_->display->image(2, 0, this->config_->icons[this->icon]); } @@ -586,7 +589,7 @@ namespace esphome else { this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF); - if (this->icon > BLANKICON) + if (this->icon != BLANKICON) { this->config_->display->image(0, 0, this->config_->icons[this->icon]); } From 2cb2286af34d9702744828ac38c27605da990f88 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Fri, 27 Oct 2023 13:43:50 +0300 Subject: [PATCH 3/3] 2023.9.1-117: Add a pseudo-icon - blank to Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 751b3499..e0e90ed1 100644 --- a/README.md +++ b/README.md @@ -771,7 +771,7 @@ Numerous features are accessible with services from home assistant and lambdas t - **r, g, b**: Color components for red, green, and blue 0..255 - **size**: The size of the rindicator or alarm, 1-3 - **percent**: values from 0..100 -- **icon_name**: the id of the icon to show, as defined in the YAML file, it is also possible to set the arbitrary [screen identifier](#screen_id), for example `icon_name|screen_id` +- **icon_name**: the id of the icon to show, as defined in the YAML file (or pseudo-icon `blank` - empty icon), it is also possible to set the arbitrary [screen identifier](#screen_id), for example `icon_name|screen_id` - **text**: a text message to display - **lifetime**: how long does this screen stay in the queue (minutes) - **screen_time**: how long is this screen display in the loop (seconds). For short text without scrolling it is shown the defined time, longer text is scrolled at least `scroll_count` times.