Skip to content

Commit

Permalink
2023.9.1: Ability to change the direction of the progress color gradient
Browse files Browse the repository at this point in the history
Progress in MODE_ICON_PROGRESS screen:
- 0 .. -100 - from Green to Red
- 0 .. 100 - from Red to Green
  • Loading branch information
andrewjswan committed Oct 5, 2023
1 parent a5d6114 commit d612744
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ namespace esphome
screen->mode = MODE_ICON_PROGRESS;
screen->icon_name = id;
screen->icon = icon;
screen->progress = (progress > 100) ? 100 : progress;
screen->progress = (progress > 100) ? 100 : (progress < -100) ? -100 : progress;
screen->calc_scroll_time(text, screen_time);
for (auto *t : on_add_screen_triggers_)
{
Expand Down
12 changes: 6 additions & 6 deletions components/ehmtxv2/EHMTX_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,13 @@ namespace esphome
#endif
if (this->mode == MODE_ICON_PROGRESS)
{
if (this->progress >= 0)
{
this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF);
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF);
this->config_->display->image(0, 0, this->config_->icons[this->icon]);

color_ = esphome::light::ESPHSVColor(this->progress * 120 / 100, 240, 240).to_rgb();
this->config_->display->line(9, 7, 9 + this->progress * 22 / 100, 7, color_);
if (this->progress != 0)
{
color_ = esphome::light::ESPHSVColor(this->progress * 120 / 100 + (this->progress < 0 ? 120 : 0), 240, 240).to_rgb();
this->config_->display->line(9, 7, 9 + abs(this->progress) * 22 / 100, 7, color_);
}
}
else
Expand Down

0 comments on commit d612744

Please sign in to comment.