Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit d558b56

Browse files
committed
hold_time configurable
1 parent a9d83bd commit d558b56

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ _Configuration variables:_
229229

230230
**duration** (Optional, minutes): lifetime of a screen in minutes (default=5). If not updates a screen will be removed after ```duration``` minutes
231231

232+
**hold_time** (Optional, seconds): extends the display time of the current screen in seconds (default=20)
233+
232234
**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)
233235

234236
**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:
603605

604606
Service **hold_screen**
605607

606-
displays the current screen for 20 seconds longer.
608+
displays the current screen for configured ammount (see **hold_time**) (default=20) seconds longer.
607609

608610
e.g. on the Ulanzi TC001
609611

components/ehmtx/EHMTX.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ namespace esphome
260260

261261
void EHMTX::hold_screen()
262262
{
263-
this->next_action_time+=HOLDTIME;
264-
this->store->hold_current(HOLDTIME);
263+
this->next_action_time+=this->hold_time;
264+
this->store->hold_current(this->hold_time);
265265
}
266266

267267
void EHMTX::get_status()
@@ -431,7 +431,12 @@ namespace esphome
431431
this->clock_time = t;
432432
}
433433

434-
void EHMTX::set_clock_interval(uint16_t t)
434+
void EHMTX::set_hold_time(uint16_t t)
435+
{
436+
this->hold_time = t;
437+
}
438+
439+
void EHMTX::set_clock_interval(uint16_t t)
435440
{
436441
this->clock_interval = t;
437442
}

components/ehmtx/EHMTX.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
const uint8_t MAXQUEUE = 24;
66
const uint8_t MAXICONS = 80;
7-
const uint8_t HOLDTIME = 20;
87
const uint8_t TEXTSCROLLSTART = 8;
98
const uint8_t TEXTSTARTOFFSET = (32 - 8);
109

@@ -67,6 +66,7 @@ namespace esphome
6766
uint16_t scroll_intervall; // ms to between scrollsteps
6867
uint16_t anim_intervall; // ms to next_frame()
6968
uint16_t clock_time; // seconds display of screen_time - clock_time = date_time
69+
uint16_t hold_time; // seconds display of screen_time to extend
7070
uint16_t clock_interval; // seconds display of screen_time - clock_time = date_time
7171
uint16_t screen_time; // seconds display of screen
7272
uint8_t icon_count; // max iconnumber -1
@@ -85,6 +85,7 @@ namespace esphome
8585
void set_display(addressable_light::AddressableLightDisplay *disp);
8686
void set_screen_time(uint16_t t);
8787
void set_clock_time(uint16_t t);
88+
void set_hold_time(uint16_t t);
8889
void set_clock_interval(uint16_t t);
8990
void set_show_day_of_week(bool b);
9091
void set_show_date(bool b);

components/ehmtx/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def rgb565_svg(x,y,r,g,b):
5252
CONF_ICONS = "icons"
5353
CONF_SHOWDOW = "dayofweek"
5454
CONF_SHOWDATE = "show_date"
55+
CONF_HOLD_TIME = "hold_time"
5556
CONF_DISPLAY = "display8x32"
5657
CONF_HTML = "html"
5758
CONF_SCROLLINTERVALL = "scroll_intervall"
@@ -107,6 +108,9 @@ def rgb565_svg(x,y,r,g,b):
107108
cv.Optional(
108109
CONF_XOFFSET, default="1"
109110
): cv.templatable(cv.int_range(min=-32, max=32)),
111+
cv.Optional(
112+
CONF_HOLD_TIME, default="2"
113+
): cv.templatable(cv.int_range(min=0, max=3600)),
110114
cv.Optional(CONF_SCROLLINTERVALL, default="80"
111115
): cv.templatable(cv.positive_int),
112116
cv.Optional(
@@ -563,6 +567,7 @@ async def to_code(config):
563567
cg.add(var.set_time_format(config[CONF_TIME_FORMAT]))
564568
cg.add(var.set_date_format(config[CONF_DATE_FORMAT]))
565569
cg.add(var.set_show_day_of_week(config[CONF_SHOWDOW]))
570+
cg.add(var.set_hold_time(config[CONF_HOLD_TIME]))
566571
cg.add(var.set_show_date(config[CONF_SHOWDATE]))
567572
cg.add(var.set_font_offset(config[CONF_XOFFSET], config[CONF_YOFFSET]))
568573

0 commit comments

Comments
 (0)