diff --git a/components/ehmtxv2/EHMTX_icons.cpp b/components/ehmtxv2/EHMTX_icons.cpp index a39ae59..c48102d 100644 --- a/components/ehmtxv2/EHMTX_icons.cpp +++ b/components/ehmtxv2/EHMTX_icons.cpp @@ -10,6 +10,7 @@ namespace esphome this->reverse = revers; this->frame_duration = frame_duration; this->counting_up = true; + this->transparent_=false; } void EHMTX_Icon::next_frame() diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index a3fed0c..9356d05 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -902,6 +902,7 @@ namespace esphome case MODE_RAINBOW_ICON: case MODE_ICON_PROGRESS: case MODE_PROGNOSIS_SCREEN: + this->config_->display->start_clipping(8,0,31,7); 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, @@ -914,6 +915,8 @@ namespace esphome #endif this->config_->draw_text(this->text, font, color_, this->xpos() + xoffset, this->ypos() + yoffset); #endif + this->config_->display->start_clipping(0,0,0,0); + if (this->mode == MODE_ICON_PROGRESS) { if (this->icon != BLANKICON) @@ -1019,6 +1022,7 @@ namespace esphome } } } + break; case MODE_TEXT_PROGRESS: @@ -1049,6 +1053,7 @@ namespace esphome case MODE_ICON_TEXT_SCREEN: case MODE_RAINBOW_ICON_TEXT_SCREEN: + this->config_->display->start_clipping(8,0,31,7); 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, @@ -1061,6 +1066,7 @@ namespace esphome #endif this->config_->draw_text(this->text, font, color_, this->xpos() + xoffset, this->ypos() + yoffset); #endif + this->config_->display->start_clipping(0,0,0,0); if (this->icon != BLANKICON) { int x = 0; diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index 4beb6fb..628ce43 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -25,7 +25,7 @@ MAXICONS = 120 ICONWIDTH = 8 ICONHEIGHT = 8 -ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT * 4 +ICONSIZE = ICONWIDTH * ICONHEIGHT * 2 # SVG_ICONSTART = '' SVG_FULL_SCREEN_START = '' SVG_END = "" @@ -438,6 +438,7 @@ def thumbnails(frames): if hasattr(image, 'n_frames'): frames = min(image.n_frames, MAXFRAMES) + logging.info(f"animation {conf[CONF_ID]} with { frames } frames") else: frames = 1 @@ -457,16 +458,23 @@ def thumbnails(frames): pos = 0 frameIndex = 0 html_string += f"
" - data = [0 for _ in range(ICONBUFFERSIZE * 2 * frames)] + if width == 8: + data = [0 for _ in range(ICONSIZE * frames)] + else: + data = [0 for _ in range(4* ICONSIZE * frames)] + if image.has_transparency_data: + logging.debug(f"icon {conf[CONF_ID]} has transparency!") + for frameIndex in range(frames): image.seek(frameIndex) - frame = image.convert("RGBA") + + frame = image.convert("RGB") + if CONF_RESIZE in conf: frame = frame.resize([width, height]) - + pixels = list(frame.getdata()) - # width, height = image.size if width == 8: @@ -483,17 +491,19 @@ def thumbnails(frames): y = i//width i +=1 rgb = (R << 11) | (G << 5) | B - if pix[3] < 64: - rgb = 0 + html_string += rgb565_svg(x,y,R,G,B) data[pos] = rgb >> 8 pos += 1 data[pos] = rgb & 255 pos += 1 + html_string += SVG_END html_string += f"
" rhs = [HexInt(x) for x in data] + + logging.debug(f"icon {conf[CONF_ID]} {rhs}") prog_arr = cg.progmem_array(conf[CONF_RAW_DATA_ID], rhs) diff --git a/wiki/time-date-replace.md b/wiki/time-date-replace.md index 5987104..4b39e20 100644 --- a/wiki/time-date-replace.md +++ b/wiki/time-date-replace.md @@ -20,7 +20,7 @@ Normal time and date function to get: `4:30PM` and `Oct 11`: An example to get Korean date and time like `4:30오후` and `10월11일`: ```yaml - time_format: "%l:%M%p" + time_format: "%p%l:%M" date_format: "%b%d일" replace_time_date_from: "AM PM Sun Mon Tue Wed Thu Fri Sat Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" replace_time_date_to: "오전 오후 일 월 화 수 목 금 토 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월" @@ -42,4 +42,4 @@ Note there is also a 50 pair limit. Using too many pairs may cause slowdowns. Please note also that input for `time_format` and `date_format` may be limited. Experiment! -### Don't forget to include matching glyphs in your font section! \ No newline at end of file +### Don't forget to include matching glyphs in your font section!