LuBeDa 3 years ago
parent e3dc03a795
commit db9917d15c

@ -574,6 +574,18 @@ Numerous features are accessible with services from home assistant and lambdas y
|`date_screen`|"lifetime", "screen_time", "default_font", "r", "g", "b"|show the date|
|`brightness`|"value"|set the display brightness|
#### Parameter description
"r", "g", "b": Color components for red, green and blue 0..255
"size": The size of the indicator or alarm, 1-3
"percent": values from 0..100
"icon_name": the id of the icon to show, as defined in the YAML file
"text": a text message to display
"lifetime": how long does this screen stay in the queue (minutes)
"screen_time": how long is this screen display in the loop (seconds). For short text without scrolling it is shown the defined time, longer text is scrolled at least `scroll_count` times.
"default_font": use the default font (true) or the special font (false)
"value": the brightness 0..255
### Local lambdas
#### Add screen to your display queue

@ -504,20 +504,35 @@ namespace esphome
}
EHMTX_queue *screen = this->find_icon_queue_element(icon);
int x, y, w, h;
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, &w, &h);
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, &w, &h);
this->display->get_text_bounds(0, 0, text.c_str(), this->special_font, display::TextAlign::LEFT, &x, &y, &pixel, &h);
}
screen->set_text(text, icon, w, lifetime, screen_time);
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;
for (auto *t : on_add_screen_triggers_)
{
t->process(screen->icon_name,(uint8_t)screen->mode);
@ -526,6 +541,59 @@ namespace esphome
screen->status();
}
void EHMTX::rainbow_icon_screen(std::string iconname, std::string text, int lifetime, int screen_time, bool default_font)
{
uint8_t icon = this->find_icon(iconname.c_str());
if (icon >= this->icon_count)
{
ESP_LOGW(TAG, "icon %d not found => default: 0", icon);
icon = 0;
for (auto *t : on_icon_error_triggers_)
{
t->process(iconname);
}
}
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;
for (auto *t : on_add_screen_triggers_)
{
t->process(screen->icon_name,(uint8_t)screen->mode);
}
ESP_LOGD(TAG, "rainbow 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();
}
void EHMTX::rainbow_clock_screen(int lifetime, int screen_time, bool default_font)
{
EHMTX_queue *screen = this->find_free_queue_element();
@ -550,38 +618,6 @@ namespace esphome
screen->status();
}
void EHMTX::rainbow_icon_screen(std::string iconname, std::string text, int lifetime, int screen_time, bool default_font)
{
uint8_t icon = this->find_icon(iconname.c_str());
if (icon >= this->icon_count)
{
ESP_LOGW(TAG, "icon %d not found => default: 0", icon);
icon = 0;
for (auto *t : on_icon_error_triggers_)
{
t->process(iconname);
}
}
EHMTX_queue *screen = this->find_icon_queue_element(icon);
screen->icon_name = iconname;
screen->icon = icon;
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_ICON;
screen->calc_scroll_time();
for (auto *t : on_add_screen_triggers_)
{
t->process(screen->icon_name,(uint8_t)screen->mode);
}
ESP_LOGD(TAG, "rainbow_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();
}
void EHMTX::text_screen(std::string text, int lifetime, int screen_time, bool default_font, int r, int g, int b)
{
EHMTX_queue *screen = this->find_free_queue_element();

@ -238,7 +238,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", text.c_str(), pixel, this->screen_time, screen_time);
ESP_LOGD(TAG, "display text: %s pixels %d display_duration %d calculated: %d screen_time: %d", text.c_str(), pixel,display_duration, this->screen_time, screen_time);
this->endtime = this->config_->clock->now().timestamp + et * 60;
this->icon = icon;
}

Loading…
Cancel
Save