|
|
|
|
@ -20,7 +20,7 @@ namespace esphome
|
|
|
|
|
this->alarm_color = Color(CA_RED, CA_GREEN, CA_BLUE);
|
|
|
|
|
this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE);
|
|
|
|
|
this->gauge_value = 0;
|
|
|
|
|
this->screen_pointer = 0;
|
|
|
|
|
this->screen_pointer = MAXQUEUE;
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < MAXQUEUE; i++)
|
|
|
|
|
{
|
|
|
|
|
@ -194,6 +194,7 @@ namespace esphome
|
|
|
|
|
|
|
|
|
|
register_service(&EHMTX::set_brightness, "brightness", {"value"});
|
|
|
|
|
ESP_LOGD(TAG, "Setup and running!");
|
|
|
|
|
this->is_running = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EHMTX::show_alarm(int r, int g, int b, int size)
|
|
|
|
|
@ -228,9 +229,9 @@ namespace esphome
|
|
|
|
|
{
|
|
|
|
|
if (!this->is_running)
|
|
|
|
|
{
|
|
|
|
|
if (this->clock->is_valid())
|
|
|
|
|
if (this->clock->now().is_valid())
|
|
|
|
|
{
|
|
|
|
|
ESP_LOGD(TAG, "time sync => starting");
|
|
|
|
|
ESP_LOGD(TAG, "time sync => start running");
|
|
|
|
|
this->is_running = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -288,9 +289,9 @@ namespace esphome
|
|
|
|
|
time_t ts = this->clock->now().timestamp;
|
|
|
|
|
for (size_t i = 0; i < MAXQUEUE; i++)
|
|
|
|
|
{
|
|
|
|
|
if ((this->queue[i]->mode == MODE_CLOCK)||(this->queue[i]->mode == MODE_RAINBOW_CLOCK))
|
|
|
|
|
if ((this->queue[i]->mode == MODE_CLOCK) || (this->queue[i]->mode == MODE_RAINBOW_CLOCK))
|
|
|
|
|
{
|
|
|
|
|
if (ts > (this->queue[i]->last_time + this->clock_interval))
|
|
|
|
|
if (ts > (this->queue[i]->last_time + this->clock_interval))
|
|
|
|
|
{
|
|
|
|
|
hit = i;
|
|
|
|
|
}
|
|
|
|
|
@ -355,7 +356,7 @@ namespace esphome
|
|
|
|
|
}
|
|
|
|
|
void EHMTX::tick()
|
|
|
|
|
{
|
|
|
|
|
this->hue_++;
|
|
|
|
|
this->hue_++;
|
|
|
|
|
if (this->hue_ == 360)
|
|
|
|
|
{
|
|
|
|
|
this->hue_ = 0;
|
|
|
|
|
@ -363,24 +364,6 @@ namespace esphome
|
|
|
|
|
float red, green, blue;
|
|
|
|
|
esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, red, green, blue);
|
|
|
|
|
this->rainbow_color = Color(uint8_t(255 * red), uint8_t(255 * green), uint8_t(255 * blue));
|
|
|
|
|
|
|
|
|
|
this->scroll_step++;
|
|
|
|
|
|
|
|
|
|
switch (this->queue[this->screen_pointer]->mode)
|
|
|
|
|
{
|
|
|
|
|
case MODE_ICON_SCREEN:
|
|
|
|
|
case MODE_RAINBOW_ICON:
|
|
|
|
|
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8) {
|
|
|
|
|
this->scroll_step = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MODE_RAINBOW_TEXT:
|
|
|
|
|
case MODE_TEXT_SCREEN:
|
|
|
|
|
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31) {
|
|
|
|
|
this->scroll_step = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
time_t ts = this->clock->now().timestamp;
|
|
|
|
|
|
|
|
|
|
@ -388,16 +371,37 @@ namespace esphome
|
|
|
|
|
{
|
|
|
|
|
if (ts > this->next_action_time)
|
|
|
|
|
{
|
|
|
|
|
this->scroll_step++;
|
|
|
|
|
|
|
|
|
|
this->remove_expired_queue_element();
|
|
|
|
|
this->screen_pointer = this->find_last_clock();
|
|
|
|
|
if (this->screen_pointer == MAXQUEUE)
|
|
|
|
|
{
|
|
|
|
|
this->screen_pointer = find_oldest_queue_element();
|
|
|
|
|
}
|
|
|
|
|
switch (this->queue[this->screen_pointer]->mode)
|
|
|
|
|
{
|
|
|
|
|
case MODE_ICON_SCREEN:
|
|
|
|
|
case MODE_RAINBOW_ICON:
|
|
|
|
|
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8)
|
|
|
|
|
{
|
|
|
|
|
this->scroll_step = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MODE_RAINBOW_TEXT:
|
|
|
|
|
case MODE_TEXT_SCREEN:
|
|
|
|
|
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31)
|
|
|
|
|
{
|
|
|
|
|
this->scroll_step = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ESP_LOGD(TAG, "tick action Pointer: %d",this->screen_pointer);
|
|
|
|
|
|
|
|
|
|
if (this->screen_pointer != MAXQUEUE)
|
|
|
|
|
{
|
|
|
|
|
this->queue[this->screen_pointer]->shiftx_ = 0;
|
|
|
|
|
this->scroll_step=0;
|
|
|
|
|
this->scroll_step = 0;
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
@ -431,6 +435,7 @@ namespace esphome
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ESP_LOGD(TAG, "tick rectangle %d", this->is_running);
|
|
|
|
|
uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32;
|
|
|
|
|
this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40));
|
|
|
|
|
this->boot_anim++;
|
|
|
|
|
@ -565,7 +570,7 @@ namespace esphome
|
|
|
|
|
screen->mode = MODE_ICON_SCREEN;
|
|
|
|
|
screen->icon_name = iconname;
|
|
|
|
|
screen->icon = icon;
|
|
|
|
|
screen->calc_scroll_time(text,screen_time);
|
|
|
|
|
screen->calc_scroll_time(text, screen_time);
|
|
|
|
|
for (auto *t : on_add_screen_triggers_)
|
|
|
|
|
{
|
|
|
|
|
t->process(screen->icon_name, (uint8_t)screen->mode);
|
|
|
|
|
@ -588,15 +593,15 @@ namespace esphome
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EHMTX_queue *screen = this->find_icon_queue_element(icon);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screen->text = text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screen->endtime = this->clock->now().timestamp + lifetime * 60;
|
|
|
|
|
screen->default_font = default_font;
|
|
|
|
|
screen->mode = MODE_RAINBOW_ICON;
|
|
|
|
|
screen->icon_name = iconname;
|
|
|
|
|
screen->icon = icon;
|
|
|
|
|
screen->calc_scroll_time(text,screen_time);
|
|
|
|
|
screen->calc_scroll_time(text, screen_time);
|
|
|
|
|
for (auto *t : on_add_screen_triggers_)
|
|
|
|
|
{
|
|
|
|
|
t->process(screen->icon_name, (uint8_t)screen->mode);
|
|
|
|
|
@ -612,7 +617,7 @@ namespace esphome
|
|
|
|
|
ESP_LOGD(TAG, "rainbow_clock_screen lifetime: %d screen_time: %d", lifetime, screen_time);
|
|
|
|
|
screen->mode = MODE_RAINBOW_CLOCK;
|
|
|
|
|
screen->default_font = default_font;
|
|
|
|
|
screen->screen_time_ = (screen_time > this->clock_interval)?screen_time:this->clock_interval-1;
|
|
|
|
|
screen->screen_time_ = (screen_time > this->clock_interval) ? screen_time : this->clock_interval - 1;
|
|
|
|
|
screen->endtime = this->clock->now().timestamp + lifetime * 60;
|
|
|
|
|
screen->status();
|
|
|
|
|
}
|
|
|
|
|
@ -638,7 +643,7 @@ namespace esphome
|
|
|
|
|
screen->default_font = default_font;
|
|
|
|
|
screen->text_color = Color(r, g, b);
|
|
|
|
|
screen->mode = MODE_TEXT_SCREEN;
|
|
|
|
|
screen->calc_scroll_time(text,screen_time);
|
|
|
|
|
screen->calc_scroll_time(text, screen_time);
|
|
|
|
|
screen->status();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -649,7 +654,7 @@ namespace esphome
|
|
|
|
|
screen->endtime = this->clock->now().timestamp + lifetime * 60;
|
|
|
|
|
screen->default_font = default_font;
|
|
|
|
|
screen->mode = MODE_RAINBOW_TEXT;
|
|
|
|
|
screen->calc_scroll_time(text,screen_time);
|
|
|
|
|
screen->calc_scroll_time(text, screen_time);
|
|
|
|
|
screen->status();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -689,7 +694,11 @@ namespace esphome
|
|
|
|
|
ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b);
|
|
|
|
|
screen->mode = MODE_CLOCK;
|
|
|
|
|
screen->default_font = default_font;
|
|
|
|
|
screen->screen_time_ = (this->clock_interval > screen_time )?screen_time:this->clock_interval-1;
|
|
|
|
|
if (this->clock_interval ==0 || (this->clock_interval > screen_time )) {
|
|
|
|
|
screen->screen_time_ = screen_time;
|
|
|
|
|
} else {
|
|
|
|
|
screen->screen_time_ = this->clock_interval-2;
|
|
|
|
|
}
|
|
|
|
|
screen->endtime = this->clock->now().timestamp + lifetime * 60;
|
|
|
|
|
screen->status();
|
|
|
|
|
}
|
|
|
|
|
@ -885,6 +894,10 @@ namespace esphome
|
|
|
|
|
{
|
|
|
|
|
ESP_LOGCONFIG(TAG, "show date");
|
|
|
|
|
}
|
|
|
|
|
if (this->rtl)
|
|
|
|
|
{
|
|
|
|
|
ESP_LOGCONFIG(TAG, "RTL activated");
|
|
|
|
|
}
|
|
|
|
|
if (this->week_starts_monday)
|
|
|
|
|
{
|
|
|
|
|
ESP_LOGCONFIG(TAG, "weekstart: monday");
|
|
|
|
|
@ -893,6 +906,7 @@ namespace esphome
|
|
|
|
|
{
|
|
|
|
|
ESP_LOGCONFIG(TAG, "weekstart: sunday");
|
|
|
|
|
}
|
|
|
|
|
this->is_running = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EHMTX::add_icon(EHMTX_Icon *icon)
|
|
|
|
|
|