Skip to content

Commit

Permalink
2024.1.0: Advanced clock - draw date
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjswan authored Jan 8, 2024
1 parent 2839b69 commit ff4a5c0
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions components/ehmtxv2/EHMTX_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,19 +592,28 @@ namespace esphome
{
color_ = (this->mode == MODE_RAINBOW_DATE) ? this->config_->rainbow_color : this->text_color;
time_t ts = this->config_->clock->now().timestamp;
if (this->config_->replace_time_date_active) // check for replace active
{
std::string time_new = this->config_->clock->now().strftime(EHMTXv2_DATE_FORMAT).c_str();
time_new = this->config_->replace_time_date(time_new);
this->config_->display->printf(xoffset + 15, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str());
} else {
this->config_->display->strftime(xoffset + 15, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_DATE_FORMAT,
this->config_->clock->now());
}
if ((this->config_->clock->now().second % 2 == 0) && this->config_->show_seconds)
#ifdef EHMTXv2_ADV_CLOCK
if (!this->config_->draw_date(EHMTXv2_DATE_FORMAT, font, color_, xoffset + 15, this->ypos() + yoffset))
{
this->config_->display->draw_pixel_at(0, 0, color_);
#endif
if (this->config_->replace_time_date_active) // check for replace active
{
std::string time_new = this->config_->clock->now().strftime(EHMTXv2_DATE_FORMAT).c_str();
time_new = this->config_->replace_time_date(time_new);
this->config_->display->printf(xoffset + 15, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str());
}
else
{
this->config_->display->strftime(xoffset + 15, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_DATE_FORMAT,
this->config_->clock->now());
}
if ((this->config_->clock->now().second % 2 == 0) && this->config_->show_seconds)
{
this->config_->display->draw_pixel_at(0, 0, color_);
}
#ifdef EHMTXv2_ADV_CLOCK
}
#endif
if (this->mode != MODE_RAINBOW_DATE)
{
this->config_->draw_day_of_week(this->ypos());
Expand Down Expand Up @@ -651,17 +660,24 @@ namespace esphome
}
else
{
if (this->config_->replace_time_date_active) // check for replace active
{
std::string time_new = this->config_->clock->now().strftime(EHMTXv2_DATE_FORMAT).c_str();
time_new = this->config_->replace_time_date(time_new);
this->config_->display->printf(xoffset + offset, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str());
}
else
#ifdef EHMTXv2_ADV_CLOCK
if (!this->config_->draw_date(EHMTXv2_DATE_FORMAT, font, color_, xoffset + offset, this->ypos() + yoffset))
{
this->config_->display->strftime(xoffset + offset, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_DATE_FORMAT,
this->config_->clock->now());
#endif
if (this->config_->replace_time_date_active) // check for replace active
{
std::string time_new = this->config_->clock->now().strftime(EHMTXv2_DATE_FORMAT).c_str();
time_new = this->config_->replace_time_date(time_new);
this->config_->display->printf(xoffset + offset, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, "%s", time_new.c_str());
}
else
{
this->config_->display->strftime(xoffset + offset, this->ypos() + yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_DATE_FORMAT,
this->config_->clock->now());
}
#ifdef EHMTXv2_ADV_CLOCK
}
#endif
}
if (this->icon != BLANKICON)
{
Expand Down

0 comments on commit ff4a5c0

Please sign in to comment.