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

Commit 523fba8

Browse files
authored
Merge pull request #54 from lubeda/2023.3.3
2023.3.3
2 parents 1edf300 + 1e80bb2 commit 523fba8

File tree

7 files changed

+67
-3
lines changed

7 files changed

+67
-3
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
# Changelog
22

3+
## 2023.3.3
4+
5+
fixed: force_screen skips imediatly to the selected screen
6+
added: hold_time configurable
7+
8+
## 2023.3.2
9+
10+
added: hold_screen for 20 additional seconds
11+
312
## 2023.3.1
413

514
added: del_screen with wildcards
615
changed: maximum icons to 80
716
fixed: skip_next
17+
fixed: show_all_icons on boot
818

919
## 2023.3.0
1020

README.md

Lines changed: 21 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)
@@ -584,7 +586,7 @@ switch:
584586
id(rgb8x32)->set_display_off();
585587
```
586588

587-
Service **skip**
589+
Service **skip_screen**
588590

589591
If there is more than one screen in the queue, skip to the next screen.
590592

@@ -601,6 +603,24 @@ binary_sensor:
601603
id(rgb8x32)->skip_screen();
602604
```
603605

606+
Service **hold_screen**
607+
608+
displays the current screen for configured ammount (see **hold_time**) (default=20) seconds longer.
609+
610+
e.g. on the Ulanzi TC001
611+
612+
```
613+
binary_sensor:
614+
- platform: gpio
615+
pin:
616+
number: $right_button_pin
617+
inverted: true
618+
on_press:
619+
lambda:
620+
id(rgb8x32)->hold_screen();
621+
```
622+
623+
604624
Service **status**
605625
606626
This service displays the running queue and a list of icons in the logs

components/ehmtx/EHMTX.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace esphome
1717
this->gauge_value = 0;
1818
this->icon_count = 0;
1919
this->last_clock_time = 0;
20+
this->show_icons = false;
2021

2122
#ifdef USE_EHMTX_SELECT
2223
this->select = NULL;
@@ -257,6 +258,12 @@ namespace esphome
257258
this->store->move_next();
258259
}
259260

261+
void EHMTX::hold_screen()
262+
{
263+
this->next_action_time+=this->hold_time;
264+
this->store->hold_current(this->hold_time);
265+
}
266+
260267
void EHMTX::get_status()
261268
{
262269
time_t ts = this->clock->now().timestamp;
@@ -424,7 +431,12 @@ namespace esphome
424431
this->clock_time = t;
425432
}
426433

427-
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)
428440
{
429441
this->clock_interval = t;
430442
}

components/ehmtx/EHMTX.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const uint8_t TEXTSCROLLSTART = 8;
88
const uint8_t TEXTSTARTOFFSET = (32 - 8);
99

1010
const uint16_t TICKINTERVAL = 1000; // each 1000ms
11-
static const char *const EHMTX_VERSION = "Version: 2023.3.1";
11+
static const char *const EHMTX_VERSION = "Version: 2023.3.3";
1212
static const char *const TAG = "EHMTX";
1313

1414
namespace esphome
@@ -66,6 +66,7 @@ namespace esphome
6666
uint16_t scroll_intervall; // ms to between scrollsteps
6767
uint16_t anim_intervall; // ms to next_frame()
6868
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
6970
uint16_t clock_interval; // seconds display of screen_time - clock_time = date_time
7071
uint16_t screen_time; // seconds display of screen
7172
uint8_t icon_count; // max iconnumber -1
@@ -79,10 +80,12 @@ namespace esphome
7980
void draw();
8081
void get_status();
8182
void skip_screen();
83+
void hold_screen();
8284
std::string get_current();
8385
void set_display(addressable_light::AddressableLightDisplay *disp);
8486
void set_screen_time(uint16_t t);
8587
void set_clock_time(uint16_t t);
88+
void set_hold_time(uint16_t t);
8689
void set_clock_interval(uint16_t t);
8790
void set_show_day_of_week(bool b);
8891
void set_show_date(bool b);
@@ -135,6 +138,7 @@ namespace esphome
135138
EHMTX_screen *find_free_screen(uint8_t icon);
136139
void delete_screen(uint8_t icon);
137140
bool move_next();
141+
void hold_current(uint _sec);
138142
EHMTX_screen *current();
139143
void log_status();
140144
};
@@ -165,6 +169,7 @@ namespace esphome
165169
bool update_slot(uint8_t _icon);
166170
void update_screen();
167171
bool del_slot(uint8_t _icon);
172+
void hold_slot(uint8_t _sec);
168173
void set_text(std::string text, uint8_t icon, uint8_t pixel, uint16_t et);
169174
};
170175

components/ehmtx/EHMTX_screen.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ namespace esphome
112112
this->update_screen();
113113
}
114114

115+
void EHMTX_screen::hold_slot(uint8_t _sec)
116+
{
117+
this->endtime += _sec;
118+
ESP_LOGD(TAG, "hold for %d secs", _sec);
119+
}
120+
115121
void EHMTX_screen::set_text(std::string text, uint8_t icon, uint8_t pixel, uint16_t et)
116122
{
117123
this->text = text;

components/ehmtx/EHMTX_store.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ namespace esphome
4848
if (icon_id < MAXICONS)
4949
{
5050
this->force_screen = icon_id;
51+
this->move_next();
5152
}
5253
}
5354

@@ -115,6 +116,11 @@ namespace esphome
115116
return this->slots[this->active_slot];
116117
}
117118

119+
void EHMTX_store::hold_current(uint _sec)
120+
{
121+
this->slots[this->active_slot]->hold_slot(_sec);
122+
}
123+
118124
uint8_t EHMTX_store::count_active_screens()
119125
{
120126
uint8_t count = 0;

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)