diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 30f1501..9d4fc52 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -638,6 +638,7 @@ namespace esphome if (strcmp(this->icons[i]->name.c_str(), name.c_str()) == 0) { ESP_LOGD(TAG, "icon: %s found id: %d", name.c_str(), i); + ESP_LOGD(TAG, "icon: %s has transparency: %d", this->icons[i]->); return i; } } diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index f7f747c..d7ecd54 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -885,6 +885,9 @@ namespace esphome case MODE_RAINBOW_ICON: case MODE_ICON_PROGRESS: case MODE_PROGNOSIS_SCREEN: + this->config_->display->start_clipping(8,0,31,7); + if (this->config_->display->is_clipping()) + color_ = (this->mode == MODE_RAINBOW_ICON || this->mode == MODE_RAINBOW_ALERT_SCREEN) ? this->config_->rainbow_color : this->text_color; #ifdef EHMTXv2_USE_RTL this->config_->display->print(this->xpos() + xoffset, this->ypos() + yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, @@ -898,6 +901,7 @@ namespace esphome this->config_->display->print(this->xpos() + xoffset, this->ypos() + yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, this->text.c_str()); #endif + this->config_->display->end_clipping(); if (this->mode == MODE_ICON_PROGRESS) { if (this->icon != BLANKICON) @@ -1033,6 +1037,7 @@ namespace esphome case MODE_ICON_TEXT_SCREEN: case MODE_RAINBOW_ICON_TEXT_SCREEN: + color_ = (this->mode == MODE_RAINBOW_ICON_TEXT_SCREEN) ? this->config_->rainbow_color : this->text_color; #ifdef EHMTXv2_USE_RTL this->config_->display->print(this->xpos() + xoffset, this->ypos() + yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT, @@ -1046,6 +1051,7 @@ namespace esphome this->config_->display->print(this->xpos() + xoffset, this->ypos() + yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, this->text.c_str()); #endif + if (this->icon != BLANKICON) { int x = 0; diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index bdb561e..ecc6f0a 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -20,12 +20,11 @@ DEPENDENCIES = ["display", "light", "api"] AUTO_LOAD = ["ehmtxv2","json"] -IMAGE_TYPE_RGB565 = 4 MAXFRAMES = 110 MAXICONS = 120 ICONWIDTH = 8 ICONHEIGHT = 8 -ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT * 4 +ICONBUFFERBYTES = ICONWIDTH * ICONHEIGHT * 3 SVG_ICONSTART = '' SVG_FULL_SCREEN_START = '' SVG_END = "" @@ -420,6 +419,9 @@ def thumbnails(frames): width, height = image.size + if image.has_transparency_data: + logging.info(f" ICONS: {conf[CONF_ID]} has transparancy") + if CONF_RESIZE in conf: new_width_max, new_height_max = conf[CONF_RESIZE] ratio = min(new_width_max / width, new_height_max / height) @@ -446,23 +448,23 @@ def thumbnails(frames): pos = 0 frameIndex = 0 html_string += f"
" - data = [0 for _ in range(ICONBUFFERSIZE * 2 * frames)] + data = [0 for _ in range(ICONBUFFERBYTES * frames)] for frameIndex in range(frames): image.seek(frameIndex) frame = image.convert("RGBA") + if CONF_RESIZE in conf: frame = frame.resize([width, height]) pixels = list(frame.getdata()) - - # width, height = image.size if width == 8: html_string += SVG_ICONSTART else: html_string += SVG_FULL_SCREEN_START i = 0 + for pix in pixels: R = pix[0] >> 3 G = pix[1] >> 2 @@ -479,12 +481,12 @@ def thumbnails(frames): pos += 1 data[pos] = rgb & 255 pos += 1 + html_string += SVG_END html_string += f"
" - rhs = [HexInt(x) for x in data] - - prog_arr = cg.progmem_array(conf[CONF_RAW_DATA_ID], rhs) + + prog_arr = cg.progmem_array(conf[CONF_RAW_DATA_ID], data) cg.new_Pvariable( conf[CONF_ID], @@ -492,12 +494,11 @@ def thumbnails(frames): width, height, frames, - espImage.IMAGE_TYPE["RGB565"], + espImage.IMAGE_TYPE["RGB565icvon"], str(conf[CONF_ID]), conf[CONF_PINGPONG], duration, - ) - + ) cg.add(var.add_icon(RawExpression(str(conf[CONF_ID])))) html_string += ""