From 5a546acd899221fa10be09efe637c96210bc03a7 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Wed, 1 May 2024 12:54:11 +0200 Subject: [PATCH] cleanup and changed on empty queue behavior --- .github/workflows/wiki.yaml | 2 +- CHANGELOG.md | 3 +++ components/ehmtxv2/EHMTX.cpp | 30 ++++++++++++++---------------- components/ehmtxv2/EHMTX.h | 2 +- components/ehmtxv2/EHMTX_queue.cpp | 24 ++++++++++++------------ components/ehmtxv2/__init__.py | 9 ++++----- install/ulanzi-easy.yaml | 6 +++--- wiki/using-graphs.md | 2 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.github/workflows/wiki.yaml b/.github/workflows/wiki.yaml index 16dfdf43..9e02f493 100644 --- a/.github/workflows/wiki.yaml +++ b/.github/workflows/wiki.yaml @@ -2,7 +2,7 @@ name: Publish wiki on: push: branches: - - 2023.9.1 + - 2024.5.0 - 2024.1.0-prerelease paths: - wiki/** diff --git a/CHANGELOG.md b/CHANGELOG.md index 56eacd0f..07116db9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 2024.5.0 +- changed on_empty_queue behavior (triggered every 15 sec after first occurance) + ## 2024.1.0 - cleaned up docu diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 0e13e66b..b62852a0 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -21,7 +21,6 @@ namespace esphome { EHMTX::EHMTX() : PollingComponent(POLLINGINTERVAL) { - ESP_LOGD(TAG, "Constructor start"); this->show_display = true; this->display_gauge = false; this->display_rindicator = 0; @@ -71,7 +70,6 @@ namespace esphome this->set_adv_clock_color(); #endif - ESP_LOGD(TAG, "Constructor finish"); } void EHMTX::show_rindicator(int r, int g, int b, int size) @@ -1023,7 +1021,7 @@ namespace esphome } else { - ESP_LOGD(TAG, "oldest queue element not found"); + // Queue is empty } this->queue[hit]->status(); @@ -1033,7 +1031,7 @@ namespace esphome uint8_t EHMTX::find_last_clock() { uint8_t hit = MAXQUEUE; - if (EHMTXv2_CLOCK_INTERVALL > 0) + if (EHMTXv2_CLOCK_INTERVAL > 0) { float ts = this->get_tick(); for (size_t i = 0; i < MAXQUEUE; i++) @@ -1056,7 +1054,7 @@ namespace esphome if ((this->queue[i]->mode == MODE_CLOCK) || (this->queue[i]->mode == MODE_RAINBOW_CLOCK) || (this->queue[i]->mode == MODE_ICON_CLOCK)) { - if (ts > (this->queue[i]->last_time + EHMTXv2_CLOCK_INTERVALL * 1000.0)) + if (ts > (this->queue[i]->last_time + EHMTXv2_CLOCK_INTERVAL * 1000.0)) { hit = i; } @@ -1076,7 +1074,7 @@ namespace esphome if (this->clock->now().is_valid()) { std::string infotext; - float ts = this->get_tick() + static_cast(EHMTXv2_SCROLL_INTERVALL); // Force remove expired queue element + float ts = this->get_tick() + static_cast(EHMTXv2_SCROLL_INTERVAL); // Force remove expired queue element for (size_t i = 0; i < MAXQUEUE; i++) { @@ -1218,7 +1216,7 @@ namespace esphome void EHMTX::tick() { - if (millis() - this->last_rainbow_time >= EHMTXv2_RAINBOW_INTERVALL) + if (millis() - this->last_rainbow_time >= EHMTXv2_RAINBOW_INTERVAL) { this->hue_++; this->rainbow_color = esphome::light::ESPHSVColor(this->hue_, 255, 240).to_rgb(); @@ -1229,7 +1227,7 @@ namespace esphome { float ts = this->get_tick(); - if (millis() - this->last_scroll_time >= EHMTXv2_SCROLL_INTERVALL) + if (millis() - this->last_scroll_time >= EHMTXv2_SCROLL_INTERVAL) { this->scroll_step++; this->last_scroll_time = millis(); @@ -1352,12 +1350,12 @@ namespace esphome } else { - this->next_action_time = ts; + this->next_action_time = ts + 15000 ; // come back in 15 Seconds for (auto *t : on_empty_queue_triggers_) { - ESP_LOGD(TAG, "on_empty_queue trigger"); - t->process(); - } + ESP_LOGD(TAG, "on_empty_queue trigger"); + t->process(); + } } } @@ -1941,13 +1939,13 @@ namespace esphome ESP_LOGD(TAG, "rainbow_clock_screen lifetime: %d screen_time: %d", lifetime, screen_time); screen->mode = MODE_RAINBOW_CLOCK; screen->default_font = default_font; - if (EHMTXv2_CLOCK_INTERVALL == 0 || (EHMTXv2_CLOCK_INTERVALL * 1000.0 > screen_time * 1000.0)) + if (EHMTXv2_CLOCK_INTERVAL == 0 || (EHMTXv2_CLOCK_INTERVAL * 1000.0 > screen_time * 1000.0)) { screen->screen_time_ = screen_time * 1000.0; } else { - screen->screen_time_ = EHMTXv2_CLOCK_INTERVALL * 1000.0 - 2000.0; + screen->screen_time_ = EHMTXv2_CLOCK_INTERVAL * 1000.0 - 2000.0; } #ifdef EHMTXv2_USE_VERTICAL_SCROLL screen->pixels_ = 0; @@ -2817,10 +2815,10 @@ namespace esphome { ESP_LOGCONFIG(TAG, "EspHoMatriXv2 version: %s", EHMTX_VERSION); ESP_LOGCONFIG(TAG, "Icons: %d of %d", this->icon_count, MAXICONS); - ESP_LOGCONFIG(TAG, "Clock interval: %d s", EHMTXv2_CLOCK_INTERVALL); + ESP_LOGCONFIG(TAG, "Clock interval: %d s", EHMTXv2_CLOCK_INTERVAL); ESP_LOGCONFIG(TAG, "Date format: %s", EHMTXv2_DATE_FORMAT); ESP_LOGCONFIG(TAG, "Time format: %s", EHMTXv2_TIME_FORMAT); - ESP_LOGCONFIG(TAG, "Interval (ms) scroll: %d", EHMTXv2_SCROLL_INTERVALL); + ESP_LOGCONFIG(TAG, "Interval (ms) scroll: %d", EHMTXv2_SCROLL_INTERVAL); if (this->show_day_of_week) { ESP_LOGCONFIG(TAG, "Show day of week"); diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 58a563ac..58aec8ba 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -28,7 +28,7 @@ const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); const uint16_t POLLINGINTERVAL = 250; -static const char *const EHMTX_VERSION = "2024.3.0"; +static const char *const EHMTX_VERSION = "2024.5.0"; static const char *const TAG = "EHMTXv2"; enum show_mode : uint8_t diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 7eb6befd..f7f747c1 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -177,7 +177,7 @@ namespace esphome #endif default: - ESP_LOGD(TAG, "queue: UPPS"); + // Queue not initialized break; } } @@ -284,7 +284,7 @@ namespace esphome { uint8_t reverse_steps = round(((static_cast(width) - 8 * static_cast(this->icon)) / static_cast(this->icon + 1)) + 8); - if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL) > reverse_steps) + if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL) > reverse_steps) { result = (item + 1 == this->icon) ? width - this->config_->scroll_step : -8 + this->config_->scroll_step; if (item == 0 && (item_pos == 32767 || item_pos < target)) @@ -324,7 +324,7 @@ namespace esphome { uint8_t reverse_steps = round(((static_cast(width) - 8 * static_cast(this->icon)) / static_cast(this->icon + 1)) * this->icon + 8 * (this->icon + 1)) + 8; - if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL) > reverse_steps) + if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL) > reverse_steps) { if (item_pos > target) { @@ -354,7 +354,7 @@ namespace esphome uint8_t height = 8; - if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL) > height) + if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL) > height) { if (this->config_->vertical_scroll) { @@ -363,7 +363,7 @@ namespace esphome this->config_->vertical_scroll = this->config_->scroll_step >= height; return this->config_->scroll_step - height; } - return height - round((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL); + return height - round((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL); #else return 0; #endif @@ -375,7 +375,7 @@ namespace esphome if ((this->progress == 1) && (this->icon == 1 || (this->icon == 3 && item == 1))) { - if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL) > height) + if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL) > height) { if (this->default_font) { @@ -384,7 +384,7 @@ namespace esphome this->default_font = this->config_->scroll_step >= height; return this->config_->scroll_step - height; } - return height - round((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL); + return height - round((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL); } return 0; @@ -1243,7 +1243,7 @@ namespace esphome case MODE_RAINBOW_TEXT: #ifdef EHMTXv2_SCROLL_SMALL_TEXT max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; - display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVALL); + display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVAL); this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time; #else if (this->pixels_ < 32) @@ -1253,7 +1253,7 @@ namespace esphome else { max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; - display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVALL); + display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVAL); this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time; } #endif @@ -1274,7 +1274,7 @@ namespace esphome else { max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; - display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVALL); + display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVAL); this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time; } break; @@ -1287,7 +1287,7 @@ namespace esphome else { max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; - display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVALL); + display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVAL); this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time; } break; @@ -1320,7 +1320,7 @@ namespace esphome else { max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; - display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVALL); + display_duration = static_cast(max_steps * EHMTXv2_SCROLL_INTERVAL); this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time; } diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index b49d3171..ce5ffc1a 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -31,7 +31,6 @@ SVG_END = "" logging.warning(f"") -logging.warning(f"!!!! This version (2024.4.0) has breaking changes !!!!") logging.warning(f"Please check the documentation and wiki https://github.com/lubeda/EspHoMaTriXv2") logging.warning(f"This will only work with esphome >= 2023.7.0") logging.warning(f"") @@ -566,10 +565,10 @@ def thumbnails(frames): if config[CONF_REPLACE_TIME_DATE_FROM]: logging.warning(f"replace_time_date_from: defined but no replace_time_date_to:! (not using replacements)\n\r") - cg.add_define("EHMTXv2_SCROLL_INTERVALL",config[CONF_SCROLLINTERVAL]) - cg.add_define("EHMTXv2_RAINBOW_INTERVALL",config[CONF_RAINBOWINTERVAL]) - cg.add_define("EHMTXv2_FRAME_INTERVALL",config[CONF_FRAMEINTERVAL]) - cg.add_define("EHMTXv2_CLOCK_INTERVALL",config[CONF_CLOCKINTERVAL]) + cg.add_define("EHMTXv2_SCROLL_INTERVAL",config[CONF_SCROLLINTERVAL]) + cg.add_define("EHMTXv2_RAINBOW_INTERVAL",config[CONF_RAINBOWINTERVAL]) + cg.add_define("EHMTXv2_FRAME_INTERVAL",config[CONF_FRAMEINTERVAL]) + cg.add_define("EHMTXv2_CLOCK_INTERVAL",config[CONF_CLOCKINTERVAL]) cg.add_define("EHMTXv2_SCROLL_COUNT",config[CONF_SCROLLCOUNT]) cg.add_define("EHMTXv2_WEEK_START",config[CONF_WEEK_START_MONDAY]) cg.add_define("EHMTXv2_DEFAULT_FONT_OFFSET_X",config[CONF_DEFAULT_FONT_XOFFSET]) diff --git a/install/ulanzi-easy.yaml b/install/ulanzi-easy.yaml index 3d0d8ee5..ea08187f 100644 --- a/install/ulanzi-easy.yaml +++ b/install/ulanzi-easy.yaml @@ -58,7 +58,7 @@ external_components: - source: type: git url: https://github.com/lubeda/EspHoMaTriXv2 - ref: "2024.1.0" + ref: "2024.5.0" refresh: 600s components: [ ehmtxv2 ] @@ -67,7 +67,7 @@ esphome: name: $devicename project: name: "Ulanzi.EHMTXv2" - version: "2024.1.0" + version: "2024.5.0" on_boot: then: - ds1307.read_time: @@ -103,7 +103,7 @@ binary_sensor: name: "Right button" logger: - level: DEBUG + level: INFO api: diff --git a/wiki/using-graphs.md b/wiki/using-graphs.md index c533f44b..47d889e2 100644 --- a/wiki/using-graphs.md +++ b/wiki/using-graphs.md @@ -10,7 +10,7 @@ To use graphs on your display you have to add a graph to your yaml, only this gr ```yaml logger: - level: DEBUG + level: INFO logs: graph: error