|
|
|
@ -14,7 +14,7 @@ namespace esphome
|
|
|
|
this->today_color = Color(C_RED, C_GREEN, C_BLUE);
|
|
|
|
this->today_color = Color(C_RED, C_GREEN, C_BLUE);
|
|
|
|
this->weekday_color = Color(CD_RED, CD_GREEN, CD_BLUE);
|
|
|
|
this->weekday_color = Color(CD_RED, CD_GREEN, CD_BLUE);
|
|
|
|
this->clock_color = Color(C_RED, C_GREEN, C_BLUE);
|
|
|
|
this->clock_color = Color(C_RED, C_GREEN, C_BLUE);
|
|
|
|
|
|
|
|
this->rainbow_color = Color(CA_RED, CA_GREEN, CA_BLUE);
|
|
|
|
this->alarm_color = Color(CA_RED, CA_GREEN, CA_BLUE);
|
|
|
|
this->alarm_color = Color(CA_RED, CA_GREEN, CA_BLUE);
|
|
|
|
this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE);
|
|
|
|
this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE);
|
|
|
|
this->gauge_value = 0;
|
|
|
|
this->gauge_value = 0;
|
|
|
|
@ -186,6 +186,8 @@ namespace esphome
|
|
|
|
register_service(&EHMTX::clock_screen, "clock_screen", {"lifetime", "screen_time", "default_font", "r", "g", "b"});
|
|
|
|
register_service(&EHMTX::clock_screen, "clock_screen", {"lifetime", "screen_time", "default_font", "r", "g", "b"});
|
|
|
|
register_service(&EHMTX::blank_screen, "blank_screen", {"lifetime", "screen_time"});
|
|
|
|
register_service(&EHMTX::blank_screen, "blank_screen", {"lifetime", "screen_time"});
|
|
|
|
register_service(&EHMTX::date_screen, "date_screen", {"lifetime", "screen_time", "default_font", "r", "g", "b"});
|
|
|
|
register_service(&EHMTX::date_screen, "date_screen", {"lifetime", "screen_time", "default_font", "r", "g", "b"});
|
|
|
|
|
|
|
|
register_service(&EHMTX::rainbow_icon_screen, "rainbow_icon_screen", {"icon_name", "text", "lifetime", "screen_time", "default_font"});
|
|
|
|
|
|
|
|
register_service(&EHMTX::rainbow_text_screen, "rainbow_text_screen", {"text", "lifetime", "screen_time", "default_font"});
|
|
|
|
|
|
|
|
|
|
|
|
register_service(&EHMTX::set_brightness, "brightness", {"value"});
|
|
|
|
register_service(&EHMTX::set_brightness, "brightness", {"value"});
|
|
|
|
|
|
|
|
|
|
|
|
@ -230,7 +232,7 @@ namespace esphome
|
|
|
|
if (this->queue[i]->mode == mode)
|
|
|
|
if (this->queue[i]->mode == mode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool force = true;
|
|
|
|
bool force = true;
|
|
|
|
if ((mode == MODE_ICONSCREEN)||(mode == MODE_FULLSCREEN))
|
|
|
|
if ((mode == MODE_ICONSCREEN) || (mode == MODE_FULLSCREEN) || (mode == MODE_RAINBOW_ICON))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (strcmp(this->queue[i]->icon_name.c_str(), icon_name.c_str()) != 0)
|
|
|
|
if (strcmp(this->queue[i]->icon_name.c_str(), icon_name.c_str()) != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -277,7 +279,7 @@ namespace esphome
|
|
|
|
if ((this->queue[i]->endtime > 0) && (this->queue[i]->endtime < ts))
|
|
|
|
if ((this->queue[i]->endtime > 0) && (this->queue[i]->endtime < ts))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->queue[i]->endtime = 0;
|
|
|
|
this->queue[i]->endtime = 0;
|
|
|
|
if ((this->queue[i]->mode == MODE_ICONSCREEN) || (this->queue[i]->mode == MODE_FULLSCREEN))
|
|
|
|
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_)
|
|
|
|
for (auto *t : on_expired_screen_triggers_)
|
|
|
|
@ -299,8 +301,10 @@ namespace esphome
|
|
|
|
infotext = "fullscreen " + this->queue[i]->icon_name;
|
|
|
|
infotext = "fullscreen " + this->queue[i]->icon_name;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case MODE_ICONSCREEN:
|
|
|
|
case MODE_ICONSCREEN:
|
|
|
|
|
|
|
|
case MODE_RAINBOW_ICON:
|
|
|
|
infotext = this->queue[i]->icon_name.c_str();
|
|
|
|
infotext = this->queue[i]->icon_name.c_str();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODE_RAINBOW_TEXT:
|
|
|
|
case MODE_TEXT:
|
|
|
|
case MODE_TEXT:
|
|
|
|
infotext = "TEXT";
|
|
|
|
infotext = "TEXT";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@ -328,7 +332,8 @@ namespace esphome
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->queue[this->screen_pointer]->reset_shiftx();
|
|
|
|
this->queue[this->screen_pointer]->reset_shiftx();
|
|
|
|
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) {
|
|
|
|
if (this->queue[this->screen_pointer]->icon < this->icon_count)
|
|
|
|
|
|
|
|
{
|
|
|
|
this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0);
|
|
|
|
this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->next_action_time = this->queue[this->screen_pointer]->last_time;
|
|
|
|
this->next_action_time = this->queue[this->screen_pointer]->last_time;
|
|
|
|
@ -357,9 +362,10 @@ namespace esphome
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
uint8_t w = ((uint8_t)(32 / 14) * (this->boot_anim / 14)) % 32;
|
|
|
|
uint8_t w = ((uint8_t)(32 / 14) * (this->boot_anim / 14)) % 32;
|
|
|
|
this->display->rectangle(0,1,w,6,Color(120,190,40));
|
|
|
|
this->display->rectangle(0, 2, w, 4, Color(120, 190, 40));
|
|
|
|
this->boot_anim++;
|
|
|
|
this->boot_anim++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -452,7 +458,7 @@ namespace esphome
|
|
|
|
if (this->queue[i]->mode == mode)
|
|
|
|
if (this->queue[i]->mode == mode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool force = true;
|
|
|
|
bool force = true;
|
|
|
|
if ((mode == MODE_ICONSCREEN)||(mode == MODE_FULLSCREEN))
|
|
|
|
if ((mode == MODE_ICONSCREEN) || (mode == MODE_FULLSCREEN) || (mode == MODE_RAINBOW_ICON))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (strcmp(this->queue[i]->icon_name.c_str(), icon_name.c_str()) != 0)
|
|
|
|
if (strcmp(this->queue[i]->icon_name.c_str(), icon_name.c_str()) != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -464,7 +470,8 @@ namespace esphome
|
|
|
|
this->queue[i]->mode = MODE_EMPTY;
|
|
|
|
this->queue[i]->mode = MODE_EMPTY;
|
|
|
|
this->queue[i]->endtime = 0;
|
|
|
|
this->queue[i]->endtime = 0;
|
|
|
|
ESP_LOGW(TAG, "del_screen: icon %s in position: %d mode %d", icon_name.c_str(), i, mode);
|
|
|
|
ESP_LOGW(TAG, "del_screen: icon %s in position: %d mode %d", icon_name.c_str(), i, mode);
|
|
|
|
if (i == this->screen_pointer){
|
|
|
|
if (i == this->screen_pointer)
|
|
|
|
|
|
|
|
{
|
|
|
|
this->next_action_time = this->clock->now().timestamp;
|
|
|
|
this->next_action_time = this->clock->now().timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -501,9 +508,9 @@ namespace esphome
|
|
|
|
screen->status();
|
|
|
|
screen->status();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::timer_screen(std::string icon_name, int seconds, int lifetime, int screen_time, bool default_font, int r, int g, int b)
|
|
|
|
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(icon_name.c_str());
|
|
|
|
uint8_t icon = this->find_icon(iconname.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
if (icon >= this->icon_count)
|
|
|
|
if (icon >= this->icon_count)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -512,15 +519,20 @@ namespace esphome
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EHMTX_queue *screen = this->find_icon_queue_element(icon);
|
|
|
|
EHMTX_queue *screen = this->find_icon_queue_element(icon);
|
|
|
|
|
|
|
|
|
|
|
|
screen->text = "00:00";
|
|
|
|
int x, y, w, h;
|
|
|
|
screen->icon = icon;
|
|
|
|
if (default_font)
|
|
|
|
screen->text_color = Color(r, g, b);
|
|
|
|
{
|
|
|
|
|
|
|
|
this->display->get_text_bounds(0, 0, text.c_str(), this->default_font, display::TextAlign::LEFT, &x, &y, &w, &h);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this->display->get_text_bounds(0, 0, text.c_str(), this->special_font, display::TextAlign::LEFT, &x, &y, &w, &h);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
screen->set_text(text, icon, w, lifetime, screen_time);
|
|
|
|
screen->default_font = default_font;
|
|
|
|
screen->default_font = default_font;
|
|
|
|
screen->mode = MODE_TIMER;
|
|
|
|
screen->mode = MODE_RAINBOW_ICON;
|
|
|
|
screen->icon_name = icon_name;
|
|
|
|
screen->icon_name = iconname;
|
|
|
|
screen->screen_time = screen_time;
|
|
|
|
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->endtime = this->clock->now().timestamp + lifetime * 60;
|
|
|
|
|
|
|
|
ESP_LOGD(TAG, "TIMER_screen icon: %d icon_ name: %s seconds: %d lifetime: %d screen_time: %d", icon, icon_name.c_str(), seconds, lifetime, screen_time);
|
|
|
|
|
|
|
|
screen->status();
|
|
|
|
screen->status();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -558,6 +570,39 @@ namespace esphome
|
|
|
|
screen->status();
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int x, y, w, h;
|
|
|
|
|
|
|
|
if (default_font)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this->display->get_text_bounds(0, 0, text.c_str(), this->default_font, display::TextAlign::LEFT, &x, &y, &w, &h);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this->display->get_text_bounds(0, 0, text.c_str(), this->special_font, display::TextAlign::LEFT, &x, &y, &w, &h);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screen->text = text;
|
|
|
|
|
|
|
|
screen->pixels_ = w;
|
|
|
|
|
|
|
|
if (screen->pixels_ < 32)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
screen->centerx_ = ceil((32 - screen->pixels_) / 2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screen->shiftx_ = 0;
|
|
|
|
|
|
|
|
float display_duration = ceil((this->scroll_count * w * this->scroll_interval) / 1000);
|
|
|
|
|
|
|
|
screen->screen_time = (display_duration > screen_time) ? display_duration : screen_time;
|
|
|
|
|
|
|
|
ESP_LOGD(TAG, "text_screen text: text: %s pixels %d screen_time: %d lifetime: %d", text.c_str(), w, screen->screen_time, lifetime);
|
|
|
|
|
|
|
|
screen->endtime = this->clock->now().timestamp + lifetime * 60;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screen->default_font = default_font;
|
|
|
|
|
|
|
|
screen->mode = MODE_RAINBOW_TEXT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screen->status();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::fullscreen(std::string iconname, int lifetime, int screen_time)
|
|
|
|
void EHMTX::fullscreen(std::string iconname, int lifetime, int screen_time)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t icon = this->find_icon(iconname.c_str());
|
|
|
|
uint8_t icon = this->find_icon(iconname.c_str());
|
|
|
|
|