diff --git a/README.md b/README.md index 74c36753..317919b1 100644 --- a/README.md +++ b/README.md @@ -757,7 +757,8 @@ Numerous features are accessible with services from home assistant and lambdas t |`icon_screen_progress`|"icon_name", "text", "progress", "lifetime", "screen_time", "default_font", "r", "g", "b"|show the specified icon with text and with progress bar on bottom| |`icon_clock`|"icon_name", "lifetime", "screen_time", "default_font", "r", "g", "b"|show the specified icon with time, there is support for [displaying text on top of the icon](#icon_text)| |`icon_date`|"icon_name", "lifetime", "screen_time", "default_font", "r", "g", "b"|show the specified icon with date, there is support for [displaying text on top of the icon](#icon_text)| -|`graph_screen`|lifetime", "screen_time"|show graph as defined in the YAML file| +|`graph_screen`|"lifetime", "screen_time"|show graph as defined in the YAML file| +|`icon_graph_screen`|"icon_name", "lifetime", "screen_time"|show the specified icon with graph as defined in the YAML file| |`set_infotext_color`|"left_r", "left_g", "left_b", "right_r", "right_g", "right_b","default_font","y_offset"|set the special color for left and right char on info text| #### Parameter description diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index fbfc411d..24b9ec33 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -410,6 +410,7 @@ namespace esphome register_service(&EHMTX::icon_date, "icon_date", {"icon_name", "lifetime", "screen_time", "default_font", "r", "g", "b"}); #ifdef USE_GRAPH register_service(&EHMTX::graph_screen, "graph_screen", {"lifetime", "screen_time"}); + register_service(&EHMTX::icon_graph_screen, "icon_graph_screen", {"icon_name", "lifetime", "screen_time"}); #endif register_service(&EHMTX::rainbow_icon_screen, "rainbow_icon_screen", {"icon_name", "text", "lifetime", "screen_time", "default_font"}); @@ -1391,11 +1392,50 @@ namespace esphome screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->mode = MODE_GRAPH_SCREEN; + screen->icon = MAXICONS; screen->screen_time_ = screen_time; + + this->graph->set_height(8); + this->graph->set_width(32); + + for (auto *t : on_add_screen_triggers_) + { + t->process("graph", (uint8_t)screen->mode); + } + screen->status(); + } + + void EHMTX::icon_graph_screen(std::string iconname, int lifetime, int screen_time) + { + uint8_t icon = this->find_icon(iconname.c_str()); + + if (icon >= this->icon_count) + { + ESP_LOGW(TAG, "graph screen with icon: icon %d not found => default: 0", icon); + for (auto *t : on_icon_error_triggers_) + { + t->process(iconname); + } + graph_screen(lifetime, screen_time); + return; + } + + EHMTX_queue *screen = this->find_mode_queue_element(MODE_GRAPH_SCREEN); + + screen->endtime = this->clock->now().timestamp + lifetime * 60; + screen->mode = MODE_GRAPH_SCREEN; + screen->icon = icon; + screen->icon_name = iconname; + screen->screen_time_ = screen_time; + + this->graph->set_height(8); + this->graph->set_width(24); + for (auto *t : on_add_screen_triggers_) { t->process("graph", (uint8_t)screen->mode); } + ESP_LOGD(TAG, "graph screen with icon: icon: %d iconname: %s lifetime: %d screen_time:%d ", icon, iconname.c_str(), lifetime, screen_time); screen->status(); } diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 31428b09..30e16858 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -128,7 +128,8 @@ namespace esphome addressable_light::AddressableLightDisplay *display; esphome::time::RealTimeClock *clock; #ifdef USE_GRAPH - void graph_screen(int lifetime = 2 , int screen_time = 20); + void graph_screen(int lifetime = D_LIFETIME, int screen_time = D_SCREEN_TIME); + void icon_graph_screen(std::string icon, int lifetime = D_LIFETIME, int screen_time = D_SCREEN_TIME); graph::Graph *graph; #endif diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 658847a2..04f21f87 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -270,7 +270,15 @@ namespace esphome #ifdef USE_GRAPH case MODE_GRAPH_SCREEN: - this->config_->display->graph(0,0, this->config_->graph); + if (this->icon == MAXICONS) + { + this->config_->display->graph(0, 0, this->config_->graph); + } + else + { + this->config_->display->graph(8, 0, this->config_->graph); + this->config_->display->image(0, 0, this->config_->icons[this->icon]); + } break; #endif