From 87e0df82bc4fb904ee8fabd5133a617bc03d0495 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 5 Mar 2023 11:56:56 +0100 Subject: [PATCH 1/6] hold_screen --- CHANGELOG.md | 11 +++++++++++ components/ehmtx/EHMTX.cpp | 6 ++++++ components/ehmtx/EHMTX.h | 5 ++++- components/ehmtx/EHMTX_screen.cpp | 5 +++++ components/ehmtx/EHMTX_store.cpp | 5 +++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bcae090 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog + +## 2023.3.1 + +added: del_screen with wildcards +changed: maximum icons to 80 +fixed: skip_next + +## 2023.3.0 + +see README.md for features \ No newline at end of file diff --git a/components/ehmtx/EHMTX.cpp b/components/ehmtx/EHMTX.cpp index 42e709f..7e59296 100755 --- a/components/ehmtx/EHMTX.cpp +++ b/components/ehmtx/EHMTX.cpp @@ -17,6 +17,7 @@ namespace esphome this->gauge_value = 0; this->icon_count = 0; this->last_clock_time = 0; + this->show_icons = false; #ifdef USE_EHMTX_SELECT this->select = NULL; @@ -257,6 +258,11 @@ namespace esphome this->store->move_next(); } + void EHMTX::hold_screen() + { + this->store->hold_current(10); + } + void EHMTX::get_status() { time_t ts = this->clock->now().timestamp; diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index 66a8d8e..b774b82 100755 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -8,7 +8,7 @@ const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); const uint16_t TICKINTERVAL = 1000; // each 1000ms -static const char *const EHMTX_VERSION = "Version: 2023.3.1"; +static const char *const EHMTX_VERSION = "Version: 2023.3.2"; static const char *const TAG = "EHMTX"; namespace esphome @@ -79,6 +79,7 @@ namespace esphome void draw(); void get_status(); void skip_screen(); + void hold_screen(); std::string get_current(); void set_display(addressable_light::AddressableLightDisplay *disp); void set_screen_time(uint16_t t); @@ -135,6 +136,7 @@ namespace esphome EHMTX_screen *find_free_screen(uint8_t icon); void delete_screen(uint8_t icon); bool move_next(); + void hold_current(uint _sec); EHMTX_screen *current(); void log_status(); }; @@ -165,6 +167,7 @@ namespace esphome bool update_slot(uint8_t _icon); void update_screen(); bool del_slot(uint8_t _icon); + void hold_slot(uint8_t _sec); void set_text(std::string text, uint8_t icon, uint8_t pixel, uint16_t et); }; diff --git a/components/ehmtx/EHMTX_screen.cpp b/components/ehmtx/EHMTX_screen.cpp index e761165..de8b82f 100644 --- a/components/ehmtx/EHMTX_screen.cpp +++ b/components/ehmtx/EHMTX_screen.cpp @@ -112,6 +112,11 @@ namespace esphome this->update_screen(); } + void EHMTX_screen::hold_slot(uint8_t _sec) + { + this->endtime += _sec; + } + void EHMTX_screen::set_text(std::string text, uint8_t icon, uint8_t pixel, uint16_t et) { this->text = text; diff --git a/components/ehmtx/EHMTX_store.cpp b/components/ehmtx/EHMTX_store.cpp index e35d7de..11a2fa8 100644 --- a/components/ehmtx/EHMTX_store.cpp +++ b/components/ehmtx/EHMTX_store.cpp @@ -115,6 +115,11 @@ namespace esphome return this->slots[this->active_slot]; } + void EHMTX_store::hold_current(uint _sec) + { + this->slots[this->active_slot]->hold_slot(_sec); + } + uint8_t EHMTX_store::count_active_screens() { uint8_t count = 0; From c6345fbacfc97b36fc4e67934d986fc5775b02c1 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 5 Mar 2023 12:08:33 +0100 Subject: [PATCH 2/6] hold_screen --- CHANGELOG.md | 5 +++++ README.md | 20 +++++++++++++++++++- components/ehmtx/EHMTX.cpp | 3 ++- components/ehmtx/EHMTX.h | 1 + components/ehmtx/EHMTX_screen.cpp | 1 + 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcae090..ef2178b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,15 @@ # Changelog +## 2023.3.2 + +added: hold_screen for 20 additional seconds + ## 2023.3.1 added: del_screen with wildcards changed: maximum icons to 80 fixed: skip_next +fixed: show_all_icons on boot ## 2023.3.0 diff --git a/README.md b/README.md index bd6e5b4..4f040c1 100644 --- a/README.md +++ b/README.md @@ -565,7 +565,7 @@ switch: id(rgb8x32)->set_display_off(); ``` -Service **skip** +Service **skip_screen** if there are more than on screens in the queue this skips to the next screen. @@ -582,6 +582,24 @@ binary_sensor: id(rgb8x32)->skip_screen(); ``` +Service **hold_screen** + +displays the current screen for 20 seconds longer. + +e.g. on the Ulanzi TC001 + +``` +binary_sensor: + - platform: gpio + pin: + number: $right_button_pin + inverted: true + on_press: + lambda: + id(rgb8x32)->hold_screen(); +``` + + Service **status** This service displays the running queue and a list of icons in the logs diff --git a/components/ehmtx/EHMTX.cpp b/components/ehmtx/EHMTX.cpp index 7e59296..83dae78 100755 --- a/components/ehmtx/EHMTX.cpp +++ b/components/ehmtx/EHMTX.cpp @@ -260,7 +260,8 @@ namespace esphome void EHMTX::hold_screen() { - this->store->hold_current(10); + this->next_action_time+=HOLDTIME; + this->store->hold_current(HOLDTIME); } void EHMTX::get_status() diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index b774b82..658d066 100755 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -4,6 +4,7 @@ const uint8_t MAXQUEUE = 24; const uint8_t MAXICONS = 80; +const uint8_t HOLDTIME = 20; const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); diff --git a/components/ehmtx/EHMTX_screen.cpp b/components/ehmtx/EHMTX_screen.cpp index de8b82f..bf3812b 100644 --- a/components/ehmtx/EHMTX_screen.cpp +++ b/components/ehmtx/EHMTX_screen.cpp @@ -115,6 +115,7 @@ namespace esphome void EHMTX_screen::hold_slot(uint8_t _sec) { this->endtime += _sec; + ESP_LOGD(TAG, "hold for %d secs", _sec); } void EHMTX_screen::set_text(std::string text, uint8_t icon, uint8_t pixel, uint16_t et) From ba128f3011fee2d9c62c61ef1de81da6dd7415f7 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Tue, 7 Mar 2023 18:02:57 +0100 Subject: [PATCH 3/6] fixed force screen --- components/ehmtx/EHMTX.h | 2 +- components/ehmtx/EHMTX_store.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index 658d066..7de010f 100755 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -9,7 +9,7 @@ const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); const uint16_t TICKINTERVAL = 1000; // each 1000ms -static const char *const EHMTX_VERSION = "Version: 2023.3.2"; +static const char *const EHMTX_VERSION = "Version: 2023.3.3"; static const char *const TAG = "EHMTX"; namespace esphome diff --git a/components/ehmtx/EHMTX_store.cpp b/components/ehmtx/EHMTX_store.cpp index 11a2fa8..3c84c92 100644 --- a/components/ehmtx/EHMTX_store.cpp +++ b/components/ehmtx/EHMTX_store.cpp @@ -48,6 +48,7 @@ namespace esphome if (icon_id < MAXICONS) { this->force_screen = icon_id; + this->move_next(); } } From a9d83bd416b3c6c87d6ad3198ead03abb2c341da Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Tue, 7 Mar 2023 18:04:39 +0100 Subject: [PATCH 4/6] chancelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef2178b..dea1a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2023.3.3 + +fixed: force_screen skips imediatly to the selected screen + + ## 2023.3.2 added: hold_screen for 20 additional seconds From d558b566256a6de2f0629b44dd9526754c23fc4a Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Thu, 9 Mar 2023 08:42:22 +0100 Subject: [PATCH 5/6] hold_time configurable --- README.md | 4 +++- components/ehmtx/EHMTX.cpp | 11 ++++++++--- components/ehmtx/EHMTX.h | 3 ++- components/ehmtx/__init__.py | 5 +++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 01b64b6..e2a566b 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,8 @@ _Configuration variables:_ **duration** (Optional, minutes): lifetime of a screen in minutes (default=5). If not updates a screen will be removed after ```duration``` minutes +**hold_time** (Optional, seconds): extends the display time of the current screen in seconds (default=20) + **date_format** (Optional, string): formats the date display with [strftime syntax](https://esphome.io/components/time.html?highlight=strftime), defaults `"%d.%m."` (use `"%m.%d."` for the US) **time_format** (Optional, string): formats the date display with [strftime syntax](https://esphome.io/components/time.html?highlight=strftime), defaults `"%H:%M"` (use `"%I:%M%p"` for the US) @@ -603,7 +605,7 @@ binary_sensor: Service **hold_screen** -displays the current screen for 20 seconds longer. +displays the current screen for configured ammount (see **hold_time**) (default=20) seconds longer. e.g. on the Ulanzi TC001 diff --git a/components/ehmtx/EHMTX.cpp b/components/ehmtx/EHMTX.cpp index 83dae78..406c215 100755 --- a/components/ehmtx/EHMTX.cpp +++ b/components/ehmtx/EHMTX.cpp @@ -260,8 +260,8 @@ namespace esphome void EHMTX::hold_screen() { - this->next_action_time+=HOLDTIME; - this->store->hold_current(HOLDTIME); + this->next_action_time+=this->hold_time; + this->store->hold_current(this->hold_time); } void EHMTX::get_status() @@ -431,7 +431,12 @@ namespace esphome this->clock_time = t; } -void EHMTX::set_clock_interval(uint16_t t) + void EHMTX::set_hold_time(uint16_t t) + { + this->hold_time = t; + } + + void EHMTX::set_clock_interval(uint16_t t) { this->clock_interval = t; } diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index 7de010f..d760cda 100755 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -4,7 +4,6 @@ const uint8_t MAXQUEUE = 24; const uint8_t MAXICONS = 80; -const uint8_t HOLDTIME = 20; const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); @@ -67,6 +66,7 @@ namespace esphome uint16_t scroll_intervall; // ms to between scrollsteps uint16_t anim_intervall; // ms to next_frame() uint16_t clock_time; // seconds display of screen_time - clock_time = date_time + uint16_t hold_time; // seconds display of screen_time to extend uint16_t clock_interval; // seconds display of screen_time - clock_time = date_time uint16_t screen_time; // seconds display of screen uint8_t icon_count; // max iconnumber -1 @@ -85,6 +85,7 @@ namespace esphome void set_display(addressable_light::AddressableLightDisplay *disp); void set_screen_time(uint16_t t); void set_clock_time(uint16_t t); + void set_hold_time(uint16_t t); void set_clock_interval(uint16_t t); void set_show_day_of_week(bool b); void set_show_date(bool b); diff --git a/components/ehmtx/__init__.py b/components/ehmtx/__init__.py index d93fe2a..4ecef35 100755 --- a/components/ehmtx/__init__.py +++ b/components/ehmtx/__init__.py @@ -52,6 +52,7 @@ def rgb565_svg(x,y,r,g,b): CONF_ICONS = "icons" CONF_SHOWDOW = "dayofweek" CONF_SHOWDATE = "show_date" +CONF_HOLD_TIME = "hold_time" CONF_DISPLAY = "display8x32" CONF_HTML = "html" CONF_SCROLLINTERVALL = "scroll_intervall" @@ -107,6 +108,9 @@ def rgb565_svg(x,y,r,g,b): cv.Optional( CONF_XOFFSET, default="1" ): cv.templatable(cv.int_range(min=-32, max=32)), + cv.Optional( + CONF_HOLD_TIME, default="2" + ): cv.templatable(cv.int_range(min=0, max=3600)), cv.Optional(CONF_SCROLLINTERVALL, default="80" ): cv.templatable(cv.positive_int), cv.Optional( @@ -563,6 +567,7 @@ async def to_code(config): cg.add(var.set_time_format(config[CONF_TIME_FORMAT])) cg.add(var.set_date_format(config[CONF_DATE_FORMAT])) cg.add(var.set_show_day_of_week(config[CONF_SHOWDOW])) + cg.add(var.set_hold_time(config[CONF_HOLD_TIME])) cg.add(var.set_show_date(config[CONF_SHOWDATE])) cg.add(var.set_font_offset(config[CONF_XOFFSET], config[CONF_YOFFSET])) From 1e80bb2016dc347d77629c5270af34b566f7ca6a Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Thu, 9 Mar 2023 08:43:06 +0100 Subject: [PATCH 6/6] change --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dea1a04..83c03db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 2023.3.3 fixed: force_screen skips imediatly to the selected screen - +added: hold_time configurable ## 2023.3.2