Skip to content

Commit

Permalink
Merge pull request #256 from lubeda/latest
Browse files Browse the repository at this point in the history
Latest
  • Loading branch information
lubeda authored Dec 2, 2024
2 parents 07bbf5c + 79ef9e8 commit 49e06e3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions components/ehmtxv2/EHMTX_icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions components/ehmtxv2/EHMTX_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -1019,6 +1022,7 @@ namespace esphome
}
}
}

break;

case MODE_TEXT_PROGRESS:
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down
24 changes: 17 additions & 7 deletions components/ehmtxv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
MAXICONS = 120
ICONWIDTH = 8
ICONHEIGHT = 8
ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT * 4
ICONSIZE = ICONWIDTH * ICONHEIGHT * 2 #
SVG_ICONSTART = '<svg width="80px" height="80px" viewBox="0 0 80 80">'
SVG_FULL_SCREEN_START = '<svg width="320px" height="80px" viewBox="0 0 320 80">'
SVG_END = "</svg>"
Expand Down Expand Up @@ -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

Expand All @@ -457,16 +458,23 @@ def thumbnails(frames):
pos = 0
frameIndex = 0
html_string += f"<DIV ID={conf[CONF_ID]}>"
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:
Expand All @@ -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"</DIV>"

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)

Expand Down
4 changes: 2 additions & 2 deletions wiki/time-date-replace.md
Original file line number Diff line number Diff line change
Expand Up @@ -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월"
Expand All @@ -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!
### Don't forget to include matching glyphs in your font section!

0 comments on commit 49e06e3

Please sign in to comment.