|
|
|
|
@ -20,7 +20,9 @@ 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->next_action_time = 0;
|
|
|
|
|
this->last_scroll_time = 0;
|
|
|
|
|
this->screen_pointer = MAXQUEUE;
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < MAXQUEUE; i++)
|
|
|
|
|
{
|
|
|
|
|
@ -228,9 +230,9 @@ namespace esphome
|
|
|
|
|
{
|
|
|
|
|
if (!this->is_running)
|
|
|
|
|
{
|
|
|
|
|
if (this->clock->now().timestamp > 15)
|
|
|
|
|
if (this->clock->now().is_valid())
|
|
|
|
|
{
|
|
|
|
|
ESP_LOGD(TAG, "time sync => starting");
|
|
|
|
|
ESP_LOGD(TAG, "time sync => start running");
|
|
|
|
|
this->is_running = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -238,12 +240,6 @@ namespace esphome
|
|
|
|
|
|
|
|
|
|
void EHMTX::force_screen(std::string icon_name, int mode)
|
|
|
|
|
{
|
|
|
|
|
// if (this->string_has_ending(icon_name, "*"))
|
|
|
|
|
// {
|
|
|
|
|
// // remove the *
|
|
|
|
|
// icon_name = icon_name.substr(0, icon_name.length() - 1);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < MAXQUEUE; i++)
|
|
|
|
|
{
|
|
|
|
|
if (this->queue[i]->mode == mode)
|
|
|
|
|
@ -359,6 +355,7 @@ namespace esphome
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EHMTX::tick()
|
|
|
|
|
{
|
|
|
|
|
this->hue_++;
|
|
|
|
|
@ -370,30 +367,35 @@ namespace esphome
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
if (millis() - this->last_scroll_time >= this->scroll_interval){
|
|
|
|
|
time_t ts = this->clock->now().timestamp;
|
|
|
|
|
|
|
|
|
|
if (this->is_running)
|
|
|
|
|
{
|
|
|
|
|
if (millis() - this->last_scroll_time >= this->scroll_interval)
|
|
|
|
|
{
|
|
|
|
|
this->scroll_step++;
|
|
|
|
|
this->last_scroll_time = millis();
|
|
|
|
|
|
|
|
|
|
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 32) {
|
|
|
|
|
if (this->scroll_step > this->queue[this->screen_pointer]->scroll_reset)
|
|
|
|
|
{
|
|
|
|
|
ESP_LOGD(TAG, "end scroll at: %d",this->scroll_step);
|
|
|
|
|
this->scroll_step = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
time_t ts = this->clock->now().timestamp;
|
|
|
|
|
|
|
|
|
|
if (this->is_running)
|
|
|
|
|
{
|
|
|
|
|
if (ts > this->next_action_time)
|
|
|
|
|
{
|
|
|
|
|
this->remove_expired_queue_element();
|
|
|
|
|
this->screen_pointer = this->find_last_clock();
|
|
|
|
|
this->scroll_step = 0;
|
|
|
|
|
|
|
|
|
|
if (this->screen_pointer == MAXQUEUE)
|
|
|
|
|
{
|
|
|
|
|
this->screen_pointer = find_oldest_queue_element();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this->screen_pointer != MAXQUEUE)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
@ -608,7 +610,14 @@ 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;
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
@ -685,7 +694,14 @@ 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();
|
|
|
|
|
}
|
|
|
|
|
@ -881,6 +897,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");
|
|
|
|
|
|