From 79ef9e83a53b2e389e27ea2ad338f0b66aee307e Mon Sep 17 00:00:00 2001 From: lubeda Date: Mon, 2 Dec 2024 16:09:59 +0100 Subject: [PATCH] ICONSIZE and debuggung --- components/ehmtxv2/__init__.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index 846d8d4..debaa38 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -25,7 +25,7 @@ MAXICONS = 120 ICONWIDTH = 8 ICONHEIGHT = 8 -ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT * 2 +ICONSIZE = ICONWIDTH * ICONHEIGHT * 2 # SVG_ICONSTART = '' SVG_FULL_SCREEN_START = '' SVG_END = "" @@ -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 @@ -446,20 +447,23 @@ def thumbnails(frames): pos = 0 frameIndex = 0 html_string += f"
" - data = [0 for _ in range(ICONBUFFERSIZE * 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.warning(f" icon {conf[CONF_ID]} has transparency!") + logging.debug(f"icon {conf[CONF_ID]} has transparency!") for frameIndex in range(frames): image.seek(frameIndex) + 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: @@ -482,10 +486,13 @@ 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] + + logging.debug(f"icon {conf[CONF_ID]} {rhs}") prog_arr = cg.progmem_array(conf[CONF_RAW_DATA_ID], rhs)