Mercurial > code > home > repos > front-door-display
changeset 6:e36abecb48a1
experimenting with block size & delay
author | drewp@bigasterisk.com |
---|---|
date | Fri, 08 Mar 2024 09:17:05 -0800 |
parents | d97a5930db7e |
children | b46679798c51 |
files | src/scheduleLcd.html web_to_mqtt.py |
diffstat | 2 files changed, 9 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/scheduleLcd.html Wed Mar 06 16:38:58 2024 -0800 +++ b/src/scheduleLcd.html Fri Mar 08 09:17:05 2024 -0800 @@ -28,7 +28,7 @@ </div> <div class="closeup-cal area" - style="left: 2px; top: 50px; width: 300px; height: 80px" + style="left: 2px; top: 60px; width: 300px; height: 80px" > <div><span id="time">.....</span> 😼 🐶 ⤵ 6 minutes left</div> <div>youtube | minecraft
--- a/web_to_mqtt.py Wed Mar 06 16:38:58 2024 -0800 +++ b/web_to_mqtt.py Fri Mar 08 09:17:05 2024 -0800 @@ -30,8 +30,9 @@ return Image.open(out.name).convert('RGB') -block = 320 // 10 - +blockX = 16 +blockY = 64 +msgDelay = .12 dirtyQueue = {} @@ -39,9 +40,9 @@ current_image = await renderer.capture_screenshot( "http://localhost:8002/front-door-display/scheduleLcd.html") diff_image = ImageChops.difference(last_image, current_image) - for y in range(0, current_image.height, block): - for x in range(0, current_image.width, block): - box = (x, y, x + block, y + block) + for y in range(0, current_image.height, blockY): + for x in range(0, current_image.width, blockX): + box = (x, y, x + blockX, y + blockY) region = diff_image.crop(box) if region.getbbox(): dirtyQueue[(x, y)] = current_image.crop(box) @@ -57,14 +58,14 @@ pos = min(list(dirtyQueue.keys())) img = dirtyQueue.pop(pos) await tell_lcd(client, pos[0], pos[1], img) - await asyncio.sleep(.15) + await asyncio.sleep(msgDelay) # too fast and esp restarts framesSent = itertools.count() async def tell_lcd(client: aiomqtt.Client, x: int, y: int, region: Image.Image): - seq = next(framesSent) + seq = next(framesSent) % 65535 msg = struct.pack('HHHHH', seq, x, y, region.width, region.height) + region.tobytes() print(f'send {seq=} {x=} {y=} {region.width=} {region.height=} ', end='\r', flush=True) await client.publish('display/squib/updates', msg, qos=0)