Skip to content

Commit

Permalink
2023.9.1-117: Add a pseudo-icon - blank
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjswan committed Oct 23, 2023
1 parent 24657e6 commit 421a8ba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- `icon_screen_progress(iconname, text, progress, lifetime, screen_time, default_font, r, g, b)`
- Added `replace_time_date_to:` and `replace_time_date_from:` which allow replacing the system date & time text (anything!)
- Added `bitmap_small` and `rainbow_bitmap_small` screen.
- Added a pseudo-icon `blank` - empty icon, no display.

### EspHoMaTriX 2023.9.0
- Added the ability to display graph as defined in the YAML file
Expand Down
28 changes: 14 additions & 14 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,9 @@ namespace esphome
{
uint8_t icon = this->find_icon(iconname.c_str());

if (icon >= this->icon_count)
if (icon == MAXICONS)
{
ESP_LOGW(TAG, "icon %d not found => default: 0", icon);
ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, iconname.c_str());
icon = 0;
for (auto *t : on_icon_error_triggers_)
{
Expand Down Expand Up @@ -1054,9 +1054,9 @@ namespace esphome

uint8_t icon = this->find_icon(ic.c_str());

if (icon >= this->icon_count)
if (icon == MAXICONS)
{
ESP_LOGW(TAG, "icon %d not found => default: 0", icon);
ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str());
icon = 0;
for (auto *t : on_icon_error_triggers_)
{
Expand Down Expand Up @@ -1088,9 +1088,9 @@ namespace esphome

uint8_t icon = this->find_icon(ic.c_str());

if (icon >= this->icon_count)
if (icon == MAXICONS)
{
ESP_LOGW(TAG, "icon %d not found => default: 0", icon);
ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str());
icon = 0;
for (auto *t : on_icon_error_triggers_)
{
Expand Down Expand Up @@ -1134,9 +1134,9 @@ namespace esphome

uint8_t icon = this->find_icon(ic.c_str());

if (icon >= this->icon_count)
if (icon == MAXICONS)
{
ESP_LOGW(TAG, "icon %d not found => default: 0", icon);
ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str());
icon = 0;
for (auto *t : on_icon_error_triggers_)
{
Expand Down Expand Up @@ -1167,9 +1167,9 @@ namespace esphome

uint8_t icon = this->find_icon(ic.c_str());

if (icon >= this->icon_count)
if (icon == MAXICONS)
{
ESP_LOGW(TAG, "icon %d not found => default: 0", icon);
ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str());
icon = 0;
for (auto *t : on_icon_error_triggers_)
{
Expand Down Expand Up @@ -1200,9 +1200,9 @@ namespace esphome

uint8_t icon = this->find_icon(ic.c_str());

if (icon >= this->icon_count)
if (icon == MAXICONS)
{
ESP_LOGW(TAG, "icon %d not found => default: 0", icon);
ESP_LOGW(TAG, "icon %d/%s not found => default: 0", icon, ic.c_str());
icon = 0;
for (auto *t : on_icon_error_triggers_)
{
Expand Down Expand Up @@ -1328,7 +1328,7 @@ namespace esphome
{
uint8_t icon = this->find_icon(iconname.c_str());

if (icon >= this->icon_count)
if (icon == MAXICONS)
{
ESP_LOGW(TAG, "full screen: icon %d not found => default: 0", icon);
for (auto *t : on_icon_error_triggers_)
Expand Down Expand Up @@ -1508,7 +1508,7 @@ namespace esphome
{
uint8_t icon = this->find_icon(iconname.c_str());

if (icon >= this->icon_count)
if (icon == MAXICONS)
{
ESP_LOGW(TAG, "graph screen with icon: icon %d not found => default: 0", icon);
for (auto *t : on_icon_error_triggers_)
Expand Down
6 changes: 3 additions & 3 deletions components/ehmtxv2/EHMTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const uint8_t C_BLACK = 0;
const uint8_t D_LIFETIME = 5;
const uint8_t D_SCREEN_TIME = 10;

const uint8_t BLANKICON = -1;
const uint8_t MAXICONS = 90; // Max 127 icon due int8_t
const uint8_t MAXICONS = 90;
const uint8_t BLANKICON = MAXICONS + 1;
const uint8_t TEXTSCROLLSTART = 8;
const uint8_t TEXTSTARTOFFSET = (32 - 8);

Expand Down Expand Up @@ -261,7 +261,7 @@ namespace esphome
bool default_font;
time_t endtime;
time_t last_time;
int8_t icon;
uint8_t icon;
uint16_t scroll_reset;
show_mode mode;
int8_t progress;
Expand Down
19 changes: 11 additions & 8 deletions components/ehmtxv2/EHMTX_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,13 @@ namespace esphome
this->config_->last_rainbow_time = millis();
}

if (millis() - this->config_->last_anim_time >= this->config_->icons[this->icon]->frame_duration)
if (this->icon < this->config_->icon_count)
{
this->config_->icons[this->icon]->next_frame();
this->config_->last_anim_time = millis();
if (millis() - this->config_->last_anim_time >= this->config_->icons[this->icon]->frame_duration)
{
this->config_->icons[this->icon]->next_frame();
this->config_->last_anim_time = millis();
}
}
}

Expand Down Expand Up @@ -283,7 +286,7 @@ namespace esphome
else
{
this->config_->display->graph(8, 0, this->config_->graph);
if (this->icon > BLANKICON)
if (this->icon != BLANKICON)
{
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
}
Expand Down Expand Up @@ -421,7 +424,7 @@ namespace esphome
this->config_->clock->now());
}
}
if (this->icon > BLANKICON)
if (this->icon != BLANKICON)
{
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
}
Expand Down Expand Up @@ -554,7 +557,7 @@ namespace esphome
if (this->mode == MODE_ICON_PROGRESS)
{
this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF);
if (this->icon > BLANKICON)
if (this->icon != BLANKICON)
{
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
}
Expand All @@ -577,7 +580,7 @@ namespace esphome
{
if (this->config_->display_gauge)
{
if (this->icon > BLANKICON)
if (this->icon != BLANKICON)
{
this->config_->display->image(2, 0, this->config_->icons[this->icon]);
}
Expand All @@ -586,7 +589,7 @@ namespace esphome
else
{
this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF);
if (this->icon > BLANKICON)
if (this->icon != BLANKICON)
{
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
}
Expand Down

0 comments on commit 421a8ba

Please sign in to comment.