diff --git a/TODO.md b/TODO.md index 7a11b2a..791aefd 100644 --- a/TODO.md +++ b/TODO.md @@ -15,6 +15,7 @@ - [ ] seconds point moveable - [ ] seconds point to clock screen only - [x] rainbow icon and text +- [ ] del_slot noch active? ## ux diff --git a/components/ehmtx/EHMTX.cpp b/components/ehmtx/EHMTX.cpp index de7eea6..5bb2de8 100644 --- a/components/ehmtx/EHMTX.cpp +++ b/components/ehmtx/EHMTX.cpp @@ -42,13 +42,13 @@ namespace esphome { this->indicator_color = Color((uint8_t)r & 248, (uint8_t)g & 252, (uint8_t)b & 248); this->display_indicator = s; - ESP_LOGD(TAG, "show_indicator (%d)r: %d g: %d b: %d", s, r, g, b ); + ESP_LOGD(TAG, "show indicator size:%d r: %d g: %d b: %d", s, r, g, b ); } void EHMTX::hide_indicator() { this->display_indicator = 0; - ESP_LOGD(TAG, "hide_indicator"); + ESP_LOGD(TAG, "hide indicator"); } void EHMTX::set_display_off() @@ -113,11 +113,11 @@ namespace esphome { if (strcmp(this->queue[i]->icon_name.c_str(), name.c_str()) == 0) { - ESP_LOGD(TAG, "find_icon_in_queue: icon: %s at position %d", name.c_str(), i); + ESP_LOGD(TAG, "find icon in queue: icon: %s at position %d", name.c_str(), i); return i; } } - ESP_LOGW(TAG, "find_icon_in_queue: icon: %s not found", name.c_str()); + ESP_LOGW(TAG, "find icon in queue: icon: %s not found", name.c_str()); return MAXICONS; } @@ -197,7 +197,7 @@ namespace esphome void EHMTX::hide_alarm() { this->display_alarm = 0; - ESP_LOGD(TAG, "hide_alarm"); + ESP_LOGD(TAG, "hide alarm"); } void EHMTX::blank_screen(int lifetime, int showtime) @@ -257,7 +257,6 @@ namespace esphome } if (hit != MAXQUEUE) { - // ESP_LOGD(TAG, "find_oldest_queue_element: oldest screen is: %d", hit); this->queue[hit]->status(); } return hit; @@ -274,7 +273,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: removed 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 = ""; @@ -391,7 +390,6 @@ namespace esphome ESP_LOGI(TAG, "status brightness: %d (0..255)", this->brightness_); ESP_LOGI(TAG, "status date format: %s", this->date_fmt.c_str()); ESP_LOGI(TAG, "status time format: %s", this->time_fmt.c_str()); - ESP_LOGI(TAG, "status text_color: RGB(%d,%d,%d)", this->text_color.r, this->text_color.g, this->text_color.b); ESP_LOGI(TAG, "status alarm_color: RGB(%d,%d,%d)", this->alarm_color.r, this->alarm_color.g, this->alarm_color.b); if (this->show_display) { @@ -498,7 +496,7 @@ namespace esphome screen->default_font = default_font; screen->mode = MODE_ICONSCREEN; screen->icon_name = iconname; - ESP_LOGD(TAG, "icon_screen icon: %d iconname: %s text: %s lifetime: %d screen_time: %d", icon, iconname.c_str(), text.c_str(), lifetime, screen_time); + ESP_LOGD(TAG, "icon screen icon: %d iconname: %s text: %s lifetime: %d screen_time: %d", icon, iconname.c_str(), text.c_str(), lifetime, screen_time); screen->status(); } @@ -809,7 +807,7 @@ namespace esphome ESP_LOGCONFIG(TAG, "Date format: %s", this->date_fmt.c_str()); ESP_LOGCONFIG(TAG, "Time format: %s", this->time_fmt.c_str()); ESP_LOGCONFIG(TAG, "Interval (ms) scroll: %d frame: %d", this->scroll_interval, this->frame_interval); - ESP_LOGCONFIG(TAG, "Displaytime (s) clock: %d screen: %d", this->clock_time, this->screen_time); + ESP_LOGCONFIG(TAG, "Displaytime (s) clock: %d", this->clock_time); if (this->show_day_of_week) { ESP_LOGCONFIG(TAG, "show day of week"); @@ -835,13 +833,23 @@ namespace esphome this->icon_count++; } - void EHMTX::draw() - { - if ((this->is_running) && (this->show_display) && (this->screen_pointer != MAXQUEUE)) - { - this->queue[this->screen_pointer]->draw(); - this->draw_gauge(); +void EHMTX::draw_alarm(){ + if (this->display_alarm>2) + { + this->display->line(31, 2, 29, 0, this->alarm_color); + } + if (this->display_alarm>1) + { + this->display->draw_pixel_at(30, 0, this->alarm_color); + this->display->draw_pixel_at(31, 1, this->alarm_color); + } + if (this->display_alarm>0) + { + this->display->draw_pixel_at(31, 0, this->alarm_color); + } +} +void EHMTX::draw_indicator(){ if (this->display_indicator>2) { this->display->line(31, 5, 29, 7, this->indicator_color); @@ -856,7 +864,20 @@ namespace esphome { this->display->draw_pixel_at(31, 7, this->indicator_color); } - +} + + + void EHMTX::draw() + { + if ((this->is_running) && (this->show_display) && (this->screen_pointer != MAXQUEUE)) + { + this->queue[this->screen_pointer]->draw(); + this->draw_gauge(); + if (this->queue[this->screen_pointer]->mode != MODE_CLOCK && this->queue[this->screen_pointer]->mode != MODE_DATE && this->queue[this->screen_pointer]->mode != MODE_FULLSCREEN) { + this->draw_indicator(); + } + // this->draw_indicator(); + this->draw_alarm(); } } diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index 7f122df..e9c1bcc 100644 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -95,7 +95,6 @@ namespace esphome void draw_day_of_week(); void show_all_icons(); void tick(); - void Ntick(); void draw(); void get_status(); void queue_status(); @@ -146,6 +145,8 @@ namespace esphome void del_screen(std::string icon, int mode=MODE_ICONSCREEN); void draw_gauge(); + void draw_alarm(); + void draw_indicator(); void add_on_next_screen_trigger(EHMTXNextScreenTrigger *t) { this->on_next_screen_triggers_.push_back(t); } void add_on_expired_screen_trigger(EHMTXExpiredScreenTrigger *t) { this->on_expired_screen_triggers_.push_back(t); } diff --git a/components/ehmtx/EHMTX_queue.cpp b/components/ehmtx/EHMTX_queue.cpp index 48e6164..06adb93 100644 --- a/components/ehmtx/EHMTX_queue.cpp +++ b/components/ehmtx/EHMTX_queue.cpp @@ -25,28 +25,28 @@ namespace esphome ESP_LOGD(TAG, "queue: empty slot"); break; case MODE_BLANK: - ESP_LOGD(TAG, "queue: show blank screen"); + ESP_LOGD(TAG, "queue: blank screen"); break; case MODE_CLOCK: - ESP_LOGD(TAG, "queue: show 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: show date for %d sec", this->screen_time); + ESP_LOGD(TAG, "queue: date for %d sec", this->screen_time); break; case MODE_FULLSCREEN: - ESP_LOGD(TAG, "queue: show fullscreen: %s for %d sec", this->icon_name.c_str(), this->screen_time); + ESP_LOGD(TAG, "queue: fullscreen: %s for %d sec", this->icon_name.c_str(), this->screen_time); break; case MODE_ICONSCREEN: - ESP_LOGD(TAG, "queue: show 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: - ESP_LOGD(TAG, "queue: show 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: show 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: show 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; default: ESP_LOGD(TAG, "queue: UPPS"); @@ -185,23 +185,17 @@ namespace esphome 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_alarm>2) - { - this->config_->display->line(31, 2, 29, 0, this->config_->alarm_color); - } - if (this->config_->display_alarm>1) - { - this->config_->display->draw_pixel_at(30, 0, this->config_->alarm_color); - this->config_->display->draw_pixel_at(31, 1, this->config_->alarm_color); - } - if (this->config_->display_alarm>0) - { - this->config_->display->draw_pixel_at(31, 0, this->config_->alarm_color); - } + // this->config_->draw_alarm(); + + // if (this->mode != MODE_CLOCK && this->mode != MODE_DATE && this->mode != MODE_FULLSCREEN) { + // this->config_->draw_indicator(); + // } + + if (this->config_->display_gauge) { - this->config_->draw_gauge(); + // this->config_->draw_gauge(); this->config_->display->image(2, 0, this->config_->icons[this->icon]); this->config_->display->line(10, 0, 10, 7, esphome::display::COLOR_OFF); } @@ -252,7 +246,7 @@ namespace esphome this->shiftx_ = 0; float display_duration = ceil((this->config_->scroll_count * (TEXTSTARTOFFSET + pixel) * this->config_->scroll_interval) / 1000); this->screen_time = (display_duration > screen_time) ? display_duration : screen_time; - ESP_LOGD(TAG, "display text: %s pixels %d calculated: %d screen_time: %d default: %d", text.c_str(), pixel, this->screen_time, screen_time, this->config_->screen_time); + ESP_LOGD(TAG, "display text: %s pixels %d calculated: %d screen_time: %d", text.c_str(), pixel, this->screen_time, screen_time); this->endtime = this->config_->clock->now().timestamp + et * 60; this->icon = icon; } diff --git a/components/ehmtx/__init__.py b/components/ehmtx/__init__.py index ae269fc..9abae22 100644 --- a/components/ehmtx/__init__.py +++ b/components/ehmtx/__init__.py @@ -51,7 +51,6 @@ NextClockTrigger = ehmtx_ns.class_( ) CONF_CLOCKTIME = "clock_time" -CONF_SCREENTIME = "screen_time" CONF_EHMTX = "ehmtx" CONF_URL = "url" CONF_FLAG = "flag" @@ -145,9 +144,6 @@ EHMTX_SCHEMA = cv.Schema({ cv.Optional( CONF_FRAMEINTERVAL, default="192" ): cv.templatable(cv.positive_int), - cv.Optional( - CONF_SCREENTIME, default="8" - ): cv.templatable(cv.positive_int), cv.Optional(CONF_BRIGHTNESS, default=80): cv.templatable(cv.int_range(min=0, max=255)), cv.Optional(CONF_ON_NEXT_SCREEN): automation.validate_automation( { @@ -387,7 +383,6 @@ async def to_code(config): cg.add(var.set_clock_time(config[CONF_CLOCKTIME])) cg.add(var.set_brightness(config[CONF_BRIGHTNESS])) - cg.add(var.set_screen_time(config[CONF_SCREENTIME])) cg.add(var.set_scroll_interval(config[CONF_SCROLLINTERVAL])) cg.add(var.set_rainbow_interval(config[CONF_SCROLLINTERVAL])) cg.add(var.set_scroll_count(config[CONF_SCROLLCOUNT]))