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

Latest #256

Merged
merged 7 commits into from
Dec 2, 2024
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
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 @@ -885,6 +885,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 @@ -898,6 +899,8 @@ 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->start_clipping(0,0,0,0);

if (this->mode == MODE_ICON_PROGRESS)
{
if (this->icon != BLANKICON)
Expand Down Expand Up @@ -1003,6 +1006,7 @@ namespace esphome
}
}
}

break;

case MODE_TEXT_PROGRESS:
Expand Down Expand Up @@ -1033,6 +1037,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 @@ -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
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 @@ -427,6 +427,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 @@ -446,16 +447,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 @@ -472,17 +480,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!
Loading