From 72077bc16000cb7188fe0fd0d293d4c3cb1edeee Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Thu, 18 May 2023 13:58:17 +0200 Subject: [PATCH 01/19] clean up preparation for rtl --- components/ehmtxv2/EHMTX.cpp | 83 +++++++++--------------------- components/ehmtxv2/EHMTX.h | 6 ++- components/ehmtxv2/EHMTX_queue.cpp | 62 ++++++++++++---------- components/ehmtxv2/__init__.py | 5 ++ tests/ehtmxv2-template.yaml | 1 + 5 files changed, 70 insertions(+), 87 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index d01cade..62464c8 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -219,7 +219,7 @@ namespace esphome void EHMTX::blank_screen(int lifetime, int showtime) { auto scr = this->find_free_queue_element(); - scr->screen_time = showtime; + scr->screen_time_ = showtime; scr->mode = MODE_BLANK; scr->endtime = this->clock->now().timestamp + lifetime * 60; } @@ -259,7 +259,7 @@ namespace esphome { ESP_LOGD(TAG, "force_screen: found position: %d", i); this->queue[i]->last_time = 0; - this->queue[i]->endtime += this->queue[i]->screen_time; + this->queue[i]->endtime += this->queue[i]->screen_time_; this->next_action_time = this->clock->now().timestamp; ESP_LOGW(TAG, "force_screen: icon %s in mode %d", icon_name.c_str(), mode); } @@ -322,7 +322,7 @@ namespace esphome this->queue[i]->endtime = 0; if (this->queue[i]->mode != MODE_EMPTY) { - ESP_LOGD(TAG, "remove expired queue element: removed slot %d: icon_name: %s text: %s", i, this->queue[i]->icon_name.c_str(), this->queue[i]->text.c_str()); + ESP_LOGD(TAG, "remove expired queue element: slot %d: icon_name: %s text: %s", i, this->queue[i]->icon_name.c_str(), this->queue[i]->text.c_str()); for (auto *t : on_expired_screen_triggers_) { infotext = ""; @@ -384,7 +384,7 @@ namespace esphome if (this->screen_pointer != MAXQUEUE) { this->queue[this->screen_pointer]->shiftx_ = 0; - this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time; + this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_; if (this->queue[this->screen_pointer]->icon < this->icon_count) { this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0); @@ -544,35 +544,14 @@ namespace esphome } EHMTX_queue *screen = this->find_icon_queue_element(icon); - int x, y, pixel, h; - if (default_font) - { - this->display->get_text_bounds(0, 0, text.c_str(), this->default_font, display::TextAlign::LEFT, &x, &y, &pixel, &h); - } - else - { - this->display->get_text_bounds(0, 0, text.c_str(), this->special_font, display::TextAlign::LEFT, &x, &y, &pixel, &h); - } - if (pixel < 23) - { - screen->centerx_ = ceil((22 - pixel) / 2); - screen->screen_time = screen_time; - } - else - { - screen->centerx_ = 0; - int display_duration = ceil((this->scroll_count * (TEXTSTARTOFFSET + pixel) * this->scroll_interval) / 1000); - screen->screen_time = (display_duration > screen_time) ? display_duration : screen_time; - } screen->text = text; - screen->pixels_ = pixel; screen->endtime = this->clock->now().timestamp + lifetime * 60; - screen->shiftx_ = 0; screen->text_color = Color(r, g, b); screen->default_font = default_font; screen->mode = MODE_ICON_SCREEN; screen->icon_name = iconname; screen->icon = icon; + screen->calc_scroll_time(text,screen_time); for (auto *t : on_add_screen_triggers_) { t->process(screen->icon_name, (uint8_t)screen->mode); @@ -595,35 +574,15 @@ namespace esphome } } EHMTX_queue *screen = this->find_icon_queue_element(icon); - - int x, y, pixel, h; - if (default_font) - { - this->display->get_text_bounds(0, 0, text.c_str(), this->default_font, display::TextAlign::LEFT, &x, &y, &pixel, &h); - } - else - { - this->display->get_text_bounds(0, 0, text.c_str(), this->special_font, display::TextAlign::LEFT, &x, &y, &pixel, &h); - } - if (pixel < 23) - { - screen->centerx_ = ceil((22 - pixel) / 2); - screen->screen_time = screen_time; - } - else - { - screen->centerx_ = 0; - int display_duration = ceil((this->scroll_count * (TEXTSTARTOFFSET + pixel) * this->scroll_interval) / 1000); - screen->screen_time = (display_duration > screen_time) ? display_duration : screen_time; - } + screen->text = text; - screen->pixels_ = pixel; + screen->endtime = this->clock->now().timestamp + lifetime * 60; - screen->shiftx_ = 0; screen->default_font = default_font; screen->mode = MODE_RAINBOW_ICON; screen->icon_name = iconname; screen->icon = icon; + screen->calc_scroll_time(text,screen_time); for (auto *t : on_add_screen_triggers_) { t->process(screen->icon_name, (uint8_t)screen->mode); @@ -639,7 +598,7 @@ 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; - screen->screen_time = (screen_time > this->clock_interval)?screen_time:this->clock_interval-1; + screen->screen_time_ = (screen_time > this->clock_interval)?screen_time:this->clock_interval-1; screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } @@ -651,7 +610,7 @@ namespace esphome ESP_LOGD(TAG, "rainbow_date_screen lifetime: %d screen_time: %d", lifetime, screen_time); screen->mode = MODE_RAINBOW_DATE; screen->default_font = default_font; - screen->screen_time = screen_time; + screen->screen_time_ = screen_time; screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } @@ -662,24 +621,21 @@ namespace esphome screen->text = text; screen->endtime = this->clock->now().timestamp + lifetime * 60; - screen->screen_time = screen_time; screen->default_font = default_font; screen->text_color = Color(r, g, b); screen->mode = MODE_TEXT_SCREEN; - screen->calc_scroll_time(); + screen->calc_scroll_time(text,screen_time); screen->status(); } void EHMTX::rainbow_text_screen(std::string text, int lifetime, int screen_time, bool default_font) { EHMTX_queue *screen = this->find_free_queue_element(); - screen->text = text; screen->endtime = this->clock->now().timestamp + lifetime * 60; - screen->screen_time = screen_time; screen->default_font = default_font; screen->mode = MODE_RAINBOW_TEXT; - screen->calc_scroll_time(); + screen->calc_scroll_time(text,screen_time); screen->status(); } @@ -701,7 +657,7 @@ namespace esphome screen->mode = MODE_FULL_SCREEN; screen->icon = icon; screen->icon_name = iconname; - screen->screen_time = screen_time; + screen->screen_time_ = screen_time; screen->endtime = this->clock->now().timestamp + lifetime * 60; for (auto *t : on_add_screen_triggers_) { @@ -719,7 +675,7 @@ namespace esphome ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b); screen->mode = MODE_CLOCK; screen->default_font = default_font; - screen->screen_time = (screen_time > this->clock_interval)?screen_time:this->clock_interval-1; + screen->screen_time_ = (this->clock_interval > screen_time )?screen_time:this->clock_interval-1; screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } @@ -731,7 +687,7 @@ namespace esphome screen->text_color = Color(r, g, b); ESP_LOGD(TAG, "date_screen lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b); screen->mode = MODE_DATE; - screen->screen_time = screen_time; + screen->screen_time_ = screen_time; screen->default_font = default_font; screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); @@ -777,6 +733,15 @@ namespace esphome } } + void EHMTX::set_rtl(bool b) + { + this->rtl = b; + if (b) + { + ESP_LOGI(TAG, "show text right to left"); + } + } + void EHMTX::set_show_seconds(bool b) { this->show_seconds = b; diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 9d1855d..2a7781d 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -67,6 +67,7 @@ namespace esphome bool display_gauge; bool is_running=false; bool show_date; + bool rtl; uint8_t gauge_value; uint16_t clock_time; uint8_t scroll_count; @@ -113,6 +114,7 @@ namespace esphome void set_show_day_of_week(bool b); void set_show_seconds(bool b); void set_show_date(bool b); + void set_rtl(bool b); void set_font_offset(int8_t x, int8_t y); void set_week_start(bool b); void set_brightness(int b); @@ -175,7 +177,7 @@ namespace esphome uint8_t centerx_; uint16_t shiftx_; uint16_t pixels_; - uint16_t screen_time; + uint16_t screen_time_; bool default_font; time_t endtime; time_t last_time; @@ -194,7 +196,7 @@ namespace esphome bool update_slot(uint8_t _icon); void update_screen(); void hold_slot(uint8_t _sec); - void calc_scroll_time(); + void calc_scroll_time(std::string,uint16_t ); }; class EHMTXNextScreenTrigger : public Trigger diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 433acb6..12f33fc 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -10,7 +10,7 @@ namespace esphome this->last_time = 0; this->centerx_ = 0; this->shiftx_ = 0; - this->screen_time = 0; + this->screen_time_ = 0; this->mode = MODE_EMPTY; this->icon_name = ""; this->icon = 0; @@ -23,37 +23,37 @@ namespace esphome switch (this->mode) { case MODE_EMPTY: - ESP_LOGD(TAG, "queue: empty slot"); + ESP_LOGD(TAG, " empty slot"); break; case MODE_BLANK: - ESP_LOGD(TAG, "queue: blank screen for %d sec", this->screen_time); + ESP_LOGD(TAG, "queue: blank screen for %d sec", this->screen_time_); break; case MODE_CLOCK: - ESP_LOGD(TAG, "queue: clock for %d sec", this->screen_time); + ESP_LOGD(TAG, "queue: clock for: %d sec", this->screen_time_); break; case MODE_DATE: - ESP_LOGD(TAG, "queue: date for %d sec", this->screen_time); + ESP_LOGD(TAG, "queue: date for: %d sec", this->screen_time_); break; case MODE_FULL_SCREEN: - ESP_LOGD(TAG, "queue: full screen: %s for %d sec", this->icon_name.c_str(), this->screen_time); + ESP_LOGD(TAG, "queue: full screen: \"%s\" for: %d sec", this->icon_name.c_str(), this->screen_time_); break; case MODE_ICON_SCREEN: - ESP_LOGD(TAG, "queue: icon screen: %s text: %s for %d sec", this->icon_name.c_str(), this->text.c_str(), this->screen_time); + ESP_LOGD(TAG, "queue: icon screen: \"%s\" text: %s for: %d sec", this->icon_name.c_str(), this->text.c_str(), this->screen_time_); break; case MODE_TEXT_SCREEN: - ESP_LOGD(TAG, "queue: text text: %s for %d sec", this->text.c_str(), this->screen_time); + ESP_LOGD(TAG, "queue: text text: \"%s\" for: %d sec", this->text.c_str(), this->screen_time_); break; case MODE_RAINBOW_ICON: - ESP_LOGD(TAG, "queue: rainbow icon: %s text: %s for %d sec", this->icon_name.c_str(), this->text.c_str(), this->screen_time); + ESP_LOGD(TAG, "queue: rainbow icon: \"%s\" text: %s for: %d sec", this->icon_name.c_str(), this->text.c_str(), this->screen_time_); break; case MODE_RAINBOW_TEXT: - ESP_LOGD(TAG, "queue: rainbow text: %s for %d sec", this->text.c_str(), this->screen_time); + ESP_LOGD(TAG, "queue: rainbow text: \"%s\" for: %d sec", this->text.c_str(), this->screen_time_); break; case MODE_RAINBOW_CLOCK: - ESP_LOGD(TAG, "queue: clock for %d sec", this->screen_time); + ESP_LOGD(TAG, "queue: clock for: %d sec", this->screen_time_); break; case MODE_RAINBOW_DATE: - ESP_LOGD(TAG, "queue: date for %d sec", this->screen_time); + ESP_LOGD(TAG, "queue: date for: %d sec", this->screen_time_); break; default: ESP_LOGD(TAG, "queue: UPPS"); @@ -135,7 +135,8 @@ namespace esphome { this->config_->display->draw_pixel_at(0, 0, color_); } - if (this->mode != MODE_RAINBOW_CLOCK){ + if (this->mode != MODE_RAINBOW_CLOCK) + { this->config_->draw_day_of_week(); } } @@ -156,7 +157,8 @@ namespace esphome { this->config_->display->draw_pixel_at(0, 0, color_); } - if (this->mode != MODE_RAINBOW_DATE){ + if (this->mode != MODE_RAINBOW_DATE) + { this->config_->draw_day_of_week(); } } @@ -215,7 +217,7 @@ namespace esphome break; } this->update_screen(); - } + } } void EHMTX_queue::hold_slot(uint8_t _sec) @@ -225,8 +227,8 @@ namespace esphome } // TODO void EHMTX_queue::set_mode_icon() - - void EHMTX_queue::calc_scroll_time() + + void EHMTX_queue::calc_scroll_time(std::string text, uint16_t screen_time) { int x, y, w, h; float display_duration; @@ -240,33 +242,41 @@ namespace esphome } this->pixels_ = w; + this->centerx_ = 0; this->shiftx_ = 0; switch (this->mode) { case MODE_RAINBOW_TEXT: case MODE_TEXT_SCREEN: - display_duration = ceil((28+(this->config_->scroll_count * (32 + this->pixels_)) * this->config_->scroll_interval) / 1000); - this->screen_time = (display_duration > this->screen_time) ? display_duration : this->screen_time; if (this->pixels_ < 32) { + this->screen_time_ = screen_time; this->centerx_ = ceil((32 - this->pixels_) / 2); } - break; + else + { + display_duration = ceil((28 + (this->config_->scroll_count * (32 + this->pixels_)) * this->config_->scroll_interval) / 1000); + this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; + } + break; case MODE_RAINBOW_ICON: case MODE_ICON_SCREEN: - display_duration = ceil(((28-TEXTSTARTOFFSET)+(this->config_->scroll_count * (TEXTSTARTOFFSET + this->pixels_)) * this->config_->scroll_interval) / 1000); - this->screen_time = (display_duration > this->screen_time) ? display_duration : this->screen_time; if (this->pixels_ < 23) { + this->screen_time_ = screen_time; this->centerx_ = ceil((23 - this->pixels_) / 2); } - break; + else + { + display_duration = ceil((this->config_->scroll_count * (TEXTSTARTOFFSET + this->pixels_) * this->config_->scroll_interval) / 1000); + this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; + } + break; default: break; } - - this->shiftx_ = 0; - ESP_LOGD(TAG, "display text: %s pixels %d calculated: %d", text.c_str(), this->pixels_, this->screen_time); + + ESP_LOGD(TAG, "calc_scroll_time: mode: %d text: \"%s\" pixels %d calculated: %d defined: %d", this->mode, text.c_str(), this->pixels_, this->screen_time_, screen_time); } } diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index 7964046..8e228f8 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -66,6 +66,7 @@ CONF_LIFETIME = "lifetime" CONF_ICONS = "icons" CONF_SHOWDOW = "show_dow" CONF_SHOWDATE = "show_date" +CONF_RTL = "rtl" CONF_FRAMEDURATION = "frame_duration" CONF_SCROLLCOUNT = "scroll_count" CONF_MATRIXCOMPONENT = "matrix_component" @@ -105,6 +106,9 @@ EHMTX_SCHEMA = cv.Schema({ ): cv.templatable(cv.positive_int), cv.Optional( CONF_HTML, default=False + ): cv.boolean, + cv.Optional( + CONF_RTL, default=False ): cv.boolean, cv.Optional( CONF_SHOW_SECONDS, default=False @@ -362,6 +366,7 @@ async def to_code(config): cg.add(var.set_brightness(config[CONF_BRIGHTNESS])) cg.add(var.set_scroll_interval(config[CONF_SCROLLINTERVAL])) cg.add(var.set_rainbow_interval(config[CONF_SCROLLINTERVAL])) + cg.add(var.set_rtl(config[CONF_RTL])) cg.add(var.set_scroll_count(config[CONF_SCROLLCOUNT])) cg.add(var.set_frame_interval(config[CONF_FRAMEINTERVAL])) cg.add(var.set_week_start(config[CONF_WEEK_START_MONDAY])) diff --git a/tests/ehtmxv2-template.yaml b/tests/ehtmxv2-template.yaml index 245595a..d802ae2 100644 --- a/tests/ehtmxv2-template.yaml +++ b/tests/ehtmxv2-template.yaml @@ -117,6 +117,7 @@ ehmtxv2: time_format: "%H:%M" date_format: "%d.%m." show_seconds: false + clock_interval: 90 default_font_id: default_font special_font_id: default_font icons: From a167b12a4582dd52a104573ae87ba5609ed98ecd Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Thu, 18 May 2023 15:16:56 +0200 Subject: [PATCH 02/19] rtl for icon screen --- components/ehmtxv2/EHMTX.h | 1 + components/ehmtxv2/EHMTX_queue.cpp | 71 ++++++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 2a7781d..9dff312 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -197,6 +197,7 @@ namespace esphome void update_screen(); void hold_slot(uint8_t _sec); void calc_scroll_time(std::string,uint16_t ); + int xpos(); }; class EHMTXNextScreenTrigger : public Trigger diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 12f33fc..ae23ddc 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -61,6 +61,52 @@ namespace esphome } } + int EHMTX_queue::xpos() + { + uint8_t width = 32; + uint8_t startx = 0; + switch (this->mode) + { + case MODE_RAINBOW_ICON: + case MODE_ICON_SCREEN: + startx = 8; + break; + case MODE_TEXT_SCREEN: + case MODE_RAINBOW_TEXT: + // no correction + break; + } + + if (this->config_->display_gauge) + { + startx += 2; + } + width -= startx; + + if (this->config_->rtl) + { + if (this->pixels_ < width) + { + return 32 - ceil((width - this->pixels_) / 2); + } + else + { + return startx + this->shiftx_; + } + } + else + { + if (this->pixels_ < width) + { + return startx + ceil((width - this->pixels_) / 2); + } + else + { + return startx - this->shiftx_ + width; + } + } + } + void EHMTX_queue::update_screen() { if (millis() - this->config_->last_rainbow_time >= this->config_->rainbow_interval) @@ -79,13 +125,13 @@ namespace esphome if ((this->mode == MODE_ICON_SCREEN) || (this->mode == MODE_RAINBOW_ICON)) { if (millis() - this->config_->last_scroll_time >= this->config_->scroll_interval && this->pixels_ > TEXTSTARTOFFSET) - { - this->shiftx_++; - if (this->shiftx_ > this->pixels_ + TEXTSTARTOFFSET) - { - this->shiftx_ = 0; - } - this->config_->last_scroll_time = millis(); + { + this->shiftx_++; + if (this->shiftx_ > this->pixels_ + TEXTSTARTOFFSET) + { + this->shiftx_ = 0; + } + this->config_->last_scroll_time = millis(); } } if ((this->mode == MODE_TEXT_SCREEN) || (this->mode == MODE_RAINBOW_TEXT)) @@ -183,9 +229,16 @@ namespace esphome } color_ = (this->mode == MODE_RAINBOW_ICON) ? this->config_->rainbow_color : this->text_color; - - this->config_->display->print(this->centerx_ + TEXTSCROLLSTART - this->shiftx_ + extraoffset + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + if (this->config_->rtl) { + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, this->text.c_str()); + } + else { + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + this->text.c_str()); + // this->config_->display->print(this->centerx_ + TEXTSCROLLSTART - this->shiftx_ + extraoffset + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + // this->text.c_str()); + } if (this->config_->display_gauge) { this->config_->display->image(2, 0, this->config_->icons[this->icon]); From ebb12dccadc3261e576508842656e0ba5529dff9 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Thu, 18 May 2023 17:52:32 +0200 Subject: [PATCH 03/19] before scroll_step --- components/ehmtxv2/EHMTX.cpp | 22 +++++++++++++++++++++- components/ehmtxv2/EHMTX.h | 1 + components/ehmtxv2/EHMTX_queue.cpp | 7 +++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 62464c8..45c3945 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -361,7 +361,7 @@ namespace esphome } void EHMTX::tick() { - this->hue_++; + this->hue_++; if (this->hue_ == 360) { this->hue_ = 0; @@ -369,6 +369,25 @@ namespace esphome float red, green, blue; esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, red, green, blue); this->rainbow_color = Color(uint8_t(255 * red), uint8_t(255 * green), uint8_t(255 * blue)); + + this->scroll_step++; + + switch (this->queue[this->screen_pointer]->mode) + { + case MODE_ICON_SCREEN: + case MODE_RAINBOW_ICON: + if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8) { + this->scroll_step = 0; + } + break; + case MODE_RAINBOW_TEXT: + case MODE_TEXT_SCREEN: + if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31) { + this->scroll_step = 0; + } + break; + } + time_t ts = this->clock->now().timestamp; if (this->is_running) @@ -384,6 +403,7 @@ namespace esphome if (this->screen_pointer != MAXQUEUE) { this->queue[this->screen_pointer]->shiftx_ = 0; + this->scroll_step=0; this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_; if (this->queue[this->screen_pointer]->icon < this->icon_count) { diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 9dff312..f01855b 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -70,6 +70,7 @@ namespace esphome bool rtl; uint8_t gauge_value; uint16_t clock_time; + uint16_t scroll_step; uint8_t scroll_count; void remove_expired_queue_element(); uint8_t find_oldest_queue_element(); diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index ae23ddc..0b0fdc6 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -142,6 +142,7 @@ namespace esphome if (this->shiftx_ > this->pixels_ + 32) { this->shiftx_ = 0; + } this->config_->last_scroll_time = millis(); } @@ -236,8 +237,6 @@ namespace esphome else { this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, this->text.c_str()); - // this->config_->display->print(this->centerx_ + TEXTSCROLLSTART - this->shiftx_ + extraoffset + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, - // this->text.c_str()); } if (this->config_->display_gauge) { @@ -263,7 +262,7 @@ namespace esphome extraoffset += 2; } color_ = (this->mode == MODE_RAINBOW_TEXT) ? this->config_->rainbow_color : this->text_color; - this->config_->display->print(this->centerx_ - this->shiftx_ + xoffset + extraoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, this->text.c_str()); break; default: @@ -301,7 +300,7 @@ namespace esphome switch (this->mode) { case MODE_RAINBOW_TEXT: - case MODE_TEXT_SCREEN: + case MODE_TEXT_SCREEN: if (this->pixels_ < 32) { this->screen_time_ = screen_time; From 4720583311f6700e10589a130d65c697cfbf5af1 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 10:03:50 +0200 Subject: [PATCH 04/19] remove shiftx_ --- README.md | 2 +- components/ehmtxv2/EHMTX.cpp | 26 ++++++++---------------- components/ehmtxv2/EHMTX.h | 1 - components/ehmtxv2/EHMTX_queue.cpp | 32 ++---------------------------- 4 files changed, 11 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index d2598c3..53f9f32 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Important information -If you like my work, please donate me a star on GitHub and consider sponsoring me!! +If you like my work, please donate me a star on GitHub and consider [sponsoring](https://www.paypal.com/donate/?hosted_button_id=FZDKSLQ46HJTU) me!! ## Introduction diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 45c3945..e25d500 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -370,24 +370,15 @@ namespace esphome esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, red, green, blue); this->rainbow_color = Color(uint8_t(255 * red), uint8_t(255 * green), uint8_t(255 * blue)); - this->scroll_step++; - - switch (this->queue[this->screen_pointer]->mode) - { - case MODE_ICON_SCREEN: - case MODE_RAINBOW_ICON: - if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8) { - this->scroll_step = 0; - } - break; - case MODE_RAINBOW_TEXT: - case MODE_TEXT_SCREEN: - if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31) { - this->scroll_step = 0; - } - break; + if (millis() - this->last_scroll_time >= this->scroll_interval){ + this->scroll_step++; + this->last_scroll_time = millis(); + + if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 32) { + this->scroll_step = 0; } - + } + time_t ts = this->clock->now().timestamp; if (this->is_running) @@ -402,7 +393,6 @@ namespace esphome } if (this->screen_pointer != MAXQUEUE) { - this->queue[this->screen_pointer]->shiftx_ = 0; this->scroll_step=0; this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_; if (this->queue[this->screen_pointer]->icon < this->icon_count) diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index f01855b..b80be31 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -176,7 +176,6 @@ namespace esphome public: uint8_t centerx_; - uint16_t shiftx_; uint16_t pixels_; uint16_t screen_time_; bool default_font; diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 0b0fdc6..192a6df 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -9,7 +9,6 @@ namespace esphome this->endtime = 0; this->last_time = 0; this->centerx_ = 0; - this->shiftx_ = 0; this->screen_time_ = 0; this->mode = MODE_EMPTY; this->icon_name = ""; @@ -91,7 +90,7 @@ namespace esphome } else { - return startx + this->shiftx_; + return startx + this->config_->scroll_step; } } else @@ -102,7 +101,7 @@ namespace esphome } else { - return startx - this->shiftx_ + width; + return startx - this->config_->scroll_step + width; } } } @@ -122,32 +121,6 @@ namespace esphome this->config_->last_rainbow_time = millis(); } - if ((this->mode == MODE_ICON_SCREEN) || (this->mode == MODE_RAINBOW_ICON)) - { - if (millis() - this->config_->last_scroll_time >= this->config_->scroll_interval && this->pixels_ > TEXTSTARTOFFSET) - { - this->shiftx_++; - if (this->shiftx_ > this->pixels_ + TEXTSTARTOFFSET) - { - this->shiftx_ = 0; - } - this->config_->last_scroll_time = millis(); - } - } - if ((this->mode == MODE_TEXT_SCREEN) || (this->mode == MODE_RAINBOW_TEXT)) - { - if (millis() - this->config_->last_scroll_time >= this->config_->scroll_interval && this->pixels_ >= 32) - { - this->shiftx_++; - if (this->shiftx_ > this->pixels_ + 32) - { - this->shiftx_ = 0; - - } - this->config_->last_scroll_time = millis(); - } - } - if (millis() - this->config_->last_anim_time >= this->config_->icons[this->icon]->frame_duration) { this->config_->icons[this->icon]->next_frame(); @@ -295,7 +268,6 @@ namespace esphome this->pixels_ = w; this->centerx_ = 0; - this->shiftx_ = 0; switch (this->mode) { From cb7cdd4341ae46d1e7b7afd415884be728560401 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 16:38:03 +0200 Subject: [PATCH 05/19] Revert "remove shiftx_" This reverts commit 4720583311f6700e10589a130d65c697cfbf5af1. --- components/ehmtxv2/EHMTX.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 45c3945..e142ff2 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -228,7 +228,7 @@ namespace esphome { if (!this->is_running) { - if (this->clock->now().timestamp > 15) + if (this->clock->is_valid()) { ESP_LOGD(TAG, "time sync => starting"); this->is_running = true; @@ -238,12 +238,6 @@ namespace esphome void EHMTX::force_screen(std::string icon_name, int mode) { - // if (this->string_has_ending(icon_name, "*")) - // { - // // remove the * - // icon_name = icon_name.substr(0, icon_name.length() - 1); - // } - for (uint8_t i = 0; i < MAXQUEUE; i++) { if (this->queue[i]->mode == mode) From e86227304d262813cfbd384169eb6a6f0927f28d Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 19:20:34 +0200 Subject: [PATCH 06/19] slightky working --- components/ehmtxv2/EHMTX.cpp | 80 ++++++++++++++++++------------ components/ehmtxv2/EHMTX.h | 6 +-- components/ehmtxv2/EHMTX_queue.cpp | 4 +- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index e142ff2..4b9d43a 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -20,7 +20,7 @@ namespace esphome this->alarm_color = Color(CA_RED, CA_GREEN, CA_BLUE); this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE); this->gauge_value = 0; - this->screen_pointer = 0; + this->screen_pointer = MAXQUEUE; for (uint8_t i = 0; i < MAXQUEUE; i++) { @@ -194,6 +194,7 @@ namespace esphome register_service(&EHMTX::set_brightness, "brightness", {"value"}); ESP_LOGD(TAG, "Setup and running!"); + this->is_running = true; } void EHMTX::show_alarm(int r, int g, int b, int size) @@ -228,9 +229,9 @@ namespace esphome { if (!this->is_running) { - if (this->clock->is_valid()) + if (this->clock->now().is_valid()) { - ESP_LOGD(TAG, "time sync => starting"); + ESP_LOGD(TAG, "time sync => start running"); this->is_running = true; } } @@ -288,9 +289,9 @@ namespace esphome time_t ts = this->clock->now().timestamp; for (size_t i = 0; i < MAXQUEUE; i++) { - if ((this->queue[i]->mode == MODE_CLOCK)||(this->queue[i]->mode == MODE_RAINBOW_CLOCK)) + if ((this->queue[i]->mode == MODE_CLOCK) || (this->queue[i]->mode == MODE_RAINBOW_CLOCK)) { - if (ts > (this->queue[i]->last_time + this->clock_interval)) + if (ts > (this->queue[i]->last_time + this->clock_interval)) { hit = i; } @@ -355,7 +356,7 @@ namespace esphome } void EHMTX::tick() { - this->hue_++; + this->hue_++; if (this->hue_ == 360) { this->hue_ = 0; @@ -363,24 +364,6 @@ namespace esphome float red, green, blue; esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, red, green, blue); this->rainbow_color = Color(uint8_t(255 * red), uint8_t(255 * green), uint8_t(255 * blue)); - - this->scroll_step++; - - switch (this->queue[this->screen_pointer]->mode) - { - case MODE_ICON_SCREEN: - case MODE_RAINBOW_ICON: - if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8) { - this->scroll_step = 0; - } - break; - case MODE_RAINBOW_TEXT: - case MODE_TEXT_SCREEN: - if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31) { - this->scroll_step = 0; - } - break; - } time_t ts = this->clock->now().timestamp; @@ -388,16 +371,37 @@ namespace esphome { if (ts > this->next_action_time) { + this->scroll_step++; + this->remove_expired_queue_element(); this->screen_pointer = this->find_last_clock(); if (this->screen_pointer == MAXQUEUE) { this->screen_pointer = find_oldest_queue_element(); } + switch (this->queue[this->screen_pointer]->mode) + { + case MODE_ICON_SCREEN: + case MODE_RAINBOW_ICON: + if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8) + { + this->scroll_step = 0; + } + break; + case MODE_RAINBOW_TEXT: + case MODE_TEXT_SCREEN: + if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31) + { + this->scroll_step = 0; + } + break; + } + ESP_LOGD(TAG, "tick action Pointer: %d",this->screen_pointer); + if (this->screen_pointer != MAXQUEUE) { this->queue[this->screen_pointer]->shiftx_ = 0; - this->scroll_step=0; + this->scroll_step = 0; this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_; if (this->queue[this->screen_pointer]->icon < this->icon_count) { @@ -431,6 +435,7 @@ namespace esphome } else { + ESP_LOGD(TAG, "tick rectangle %d", this->is_running); uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32; this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40)); this->boot_anim++; @@ -565,7 +570,7 @@ namespace esphome screen->mode = MODE_ICON_SCREEN; screen->icon_name = iconname; screen->icon = icon; - screen->calc_scroll_time(text,screen_time); + screen->calc_scroll_time(text, screen_time); for (auto *t : on_add_screen_triggers_) { t->process(screen->icon_name, (uint8_t)screen->mode); @@ -588,15 +593,15 @@ namespace esphome } } EHMTX_queue *screen = this->find_icon_queue_element(icon); - + screen->text = text; - + screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->default_font = default_font; screen->mode = MODE_RAINBOW_ICON; screen->icon_name = iconname; screen->icon = icon; - screen->calc_scroll_time(text,screen_time); + screen->calc_scroll_time(text, screen_time); for (auto *t : on_add_screen_triggers_) { t->process(screen->icon_name, (uint8_t)screen->mode); @@ -612,7 +617,7 @@ 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; - screen->screen_time_ = (screen_time > this->clock_interval)?screen_time:this->clock_interval-1; + screen->screen_time_ = (screen_time > this->clock_interval) ? screen_time : this->clock_interval - 1; screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } @@ -638,7 +643,7 @@ namespace esphome screen->default_font = default_font; screen->text_color = Color(r, g, b); screen->mode = MODE_TEXT_SCREEN; - screen->calc_scroll_time(text,screen_time); + screen->calc_scroll_time(text, screen_time); screen->status(); } @@ -649,7 +654,7 @@ namespace esphome screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->default_font = default_font; screen->mode = MODE_RAINBOW_TEXT; - screen->calc_scroll_time(text,screen_time); + screen->calc_scroll_time(text, screen_time); screen->status(); } @@ -689,7 +694,11 @@ namespace esphome ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b); screen->mode = MODE_CLOCK; screen->default_font = default_font; - screen->screen_time_ = (this->clock_interval > screen_time )?screen_time:this->clock_interval-1; + if (this->clock_interval ==0 || (this->clock_interval > screen_time )) { + screen->screen_time_ = screen_time; + } else { + screen->screen_time_ = this->clock_interval-2; + } screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } @@ -885,6 +894,10 @@ namespace esphome { ESP_LOGCONFIG(TAG, "show date"); } + if (this->rtl) + { + ESP_LOGCONFIG(TAG, "RTL activated"); + } if (this->week_starts_monday) { ESP_LOGCONFIG(TAG, "weekstart: monday"); @@ -893,6 +906,7 @@ namespace esphome { ESP_LOGCONFIG(TAG, "weekstart: sunday"); } + this->is_running = true; } void EHMTX::add_icon(EHMTX_Icon *icon) diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index f01855b..252c832 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -20,7 +20,7 @@ const uint8_t MAXICONS = 90; const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); -const uint16_t POLLINGINTERVAL = 800; +const uint16_t POLLINGINTERVAL = 1000; static const char *const EHMTX_VERSION = "Version: 2023.5.0 beta"; static const char *const TAG = "EHMTXv2"; enum show_mode : uint8_t { MODE_EMPTY = 0,MODE_BLANK = 1, MODE_CLOCK = 2, MODE_DATE = 3, MODE_FULL_SCREEN = 4, MODE_ICON_SCREEN = 5, MODE_TEXT_SCREEN = 6 , MODE_RAINBOW_ICON = 7,MODE_RAINBOW_TEXT = 8, MODE_RAINBOW_CLOCK = 9,MODE_RAINBOW_DATE=10 }; @@ -37,7 +37,7 @@ namespace esphome class EHMTX : public PollingComponent, public api::CustomAPIDevice { protected: - float get_setup_priority() const override { return esphome::setup_priority::PROCESSOR; } + float get_setup_priority() const override { return esphome::setup_priority::BEFORE_CONNECTION; } uint8_t brightness_; uint32_t boot_anim=0; uint8_t screen_pointer; @@ -57,7 +57,7 @@ namespace esphome EHMTX(); Color text_color, alarm_color, gauge_color,indicator_color,clock_color; Color today_color,weekday_color,rainbow_color; - int hue_; + uint16_t hue_=0; void dump_config(); std::string time_fmt; std::string date_fmt; diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 0b0fdc6..0afdc59 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -172,7 +172,7 @@ namespace esphome break; case MODE_RAINBOW_CLOCK: case MODE_CLOCK: - if (this->config_->clock->now().timestamp > 6000) // valid time + if (this->config_->clock->now().is_valid()) // valid time { color_ = (this->mode == MODE_RAINBOW_CLOCK) ? this->config_->rainbow_color : this->config_->clock_color; time_t ts = this->config_->clock->now().timestamp; @@ -194,7 +194,7 @@ namespace esphome break; case MODE_RAINBOW_DATE: case MODE_DATE: - if (this->config_->clock->now().timestamp > 6000) // valid time + if (this->config_->clock->now().is_valid()) { color_ = (this->mode == MODE_RAINBOW_DATE) ? this->config_->rainbow_color : this->config_->clock_color; time_t ts = this->config_->clock->now().timestamp; From 6c7015752f6b09ba318aba19a11671956845bfcf Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 19:50:44 +0200 Subject: [PATCH 07/19] ulanzi problems --- README.md | 6 ++++-- components/ehmtxv2/EHMTX.cpp | 3 +-- components/ehmtxv2/EHMTX.h | 2 +- copy2esphome/ulanzi-easy.yaml | 18 ------------------ tests/ulanzi-easy.yaml | 18 ------------------ 5 files changed, 6 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index d2598c3..e9d4352 100644 --- a/README.md +++ b/README.md @@ -1032,7 +1032,9 @@ sensor: ## Breaking changes -### **nothing yet, since it is new** +### 2023.5.0 + +- removed the rtttl buzzer from the ulanzi easy template, because it often caused reboots! ## EspHoMaTriX in the media @@ -1065,7 +1067,7 @@ THE SOFTWARE IS PROVIDED "AS IS", use at your own risk! - **[aptonline](https://github.com/aptonline)** for his work on the ulanzi hardware - **[wsbtak](https://github.com/wsbtak)** for the work on the ulanzi hardware - **[ofirsnb](https://github.com/ofirsnb)** for his contributions -- **[darkpoet78](https://github.com/darkpoet78/MatrixClockFonts)** for his work on optimized fonts +- **[darkpoet78](https://github.com/darkpoet78/MatrixClockFonts)** for his work on optimized fonts and user support - **[pplucky](https://user-images.githubusercontent.com/16407309/224850723-634c9b2d-55d9-44f2-9f93-765c0485b090.GIF)** for his 8x32 GIF animation - **[dennisse](https://github.com/dennisse)** Auto brightness for the Ulanzi - **[geekofweek](https://github.com/geekofweek)** fixed sample YAML diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 4b9d43a..dd6803e 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -20,6 +20,7 @@ namespace esphome this->alarm_color = Color(CA_RED, CA_GREEN, CA_BLUE); this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE); this->gauge_value = 0; + this->next_action_time = 0; this->screen_pointer = MAXQUEUE; for (uint8_t i = 0; i < MAXQUEUE; i++) @@ -194,7 +195,6 @@ namespace esphome register_service(&EHMTX::set_brightness, "brightness", {"value"}); ESP_LOGD(TAG, "Setup and running!"); - this->is_running = true; } void EHMTX::show_alarm(int r, int g, int b, int size) @@ -906,7 +906,6 @@ namespace esphome { ESP_LOGCONFIG(TAG, "weekstart: sunday"); } - this->is_running = true; } void EHMTX::add_icon(EHMTX_Icon *icon) diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 252c832..0a0e993 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -37,7 +37,7 @@ namespace esphome class EHMTX : public PollingComponent, public api::CustomAPIDevice { protected: - float get_setup_priority() const override { return esphome::setup_priority::BEFORE_CONNECTION; } + float get_setup_priority() const override { return esphome::setup_priority::WIFI; } uint8_t brightness_; uint32_t boot_anim=0; uint8_t screen_pointer; diff --git a/copy2esphome/ulanzi-easy.yaml b/copy2esphome/ulanzi-easy.yaml index 1a2a49f..e42d99f 100644 --- a/copy2esphome/ulanzi-easy.yaml +++ b/copy2esphome/ulanzi-easy.yaml @@ -1,7 +1,5 @@ substitutions: devicename: ulanzi - ledpin: GPIO32 - buzzerpin: GPIO15 friendly_name: LED Matrix board: esp32dev # Pin definition from https://github.com/aptonline/PixelIt_Ulanzi @@ -11,7 +9,6 @@ substitutions: left_button_pin: GPIO26 mid_button_pin: GPIO27 right_button_pin: GPIO14 - buzzer_pin: GPIO15 scl_pin: GPIO22 sda_pin: GPIO21 @@ -99,13 +96,6 @@ logger: level: WARN api: - services: - - service: tune - variables: - tune: string - then: - - rtttl.play: - rtttl: !lambda 'return tune;' sensor: - platform: sht3xd @@ -168,14 +158,6 @@ wifi: web_server: -output: - - platform: ledc - pin: $buzzerpin - id: rtttl_out - -rtttl: - output: rtttl_out - i2c: sda: $sda_pin scl: $scl_pin diff --git a/tests/ulanzi-easy.yaml b/tests/ulanzi-easy.yaml index 1a2a49f..e42d99f 100644 --- a/tests/ulanzi-easy.yaml +++ b/tests/ulanzi-easy.yaml @@ -1,7 +1,5 @@ substitutions: devicename: ulanzi - ledpin: GPIO32 - buzzerpin: GPIO15 friendly_name: LED Matrix board: esp32dev # Pin definition from https://github.com/aptonline/PixelIt_Ulanzi @@ -11,7 +9,6 @@ substitutions: left_button_pin: GPIO26 mid_button_pin: GPIO27 right_button_pin: GPIO14 - buzzer_pin: GPIO15 scl_pin: GPIO22 sda_pin: GPIO21 @@ -99,13 +96,6 @@ logger: level: WARN api: - services: - - service: tune - variables: - tune: string - then: - - rtttl.play: - rtttl: !lambda 'return tune;' sensor: - platform: sht3xd @@ -168,14 +158,6 @@ wifi: web_server: -output: - - platform: ledc - pin: $buzzerpin - id: rtttl_out - -rtttl: - output: rtttl_out - i2c: sda: $sda_pin scl: $scl_pin From 31024249c917d1adb38bc8b4a2b3a0fcc8e6b267 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 20:24:11 +0200 Subject: [PATCH 08/19] remove shiftx --- README.md | 2 +- components/ehmtxv2/EHMTX.cpp | 100 ++++++++++++++--------------- components/ehmtxv2/EHMTX.h | 5 +- components/ehmtxv2/EHMTX_queue.cpp | 48 ++++---------- 4 files changed, 63 insertions(+), 92 deletions(-) diff --git a/README.md b/README.md index e9d4352..fae1834 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Important information -If you like my work, please donate me a star on GitHub and consider sponsoring me!! +If you like my work, please donate me a star on GitHub and consider [sponsoring](https://www.paypal.com/donate/?hosted_button_id=FZDKSLQ46HJTU) me!! ## Introduction diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index dd6803e..941ad6a 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -354,6 +354,7 @@ namespace esphome } } } + void EHMTX::tick() { this->hue_++; @@ -371,75 +372,62 @@ namespace esphome { if (ts > this->next_action_time) { - this->scroll_step++; - this->remove_expired_queue_element(); this->screen_pointer = this->find_last_clock(); if (this->screen_pointer == MAXQUEUE) { this->screen_pointer = find_oldest_queue_element(); } - switch (this->queue[this->screen_pointer]->mode) + if (millis() - this->last_scroll_time >= this->scroll_interval) { - case MODE_ICON_SCREEN: - case MODE_RAINBOW_ICON: - if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8) + this->scroll_step++; + this->last_scroll_time = millis(); + + if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 32) { this->scroll_step = 0; } - break; - case MODE_RAINBOW_TEXT: - case MODE_TEXT_SCREEN: - if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31) + if (this->screen_pointer != MAXQUEUE) { this->scroll_step = 0; - } - break; - } - ESP_LOGD(TAG, "tick action Pointer: %d",this->screen_pointer); - - if (this->screen_pointer != MAXQUEUE) - { - this->queue[this->screen_pointer]->shiftx_ = 0; - this->scroll_step = 0; - this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_; - if (this->queue[this->screen_pointer]->icon < this->icon_count) - { - this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0); - } - this->next_action_time = this->queue[this->screen_pointer]->last_time; - // Todo switch for Triggers - if (this->queue[this->screen_pointer]->mode == MODE_CLOCK) - { - for (auto *t : on_next_clock_triggers_) + this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_; + if (this->queue[this->screen_pointer]->icon < this->icon_count) + { + this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0); + } + this->next_action_time = this->queue[this->screen_pointer]->last_time; + // Todo switch for Triggers + if (this->queue[this->screen_pointer]->mode == MODE_CLOCK) + { + for (auto *t : on_next_clock_triggers_) + { + t->process(); + } + } + else { - t->process(); + for (auto *t : on_next_screen_triggers_) + { + t->process(this->queue[this->screen_pointer]->icon_name, this->queue[this->screen_pointer]->text); + } } } else { - for (auto *t : on_next_screen_triggers_) - { - t->process(this->queue[this->screen_pointer]->icon_name, this->queue[this->screen_pointer]->text); - } + ESP_LOGW(TAG, "tick: nothing to do. Restarting clock display!"); + this->clock_screen(24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); + this->date_screen(24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); + this->next_action_time = ts + this->clock_time; } } - else - { - ESP_LOGW(TAG, "tick: nothing to do. Restarting clock display!"); - this->clock_screen(24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); - this->date_screen(24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); - this->next_action_time = ts + this->clock_time; - } } } else - { - ESP_LOGD(TAG, "tick rectangle %d", this->is_running); - uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32; - this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40)); - this->boot_anim++; - } + { + uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32; + this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40)); + this->boot_anim++; + } } void EHMTX::skip_screen() @@ -617,7 +605,14 @@ 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; - screen->screen_time_ = (screen_time > this->clock_interval) ? screen_time : this->clock_interval - 1; + if (this->clock_interval == 0 || (this->clock_interval > screen_time)) + { + screen->screen_time_ = screen_time; + } + else + { + screen->screen_time_ = this->clock_interval - 2; + } screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } @@ -694,10 +689,13 @@ namespace esphome ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b); screen->mode = MODE_CLOCK; screen->default_font = default_font; - if (this->clock_interval ==0 || (this->clock_interval > screen_time )) { + if (this->clock_interval == 0 || (this->clock_interval > screen_time)) + { screen->screen_time_ = screen_time; - } else { - screen->screen_time_ = this->clock_interval-2; + } + else + { + screen->screen_time_ = this->clock_interval - 2; } screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 0a0e993..c475da7 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -37,7 +37,7 @@ namespace esphome class EHMTX : public PollingComponent, public api::CustomAPIDevice { protected: - float get_setup_priority() const override { return esphome::setup_priority::WIFI; } + float get_setup_priority() const override { return esphome::setup_priority::BEFORE_CONNECTION; } uint8_t brightness_; uint32_t boot_anim=0; uint8_t screen_pointer; @@ -109,7 +109,7 @@ namespace esphome void skip_screen(); void hold_screen(int t=30); void set_display(addressable_light::AddressableLightDisplay *disp); - void set_clock_interval(uint16_t t=60); + void set_clock_interval(uint16_t t=90); void set_hold_time(uint16_t t=30); void set_clock_time(uint16_t t=10); void set_show_day_of_week(bool b); @@ -176,7 +176,6 @@ namespace esphome public: uint8_t centerx_; - uint16_t shiftx_; uint16_t pixels_; uint16_t screen_time_; bool default_font; diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 0afdc59..a7124ab 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -9,7 +9,6 @@ namespace esphome this->endtime = 0; this->last_time = 0; this->centerx_ = 0; - this->shiftx_ = 0; this->screen_time_ = 0; this->mode = MODE_EMPTY; this->icon_name = ""; @@ -76,7 +75,7 @@ namespace esphome // no correction break; } - + if (this->config_->display_gauge) { startx += 2; @@ -91,7 +90,7 @@ namespace esphome } else { - return startx + this->shiftx_; + return startx + this->config_->scroll_step; } } else @@ -102,7 +101,7 @@ namespace esphome } else { - return startx - this->shiftx_ + width; + return startx - this->config_->scroll_step + width; } } } @@ -122,32 +121,6 @@ namespace esphome this->config_->last_rainbow_time = millis(); } - if ((this->mode == MODE_ICON_SCREEN) || (this->mode == MODE_RAINBOW_ICON)) - { - if (millis() - this->config_->last_scroll_time >= this->config_->scroll_interval && this->pixels_ > TEXTSTARTOFFSET) - { - this->shiftx_++; - if (this->shiftx_ > this->pixels_ + TEXTSTARTOFFSET) - { - this->shiftx_ = 0; - } - this->config_->last_scroll_time = millis(); - } - } - if ((this->mode == MODE_TEXT_SCREEN) || (this->mode == MODE_RAINBOW_TEXT)) - { - if (millis() - this->config_->last_scroll_time >= this->config_->scroll_interval && this->pixels_ >= 32) - { - this->shiftx_++; - if (this->shiftx_ > this->pixels_ + 32) - { - this->shiftx_ = 0; - - } - this->config_->last_scroll_time = millis(); - } - } - if (millis() - this->config_->last_anim_time >= this->config_->icons[this->icon]->frame_duration) { this->config_->icons[this->icon]->next_frame(); @@ -194,7 +167,7 @@ namespace esphome break; case MODE_RAINBOW_DATE: case MODE_DATE: - if (this->config_->clock->now().is_valid()) + if (this->config_->clock->now().is_valid()) { color_ = (this->mode == MODE_RAINBOW_DATE) ? this->config_->rainbow_color : this->config_->clock_color; time_t ts = this->config_->clock->now().timestamp; @@ -230,13 +203,15 @@ namespace esphome } color_ = (this->mode == MODE_RAINBOW_ICON) ? this->config_->rainbow_color : this->text_color; - if (this->config_->rtl) { + if (this->config_->rtl) + { this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, - this->text.c_str()); + this->text.c_str()); } - else { + else + { this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, - this->text.c_str()); + this->text.c_str()); } if (this->config_->display_gauge) { @@ -295,12 +270,11 @@ namespace esphome this->pixels_ = w; this->centerx_ = 0; - this->shiftx_ = 0; switch (this->mode) { case MODE_RAINBOW_TEXT: - case MODE_TEXT_SCREEN: + case MODE_TEXT_SCREEN: if (this->pixels_ < 32) { this->screen_time_ = screen_time; From 67699e952eda9dd77d1e9cd1cf4d5c2f4ca7b358 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 21:31:39 +0200 Subject: [PATCH 09/19] removed shiftx --- TODO.md | 11 +++-- components/ehmtxv2/EHMTX.cpp | 76 ++++++++++++++++-------------- components/ehmtxv2/EHMTX.h | 3 +- components/ehmtxv2/EHMTX_queue.cpp | 28 +++++++---- 4 files changed, 68 insertions(+), 50 deletions(-) diff --git a/TODO.md b/TODO.md index e990520..25e8427 100644 --- a/TODO.md +++ b/TODO.md @@ -2,17 +2,18 @@ ## function +- [ ] screen_time on ms sec base +- [ ] scroll left to right +- [ ] seconds point moveable - [x] alarm on all screens but full screen - [x] indicator on all screens but full screen and clock - [x] refreshing an icon screen should extend the display time -- [ ] scroll left to right - [x] size of indicator and alarm - [x] center text - [x] alarm independent of screen - [x] del_screen with * and filter by type, do delete all clocks etc. - [x] force_screen with * and filter by type, do delete all clocks etc. - [x] gauge with color and del_gaugeall clocks etc. -- [ ] seconds point moveable - [x] seconds point to clock screen only - [x] rainbow icon and text - [x] del_slot still active? @@ -22,16 +23,16 @@ ## user experience - [ ] blueprints -- [x] Color in blueprints -- [ ] all modes in one blueprint - [ ] external HTML with more blueprint helpers (icons and modes) +- [ ] ~~all modes in one blueprint~~ +- [x] Color in blueprints - [x] default values for all functions - [x] provide sample font from [url](https://www.pentacom.jp/pentacom/bitfontmaker2/) - [x] start animation ## style -- [ ] in screen rename text_color to color +- [x] ~~in screen rename text_color to color~~ - [x] default_font before alarm parameter - [x] screen_time instead of showtime - [x] lifetime instead of durations diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 941ad6a..e11d3b2 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -21,6 +21,7 @@ namespace esphome this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE); this->gauge_value = 0; this->next_action_time = 0; + this->last_scroll_time = 0; this->screen_pointer = MAXQUEUE; for (uint8_t i = 0; i < MAXQUEUE; i++) @@ -370,64 +371,67 @@ namespace esphome if (this->is_running) { + if (millis() - this->last_scroll_time >= this->scroll_interval) + { + this->scroll_step++; + this->last_scroll_time = millis(); + if (this->scroll_step > this->queue[this->screen_pointer]->scroll_reset) + { + ESP_LOGD(TAG, "end scroll at: %d",this->scroll_step); + this->scroll_step = 0; + } + } + if (ts > this->next_action_time) { this->remove_expired_queue_element(); this->screen_pointer = this->find_last_clock(); + this->scroll_step = 0; + if (this->screen_pointer == MAXQUEUE) { this->screen_pointer = find_oldest_queue_element(); } - if (millis() - this->last_scroll_time >= this->scroll_interval) - { - this->scroll_step++; - this->last_scroll_time = millis(); - if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 32) + if (this->screen_pointer != MAXQUEUE) + { + this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_; + if (this->queue[this->screen_pointer]->icon < this->icon_count) { - this->scroll_step = 0; + this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0); } - if (this->screen_pointer != MAXQUEUE) + this->next_action_time = this->queue[this->screen_pointer]->last_time; + // Todo switch for Triggers + if (this->queue[this->screen_pointer]->mode == MODE_CLOCK) { - this->scroll_step = 0; - this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_; - if (this->queue[this->screen_pointer]->icon < this->icon_count) + for (auto *t : on_next_clock_triggers_) { - this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0); - } - this->next_action_time = this->queue[this->screen_pointer]->last_time; - // Todo switch for Triggers - if (this->queue[this->screen_pointer]->mode == MODE_CLOCK) - { - for (auto *t : on_next_clock_triggers_) - { - t->process(); - } - } - else - { - for (auto *t : on_next_screen_triggers_) - { - t->process(this->queue[this->screen_pointer]->icon_name, this->queue[this->screen_pointer]->text); - } + t->process(); } } else { - ESP_LOGW(TAG, "tick: nothing to do. Restarting clock display!"); - this->clock_screen(24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); - this->date_screen(24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); - this->next_action_time = ts + this->clock_time; + for (auto *t : on_next_screen_triggers_) + { + t->process(this->queue[this->screen_pointer]->icon_name, this->queue[this->screen_pointer]->text); + } } } + else + { + ESP_LOGW(TAG, "tick: nothing to do. Restarting clock display!"); + this->clock_screen(24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); + this->date_screen(24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); + this->next_action_time = ts + this->clock_time; + } } } else - { - uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32; - this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40)); - this->boot_anim++; - } + { + uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32; + this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40)); + this->boot_anim++; + } } void EHMTX::skip_screen() diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index c475da7..037aa98 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -95,6 +95,7 @@ namespace esphome uint16_t frame_interval; // ms to next_frame() uint16_t clock_interval; uint16_t hold_time; // seconds display of screen_time to extend + uint8_t icon_count; // max iconnumber -1 unsigned long last_scroll_time; unsigned long last_rainbow_time; @@ -141,7 +142,6 @@ namespace esphome void hide_gauge(); void hide_indicator(); void hide_alarm(); - void full_screen(std::string icon, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME); void icon_screen(std::string icon, std::string text, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME,bool default_font=true,int r=C_RED, int g=C_GREEN, int b=C_BLUE); void text_screen(std::string text, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME, bool default_font=true, int r=C_RED, int g=C_GREEN, int b=C_BLUE); @@ -182,6 +182,7 @@ namespace esphome time_t endtime; time_t last_time; uint8_t icon; + uint16_t scroll_reset; Color text_color; show_mode mode; diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index a7124ab..34422c9 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -64,6 +64,7 @@ namespace esphome { uint8_t width = 32; uint8_t startx = 0; + int result = 0; switch (this->mode) { case MODE_RAINBOW_ICON: @@ -86,26 +87,27 @@ namespace esphome { if (this->pixels_ < width) { - return 32 - ceil((width - this->pixels_) / 2); + result = 32 - ceil((width - this->pixels_) / 2); } else { - return startx + this->config_->scroll_step; + result = startx + this->config_->scroll_step; } } else { if (this->pixels_ < width) { - return startx + ceil((width - this->pixels_) / 2); + result = startx + ceil((width - this->pixels_) / 2); } else { - return startx - this->config_->scroll_step + width; + result = startx - this->config_->scroll_step + width; } } + return result; } - + void EHMTX_queue::update_screen() { if (millis() - this->config_->last_rainbow_time >= this->config_->rainbow_interval) @@ -259,6 +261,11 @@ namespace esphome { int x, y, w, h; float display_duration; + + uint8_t width = 32; + uint8_t startx = 0; + uint16_t max_steps = 0; + if (this->default_font) { this->config_->display->get_text_bounds(0, 0, text.c_str(), this->config_->default_font, display::TextAlign::LEFT, &x, &y, &w, &h); @@ -282,12 +289,14 @@ namespace esphome } else { - display_duration = ceil((28 + (this->config_->scroll_count * (32 + this->pixels_)) * this->config_->scroll_interval) / 1000); + max_steps = (this->config_->scroll_count + 1) * (width - startx) + this->config_->scroll_count * this->pixels_; + display_duration = ceil((max_steps * this->config_->scroll_interval) / 1000); this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; } break; case MODE_RAINBOW_ICON: case MODE_ICON_SCREEN: + startx = 8; if (this->pixels_ < 23) { this->screen_time_ = screen_time; @@ -295,7 +304,8 @@ namespace esphome } else { - display_duration = ceil((this->config_->scroll_count * (TEXTSTARTOFFSET + this->pixels_) * this->config_->scroll_interval) / 1000); + max_steps = (this->config_->scroll_count + 1) * (width - startx) + this->config_->scroll_count * this->pixels_; + display_duration = ceil((max_steps * this->config_->scroll_interval) / 1000); this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; } break; @@ -303,6 +313,8 @@ namespace esphome break; } - ESP_LOGD(TAG, "calc_scroll_time: mode: %d text: \"%s\" pixels %d calculated: %d defined: %d", this->mode, text.c_str(), this->pixels_, this->screen_time_, screen_time); + this->scroll_reset = (width - startx) + this->pixels_;; + + ESP_LOGD(TAG, "calc_scroll_time: mode: %d text: \"%s\" pixels %d calculated: %d defined: %d max_steps: %d", this->mode, text.c_str(), this->pixels_, this->screen_time_, screen_time, this->scroll_reset); } } From c853c636ba7b098511ce3091f871ee7cfcc94851 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 21:37:29 +0200 Subject: [PATCH 10/19] rtl for text --- components/ehmtxv2/EHMTX_queue.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 34422c9..646b1e3 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -98,16 +98,16 @@ namespace esphome { if (this->pixels_ < width) { - result = startx + ceil((width - this->pixels_) / 2); + result = startx + ceil((width - this->pixels_) / 2); } else { - result = startx - this->config_->scroll_step + width; + result = startx - this->config_->scroll_step + width; } } return result; } - + void EHMTX_queue::update_screen() { if (millis() - this->config_->last_rainbow_time >= this->config_->rainbow_interval) @@ -239,8 +239,16 @@ namespace esphome extraoffset += 2; } color_ = (this->mode == MODE_RAINBOW_TEXT) ? this->config_->rainbow_color : this->text_color; - this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, - this->text.c_str()); + if (this->config_->rtl) + { + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, + this->text.c_str()); + } + else + { + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + this->text.c_str()); + } break; default: break; @@ -261,7 +269,7 @@ namespace esphome { int x, y, w, h; float display_duration; - + uint8_t width = 32; uint8_t startx = 0; uint16_t max_steps = 0; @@ -313,7 +321,8 @@ namespace esphome break; } - this->scroll_reset = (width - startx) + this->pixels_;; + this->scroll_reset = (width - startx) + this->pixels_; + ; ESP_LOGD(TAG, "calc_scroll_time: mode: %d text: \"%s\" pixels %d calculated: %d defined: %d max_steps: %d", this->mode, text.c_str(), this->pixels_, this->screen_time_, screen_time, this->scroll_reset); } From 7993b24e8db3577748d2a724dc99197980129437 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 16:27:51 +0200 Subject: [PATCH 11/19] nothing works --- components/ehmtxv2/EHMTX.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 37d975e..04d3e37 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -694,14 +694,7 @@ namespace esphome ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b); screen->mode = MODE_CLOCK; screen->default_font = default_font; - if (this->clock_interval == 0 || (this->clock_interval > screen_time)) - { - screen->screen_time_ = screen_time; - } - else - { - screen->screen_time_ = this->clock_interval - 2; - } + screen->screen_time_ = (this->clock_interval > screen_time )?screen_time:this->clock_interval-1; screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } From 04ce55a9e36cd22b82ddc59111196abe3c6c105b Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 21:54:13 +0200 Subject: [PATCH 12/19] cleanup docu --- README.md | 3 +++ tests/ulanzi-easy.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fae1834..4212fbb 100644 --- a/README.md +++ b/README.md @@ -470,6 +470,7 @@ ehmtxv2: brightness: 80 # percent time_format: "%H:%M" date_format: "%d.%m." + rtl: false # write vom left to right week_start_monday: true # false equals sunday scroll_count: 2 # scroll long text at least two times scroll_interval: 80 # milliseconds @@ -497,6 +498,8 @@ ehmtxv2: **special_font_xoffset** (optional, pixel): xoffset the text is aligned BASELINE_LEFT, the left defaults to `1` +**rtl** (optional, boolean): if `true` write from right to left (arabic, hebrew etc.). Default ist `false` + **matrix_component** (required, ID): ID of the addressable display **show_dow** (optional, bool): draw the day of week indicator on the bottom of the clock screen. Disable, e.g. if you want larger fonts, defaults to true. diff --git a/tests/ulanzi-easy.yaml b/tests/ulanzi-easy.yaml index e42d99f..0dc095a 100644 --- a/tests/ulanzi-easy.yaml +++ b/tests/ulanzi-easy.yaml @@ -170,7 +170,7 @@ light: type: GRB internal: true variant: WS2812 - pin: $ledpin + pin: $led_pin num_leds: 256 color_correct: [30%, 30%, 30%] gamma_correct: 2.0 From 662f68919dda2f4ebf7dfd42271cb601a0f31e7e Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 20 May 2023 21:56:47 +0200 Subject: [PATCH 13/19] test typo --- tests/ehtmxv2-template.yaml | 1 + tests/ulanzi-easy.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ehtmxv2-template.yaml b/tests/ehtmxv2-template.yaml index d802ae2..cf577cc 100644 --- a/tests/ehtmxv2-template.yaml +++ b/tests/ehtmxv2-template.yaml @@ -118,6 +118,7 @@ ehmtxv2: date_format: "%d.%m." show_seconds: false clock_interval: 90 + rtl: true default_font_id: default_font special_font_id: default_font icons: diff --git a/tests/ulanzi-easy.yaml b/tests/ulanzi-easy.yaml index 0dc095a..6ab4800 100644 --- a/tests/ulanzi-easy.yaml +++ b/tests/ulanzi-easy.yaml @@ -170,7 +170,7 @@ light: type: GRB internal: true variant: WS2812 - pin: $led_pin + pin: $matrix_pin num_leds: 256 color_correct: [30%, 30%, 30%] gamma_correct: 2.0 From 27f43f8b95d09a8038eded669c0f557e994ce1e1 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 21 May 2023 16:26:09 +0200 Subject: [PATCH 14/19] bitmap_screen --- TODO.md | 1 + components/ehmtxv2/EHMTX.cpp | 14 ++++++++++++-- components/ehmtxv2/EHMTX.h | 1 + components/ehmtxv2/EHMTX_queue.cpp | 2 ++ copy2esphome/ulanzi-easy.yaml | 9 ++++++++- tests/ulanzi-easy.yaml | 11 +++++++++-- 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 25e8427..8bbe503 100644 --- a/TODO.md +++ b/TODO.md @@ -5,6 +5,7 @@ - [ ] screen_time on ms sec base - [ ] scroll left to right - [ ] seconds point moveable +- [ ] dynamic bitmap as json - [x] alarm on all screens but full screen - [x] indicator on all screens but full screen and clock - [x] refreshing an icon screen should extend the display time diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 04d3e37..badffce 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -9,6 +9,7 @@ namespace esphome this->display_indicator = 0; this->display_alarm = 0; this->clock_time = 10; + this->clock_intervall = 90; this->hold_time = 10; this->icon_count = 0; this->hue_ = 0; @@ -28,6 +29,8 @@ namespace esphome { this->queue[i] = new EHMTX_queue(this); } + this->clock_screen(14 * 24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); + this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); } void EHMTX::set_time_format(std::string s) @@ -102,6 +105,14 @@ namespace esphome } } + void EHMTX::get_string(std::string text) + { + ESP_LOGD(TAG, "get_string: %s",text.c_str()); + json::parse_json(text,[](JsonObject root) { + ESP_LOGD(TAG, "string1: %s int1", root["string"],root["int"]); + }); + } + uint8_t EHMTX::find_icon(std::string name) { for (uint8_t i = 0; i < this->icon_count; i++) @@ -377,7 +388,6 @@ namespace esphome this->last_scroll_time = millis(); if (this->scroll_step > this->queue[this->screen_pointer]->scroll_reset) { - ESP_LOGD(TAG, "end scroll at: %d",this->scroll_step); this->scroll_step = 0; } } @@ -694,7 +704,7 @@ namespace esphome ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b); screen->mode = MODE_CLOCK; screen->default_font = default_font; - screen->screen_time_ = (this->clock_interval > screen_time )?screen_time:this->clock_interval-1; + screen->screen_time_ = screen_time; screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 037aa98..19fc05c 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -111,6 +111,7 @@ namespace esphome void hold_screen(int t=30); void set_display(addressable_light::AddressableLightDisplay *disp); void set_clock_interval(uint16_t t=90); + void get_string(std::string); void set_hold_time(uint16_t t=30); void set_clock_time(uint16_t t=10); void set_show_day_of_week(bool b); diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index eeeb90c..318c35c 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -75,6 +75,8 @@ namespace esphome case MODE_RAINBOW_TEXT: // no correction break; + default: + break; } if (this->config_->display_gauge) diff --git a/copy2esphome/ulanzi-easy.yaml b/copy2esphome/ulanzi-easy.yaml index e42d99f..24c1c25 100644 --- a/copy2esphome/ulanzi-easy.yaml +++ b/copy2esphome/ulanzi-easy.yaml @@ -4,6 +4,7 @@ substitutions: board: esp32dev # Pin definition from https://github.com/aptonline/PixelIt_Ulanzi battery_pin: GPIO34 + buzzer_pin: GPIO15 ldr_pin: GPIO35 matrix_pin: GPIO32 left_button_pin: GPIO26 @@ -61,7 +62,13 @@ esphome: on_boot: then: - ds1307.read_time: - + +output: + - platform: gpio + pin: $buzzer_pin + id: quiet_please + + esp32: board: esp32dev diff --git a/tests/ulanzi-easy.yaml b/tests/ulanzi-easy.yaml index 6ab4800..24c1c25 100644 --- a/tests/ulanzi-easy.yaml +++ b/tests/ulanzi-easy.yaml @@ -4,6 +4,7 @@ substitutions: board: esp32dev # Pin definition from https://github.com/aptonline/PixelIt_Ulanzi battery_pin: GPIO34 + buzzer_pin: GPIO15 ldr_pin: GPIO35 matrix_pin: GPIO32 left_button_pin: GPIO26 @@ -61,7 +62,13 @@ esphome: on_boot: then: - ds1307.read_time: - + +output: + - platform: gpio + pin: $buzzer_pin + id: quiet_please + + esp32: board: esp32dev @@ -170,7 +177,7 @@ light: type: GRB internal: true variant: WS2812 - pin: $matrix_pin + pin: $ledpin num_leds: 256 color_correct: [30%, 30%, 30%] gamma_correct: 2.0 From 9d262dc530717e13d23b6a27633693fa84b8c7d6 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 21 May 2023 16:26:24 +0200 Subject: [PATCH 15/19] bitmap screen --- README.md | 16 ++++++++++ components/ehmtxv2/EHMTX.cpp | 51 ++++++++++++++++++++++++------ components/ehmtxv2/EHMTX.h | 4 ++- components/ehmtxv2/EHMTX_queue.cpp | 12 +++++++ 4 files changed, 72 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4212fbb..10d9573 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,22 @@ full_screen => {"icon_name", "lifetime", "screen_time"} void full_screen(string iconname, int =D_LIFETIME, int screen_time=D_SCREEN_TIME); ``` +##### bitmap screen + +For 8x32 images as text. You can generate this images with e.g. [Pixel Bitmap Creator (8x32)](https://pixelit.bastelbunker.de/PixelCreator) + +###### service via API + +```c +bitmap_screen => {"[0,4523,0,2342,0,..... (256 values 16bit values rgb565)]", "lifetime", "screen_time"} +``` + +###### Lambda + +```c +void bitmap_screen(string text, int =D_LIFETIME, int screen_time=D_SCREEN_TIME); +``` + #### Display Elements ![elements](./images/elements.png) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index badffce..eef20d9 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -9,7 +9,7 @@ namespace esphome this->display_indicator = 0; this->display_alarm = 0; this->clock_time = 10; - this->clock_intervall = 90; + this->clock_interval = 90; this->hold_time = 10; this->icon_count = 0; this->hue_ = 0; @@ -29,8 +29,6 @@ namespace esphome { this->queue[i] = new EHMTX_queue(this); } - this->clock_screen(14 * 24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); - this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); } void EHMTX::set_time_format(std::string s) @@ -105,12 +103,38 @@ namespace esphome } } - void EHMTX::get_string(std::string text) + void EHMTX::bitmap_screen(std::string text, int lifetime, int screen_time) { - ESP_LOGD(TAG, "get_string: %s",text.c_str()); - json::parse_json(text,[](JsonObject root) { - ESP_LOGD(TAG, "string1: %s int1", root["string"],root["int"]); - }); + ESP_LOGD(TAG, "bitmap screen: lifetime: %d screen_time: %d", lifetime, screen_time); + const size_t CAPACITY = JSON_ARRAY_SIZE(256); + StaticJsonDocument doc; + deserializeJson(doc, text); + JsonArray array = doc.as(); + // extract the values + uint16_t i = 0; + for (JsonVariant v : array) + { + uint16_t buf = v.as(); + + unsigned char b = (((buf)&0x001F) << 3); + unsigned char g = (((buf)&0x07E0) >> 3); // Fixed: shift >> 5 and << 2 + unsigned char r = (((buf)&0xF800) >> 8); // shift >> 11 and << 3 + Color c = Color(r, g, b); + + this->bitmap[i++] = c; + } + + EHMTX_queue *screen = this->find_free_queue_element(); + + screen->text = ""; + screen->endtime = this->clock->now().timestamp + lifetime * 60; + screen->mode = MODE_BITMAP_SCREEN; + screen->screen_time_ = screen_time; + for (auto *t : on_add_screen_triggers_) + { + t->process("bitmap", (uint8_t)screen->mode); + } + screen->status(); } uint8_t EHMTX::find_icon(std::string name) @@ -198,6 +222,7 @@ namespace esphome register_service(&EHMTX::rainbow_text_screen, "rainbow_text_screen", {"text", "lifetime", "screen_time", "default_font"}); register_service(&EHMTX::clock_screen, "clock_screen", {"lifetime", "screen_time", "default_font", "r", "g", "b"}); + register_service(&EHMTX::bitmap_screen, "bitmap_screen", {"text", "lifetime", "screen_time"}); register_service(&EHMTX::rainbow_clock_screen, "rainbow_clock_screen", {"lifetime", "screen_time", "default_font"}); register_service(&EHMTX::date_screen, "date_screen", {"lifetime", "screen_time", "default_font", "r", "g", "b"}); @@ -244,6 +269,8 @@ namespace esphome if (this->clock->now().is_valid()) { ESP_LOGD(TAG, "time sync => start running"); + this->clock_screen(14 * 24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); + this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); this->is_running = true; } } @@ -329,7 +356,7 @@ namespace esphome this->queue[i]->endtime = 0; if (this->queue[i]->mode != MODE_EMPTY) { - ESP_LOGD(TAG, "remove expired queue element: slot %d: icon_name: %s text: %s", i, this->queue[i]->icon_name.c_str(), this->queue[i]->text.c_str()); + ESP_LOGD(TAG, "remove expired queue element: slot %d: mode: %d icon_name: %s text: %s", i, this->queue[i]->mode, this->queue[i]->icon_name.c_str(), this->queue[i]->text.c_str()); for (auto *t : on_expired_screen_triggers_) { infotext = ""; @@ -704,7 +731,7 @@ namespace esphome ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b); screen->mode = MODE_CLOCK; screen->default_font = default_font; - screen->screen_time_ = screen_time; + screen->screen_time_ = screen_time; screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); } @@ -912,6 +939,10 @@ namespace esphome { ESP_LOGCONFIG(TAG, "weekstart: sunday"); } + if (this->clock->now().is_valid()) + { + this->is_running = true; + } } void EHMTX::add_icon(EHMTX_Icon *icon) diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 19fc05c..598ebc3 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -23,7 +23,7 @@ const uint8_t TEXTSTARTOFFSET = (32 - 8); const uint16_t POLLINGINTERVAL = 1000; static const char *const EHMTX_VERSION = "Version: 2023.5.0 beta"; static const char *const TAG = "EHMTXv2"; -enum show_mode : uint8_t { MODE_EMPTY = 0,MODE_BLANK = 1, MODE_CLOCK = 2, MODE_DATE = 3, MODE_FULL_SCREEN = 4, MODE_ICON_SCREEN = 5, MODE_TEXT_SCREEN = 6 , MODE_RAINBOW_ICON = 7,MODE_RAINBOW_TEXT = 8, MODE_RAINBOW_CLOCK = 9,MODE_RAINBOW_DATE=10 }; +enum show_mode : uint8_t { MODE_EMPTY = 0,MODE_BLANK = 1, MODE_CLOCK = 2, MODE_DATE = 3, MODE_FULL_SCREEN = 4, MODE_ICON_SCREEN = 5, MODE_TEXT_SCREEN = 6 , MODE_RAINBOW_ICON = 7,MODE_RAINBOW_TEXT = 8, MODE_RAINBOW_CLOCK = 9,MODE_RAINBOW_DATE=10,MODE_BITMAP_SCREEN=11 }; namespace esphome { @@ -72,6 +72,7 @@ namespace esphome uint16_t clock_time; uint16_t scroll_step; uint8_t scroll_count; + Color bitmap[256]; void remove_expired_queue_element(); uint8_t find_oldest_queue_element(); uint8_t find_icon_in_queue(std::string); @@ -149,6 +150,7 @@ namespace esphome void clock_screen(int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME,bool default_font=true,int r=C_RED, int g=C_GREEN, int b=C_BLUE); void date_screen(int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME,bool default_font=true, int r=C_RED, int g=C_GREEN, int b=C_BLUE); void blank_screen(int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME); + void bitmap_screen(std::string text,int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME); void rainbow_icon_screen(std::string icon_name, std::string text, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME, bool default_font=true); void rainbow_text_screen(std::string text, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME, bool default_font=true); void rainbow_clock_screen(int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME, bool default_font=true); diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 318c35c..a46935e 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -54,6 +54,9 @@ namespace esphome case MODE_RAINBOW_DATE: ESP_LOGD(TAG, "queue: date for: %d sec", this->screen_time_); break; + case MODE_BITMAP_SCREEN: + ESP_LOGD(TAG, "queue: bitmap for: %d sec", this->screen_time_); + break; default: ESP_LOGD(TAG, "queue: UPPS"); break; @@ -148,6 +151,15 @@ namespace esphome break; case MODE_BLANK: break; + case MODE_BITMAP_SCREEN: + for (uint8_t x = 0; x < 32; x++) + { + for (uint8_t y = 0; y < 8; y++) + { + this->config_->display->draw_pixel_at(x, y, this->config_->bitmap[x + y * 32]); + } + } + break; case MODE_RAINBOW_CLOCK: case MODE_CLOCK: if (this->config_->clock->now().is_valid()) // valid time From c4ada1e60ff20c6e6948a53312d75b4a0f067be6 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 21 May 2023 16:43:12 +0200 Subject: [PATCH 16/19] fixed ulanzi reboot problem --- components/ehmtxv2/EHMTX.cpp | 3 ++- copy2esphome/ulanzi-easy.yaml | 1 + tests/ulanzi-easy.yaml | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index eef20d9..c12d0dd 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -269,13 +269,14 @@ namespace esphome if (this->clock->now().is_valid()) { ESP_LOGD(TAG, "time sync => start running"); + this->bitmap_screen("[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,63519,63519,63519,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,0,0,0,0,2016,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,63488,0,63488,0,0,0,63519,0,0,0,0,2016,2016,0,0,0,65514,0,65514,0,0,0,31,0,0,0,64512,0,0,64512,0,63488,63488,0,63488,63488,0,0,63519,63519,63519,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,31,31,31,0,0,0,64512,64512,0,0,63488,63488,63488,63488,63488,0,0,63519,0,0,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,31,0,0,0,0,64512,64512,0,0,0,63488,63488,63488,0,0,0,63519,63519,63519,63519,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,0,31,31,0,64512,0,0,64512,0,0,0,63488,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]",1,10); this->clock_screen(14 * 24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); this->is_running = true; } } } - + void EHMTX::force_screen(std::string icon_name, int mode) { for (uint8_t i = 0; i < MAXQUEUE; i++) diff --git a/copy2esphome/ulanzi-easy.yaml b/copy2esphome/ulanzi-easy.yaml index 24c1c25..0ef27a1 100644 --- a/copy2esphome/ulanzi-easy.yaml +++ b/copy2esphome/ulanzi-easy.yaml @@ -152,6 +152,7 @@ sensor: if (n > id(aab_max)) n = id(aab_max); if (n < id(aab_min)) n = id(aab_min); int c = id(rgb8x32)->get_brightness(); // current value + c = c>0?c:1 ; int d = (n - c) * 100 / c; // diff in % if ( abs(d) > 2 ) id(rgb8x32)->set_brightness(n); } diff --git a/tests/ulanzi-easy.yaml b/tests/ulanzi-easy.yaml index 24c1c25..e0119ca 100644 --- a/tests/ulanzi-easy.yaml +++ b/tests/ulanzi-easy.yaml @@ -152,6 +152,7 @@ sensor: if (n > id(aab_max)) n = id(aab_max); if (n < id(aab_min)) n = id(aab_min); int c = id(rgb8x32)->get_brightness(); // current value + c = c>0?c:1 ; int d = (n - c) * 100 / c; // diff in % if ( abs(d) > 2 ) id(rgb8x32)->set_brightness(n); } @@ -177,7 +178,7 @@ light: type: GRB internal: true variant: WS2812 - pin: $ledpin + pin: $led_pin num_leds: 256 color_correct: [30%, 30%, 30%] gamma_correct: 2.0 From bf34405f0710ea03ad29f4761b6b6df86b5fb82e Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 21 May 2023 16:51:15 +0200 Subject: [PATCH 17/19] CI/CD --- TODO.md | 3 ++- tests/ulanzi-easy.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 8bbe503..aa5a08a 100644 --- a/TODO.md +++ b/TODO.md @@ -5,7 +5,8 @@ - [ ] screen_time on ms sec base - [ ] scroll left to right - [ ] seconds point moveable -- [ ] dynamic bitmap as json +- [ ] dynamic bitmap as JSON (works partially) +- [ ] fix find_free_icon to work for bitmap screen - [x] alarm on all screens but full screen - [x] indicator on all screens but full screen and clock - [x] refreshing an icon screen should extend the display time diff --git a/tests/ulanzi-easy.yaml b/tests/ulanzi-easy.yaml index e0119ca..9977dc8 100644 --- a/tests/ulanzi-easy.yaml +++ b/tests/ulanzi-easy.yaml @@ -178,7 +178,7 @@ light: type: GRB internal: true variant: WS2812 - pin: $led_pin + pin: $matrix_pin num_leds: 256 color_correct: [30%, 30%, 30%] gamma_correct: 2.0 From 33c9e32b7cf4cfa12a1cdaa365ad20a9f086e740 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 21 May 2023 17:07:27 +0200 Subject: [PATCH 18/19] fixed rtttl --- tests/ulanzi-easy.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/ulanzi-easy.yaml b/tests/ulanzi-easy.yaml index 9977dc8..8732152 100644 --- a/tests/ulanzi-easy.yaml +++ b/tests/ulanzi-easy.yaml @@ -64,10 +64,12 @@ esphome: - ds1307.read_time: output: - - platform: gpio + - platform: ledc pin: $buzzer_pin - id: quiet_please + id: rtttl_out +rtttl: + output: rtttl_out esp32: board: esp32dev @@ -103,6 +105,13 @@ logger: level: WARN api: + services: + - service: tune + variables: + tune: string + then: + - rtttl.play: + rtttl: !lambda 'return tune;' sensor: - platform: sht3xd From 504f7cb4f210ab0fc0af86fe2a7886bd23b5c476 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 21 May 2023 17:08:32 +0200 Subject: [PATCH 19/19] CI/CD --- copy2esphome/ulanzi-easy.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/copy2esphome/ulanzi-easy.yaml b/copy2esphome/ulanzi-easy.yaml index 0ef27a1..8732152 100644 --- a/copy2esphome/ulanzi-easy.yaml +++ b/copy2esphome/ulanzi-easy.yaml @@ -64,10 +64,12 @@ esphome: - ds1307.read_time: output: - - platform: gpio + - platform: ledc pin: $buzzer_pin - id: quiet_please + id: rtttl_out +rtttl: + output: rtttl_out esp32: board: esp32dev @@ -103,6 +105,13 @@ logger: level: WARN api: + services: + - service: tune + variables: + tune: string + then: + - rtttl.play: + rtttl: !lambda 'return tune;' sensor: - platform: sht3xd @@ -178,7 +187,7 @@ light: type: GRB internal: true variant: WS2812 - pin: $ledpin + pin: $matrix_pin num_leds: 256 color_correct: [30%, 30%, 30%] gamma_correct: 2.0