Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023.9.1-117: Add a pseudo icon - blank #118

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 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 Expand Up @@ -770,7 +771,7 @@ Numerous features are accessible with services from home assistant and lambdas t
- **r, g, b**: Color components for red, green, and blue 0..255
- **size**: The size of the rindicator or alarm, 1-3
- **percent**: values from 0..100
- **icon_name**: the id of the icon to show, as defined in the YAML file, it is also possible to set the arbitrary [screen identifier](#screen_id), for example `icon_name|screen_id`
- **icon_name**: the id of the icon to show, as defined in the YAML file (or pseudo-icon `blank` - empty icon), it is also possible to set the arbitrary [screen identifier](#screen_id), for example `icon_name|screen_id`
- **text**: a text message to display
- **lifetime**: how long does this screen stay in the queue (minutes)
- **screen_time**: how long is this screen display in the loop (seconds). For short text without scrolling it is shown the defined time, longer text is scrolled at least `scroll_count` times.
Expand Down
33 changes: 19 additions & 14 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ namespace esphome

uint8_t EHMTX::find_icon(std::string name)
{
if (name == "blank")
{
return BLANKICON;
}

for (uint8_t i = 0; i < this->icon_count; i++)
{
if (strcmp(this->icons[i]->name.c_str(), name.c_str()) == 0)
Expand Down Expand Up @@ -1011,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 @@ -1049,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 @@ -1083,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 @@ -1129,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 @@ -1162,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 @@ -1195,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 @@ -1323,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 @@ -1503,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
1 change: 1 addition & 0 deletions components/ehmtxv2/EHMTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const uint8_t D_LIFETIME = 5;
const uint8_t D_SCREEN_TIME = 10;

const uint8_t MAXICONS = 90;
const uint8_t BLANKICON = MAXICONS + 1;
const uint8_t TEXTSCROLLSTART = 8;
const uint8_t TEXTSTARTOFFSET = (32 - 8);

Expand Down
34 changes: 26 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,10 @@ namespace esphome
else
{
this->config_->display->graph(8, 0, this->config_->graph);
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
if (this->icon != BLANKICON)
{
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
}
}
break;
#endif
Expand Down Expand Up @@ -418,7 +424,10 @@ namespace esphome
this->config_->clock->now());
}
}
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
if (this->icon != BLANKICON)
{
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
}
this->config_->draw_day_of_week(true);

if (this->icon_name.find("day") != std::string::npos || this->icon_name.find("weekday") != std::string::npos)
Expand Down Expand Up @@ -548,7 +557,10 @@ namespace esphome
if (this->mode == MODE_ICON_PROGRESS)
{
this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF);
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
if (this->icon != BLANKICON)
{
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
}

if (this->progress != 0)
{
Expand All @@ -568,13 +580,19 @@ namespace esphome
{
if (this->config_->display_gauge)
{
this->config_->display->image(2, 0, this->config_->icons[this->icon]);
if (this->icon != BLANKICON)
{
this->config_->display->image(2, 0, this->config_->icons[this->icon]);
}
this->config_->display->line(10, 0, 10, 7, esphome::display::COLOR_OFF);
}
else
{
this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF);
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
if (this->icon != BLANKICON)
{
this->config_->display->image(0, 0, this->config_->icons[this->icon]);
}
}
}
break;
Expand Down
Loading