|
|
|
@ -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;
|
|
|
|
@ -25,7 +25,7 @@ namespace esphome
|
|
|
|
this->queue[i] = new EHMTX_queue(this);
|
|
|
|
this->queue[i] = new EHMTX_queue(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this->is_running =false;
|
|
|
|
this->is_running = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::set_time_format(std::string s)
|
|
|
|
void EHMTX::set_time_format(std::string s)
|
|
|
|
@ -177,8 +177,8 @@ namespace esphome
|
|
|
|
register_service(&EHMTX::set_today_color, "today_color", {"r", "g", "b"});
|
|
|
|
register_service(&EHMTX::set_today_color, "today_color", {"r", "g", "b"});
|
|
|
|
register_service(&EHMTX::set_weekday_color, "weekday_color", {"r", "g", "b"});
|
|
|
|
register_service(&EHMTX::set_weekday_color, "weekday_color", {"r", "g", "b"});
|
|
|
|
|
|
|
|
|
|
|
|
register_service(&EHMTX::del_screen, "del_screen", {"icon_name","mode"});
|
|
|
|
register_service(&EHMTX::del_screen, "del_screen", {"icon_name", "mode"});
|
|
|
|
register_service(&EHMTX::force_screen, "force_screen", {"icon_name","mode"});
|
|
|
|
register_service(&EHMTX::force_screen, "force_screen", {"icon_name", "mode"});
|
|
|
|
|
|
|
|
|
|
|
|
register_service(&EHMTX::fullscreen, "fullscreen", {"icon_name", "lifetime", "screen_time"});
|
|
|
|
register_service(&EHMTX::fullscreen, "fullscreen", {"icon_name", "lifetime", "screen_time"});
|
|
|
|
register_service(&EHMTX::icon_screen, "icon_screen", {"icon_name", "text", "lifetime", "screen_time", "default_font", "r", "g", "b"});
|
|
|
|
register_service(&EHMTX::icon_screen, "icon_screen", {"icon_name", "text", "lifetime", "screen_time", "default_font", "r", "g", "b"});
|
|
|
|
@ -186,10 +186,12 @@ 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"});
|
|
|
|
|
|
|
|
|
|
|
|
this->is_running=true;
|
|
|
|
this->is_running = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::show_alarm(int r, int g, int b)
|
|
|
|
void EHMTX::show_alarm(int r, int g, int b)
|
|
|
|
@ -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;
|
|
|
|
{
|
|
|
|
this->display->rectangle(0,1,w,6,Color(120,190,40));
|
|
|
|
uint8_t w = ((uint8_t)(32 / 14) * (this->boot_anim / 14)) % 32;
|
|
|
|
|
|
|
|
this->display->rectangle(0, 2, w, 4, Color(120, 190, 40));
|
|
|
|
this->boot_anim++;
|
|
|
|
this->boot_anim++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -425,12 +431,12 @@ namespace esphome
|
|
|
|
ESP_LOGI(TAG, "queue: %d empty slots", empty);
|
|
|
|
ESP_LOGI(TAG, "queue: %d empty slots", empty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::set_default_font(display::Font * font)
|
|
|
|
void EHMTX::set_default_font(display::Font *font)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->default_font = font;
|
|
|
|
this->default_font = font;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::set_special_font(display::Font * font)
|
|
|
|
void EHMTX::set_special_font(display::Font *font)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->special_font = font;
|
|
|
|
this->special_font = font;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -445,14 +451,14 @@ namespace esphome
|
|
|
|
this->scroll_interval = si;
|
|
|
|
this->scroll_interval = si;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::del_screen(std::string icon_name,int mode)
|
|
|
|
void EHMTX::del_screen(std::string icon_name, int mode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (uint8_t i = 0; i < MAXQUEUE; i++)
|
|
|
|
for (uint8_t i = 0; i < MAXQUEUE; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -463,9 +469,10 @@ 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());
|
|
|
|
@ -714,13 +759,13 @@ namespace esphome
|
|
|
|
this->scroll_count = c;
|
|
|
|
this->scroll_count = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::set_display(addressable_light::AddressableLightDisplay * disp)
|
|
|
|
void EHMTX::set_display(addressable_light::AddressableLightDisplay *disp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->display = disp;
|
|
|
|
this->display = disp;
|
|
|
|
this->show_display = true;
|
|
|
|
this->show_display = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::set_clock(time::RealTimeClock * clock)
|
|
|
|
void EHMTX::set_clock(time::RealTimeClock *clock)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->clock = clock;
|
|
|
|
this->clock = clock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -787,7 +832,7 @@ namespace esphome
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EHMTX::add_icon(EHMTX_Icon * icon)
|
|
|
|
void EHMTX::add_icon(EHMTX_Icon *icon)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->icons[this->icon_count] = icon;
|
|
|
|
this->icons[this->icon_count] = icon;
|
|
|
|
ESP_LOGD(TAG, "add_icon no.: %d name: %s frame_duration: %d ms", this->icon_count, icon->name.c_str(), icon->frame_duration);
|
|
|
|
ESP_LOGD(TAG, "add_icon no.: %d name: %s frame_duration: %d ms", this->icon_count, icon->name.c_str(), icon->frame_duration);
|
|
|
|
@ -825,4 +870,4 @@ namespace esphome
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->trigger();
|
|
|
|
this->trigger();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|