From 00eadf0ebdb0d9dd0dd5d092de0404d1f374184d Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sun, 29 Oct 2023 14:43:07 +0200 Subject: [PATCH] 2023.9.1: Added check for array existence --- components/ehmtxv2/EHMTX.cpp | 2 +- components/ehmtxv2/EHMTX_queue.cpp | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 5de31bcb..7fb5ba89 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -778,12 +778,12 @@ namespace esphome t->process(this->queue[i]->icon_name, infotext); } } + this->queue[i]->mode = MODE_EMPTY; if (this->queue[i]->sbitmap != NULL) { delete [] this->queue[i]->sbitmap; this->queue[i]->sbitmap = nullptr; } - this->queue[i]->mode = MODE_EMPTY; } } } diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index ee946990..56455a17 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -299,25 +299,28 @@ namespace esphome this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, this->text.c_str()); #endif - if (this->config_->display_gauge) + if (this->sbitmap != NULL) { - this->config_->display->line(10, 0, 10, 7, esphome::display::COLOR_OFF); - for (uint8_t x = 0; x < 8; x++) + if (this->config_->display_gauge) { - for (uint8_t y = 0; y < 8; y++) + this->config_->display->line(10, 0, 10, 7, esphome::display::COLOR_OFF); + for (uint8_t x = 0; x < 8; x++) { - this->config_->display->draw_pixel_at(x + 2, y, this->sbitmap[x + y * 8]); + for (uint8_t y = 0; y < 8; y++) + { + this->config_->display->draw_pixel_at(x + 2, y, this->sbitmap[x + y * 8]); + } } } - } - else - { - this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF); - for (uint8_t x = 0; x < 8; x++) + else { - for (uint8_t y = 0; y < 8; y++) + this->config_->display->line(8, 0, 8, 7, esphome::display::COLOR_OFF); + for (uint8_t x = 0; x < 8; x++) { - this->config_->display->draw_pixel_at(x, y, this->sbitmap[x + y * 8]); + for (uint8_t y = 0; y < 8; y++) + { + this->config_->display->draw_pixel_at(x, y, this->sbitmap[x + y * 8]); + } } } }