diff web_to_mqtt.py @ 8:47795c3121f1

bufferless updates! mqtt message is sent over SPI and everything works
author drewp@bigasterisk.com
date Mon, 11 Mar 2024 01:37:57 -0700
parents b46679798c51
children affb3c8f3f58
line wrap: on
line diff
--- a/web_to_mqtt.py	Sun Mar 10 15:03:53 2024 -0700
+++ b/web_to_mqtt.py	Mon Mar 11 01:37:57 2024 -0700
@@ -20,7 +20,7 @@
         screenshot_command = [
             "google-chrome",
             "--headless",
-            "--window-size=320,320",
+            "--window-size=320,480",
             f"--screenshot={out.name}",
             url,
         ]
@@ -32,7 +32,7 @@
 
 blockX = 32
 blockY = 32
-msgDelay = .12
+msgDelay = .05
 dirtyQueue = {}
 
 
@@ -55,8 +55,7 @@
     while True:
         if dirtyQueue:
             # pos = random.choice(list(dirtyQueue.keys()))
-            # pos = min(list(dirtyQueue.keys()))
-            pos = random.choice(list(dirtyQueue.keys()))
+            pos = min(list(dirtyQueue.keys()))
             img = dirtyQueue.pop(pos)
             await tell_lcd(client, pos[0], pos[1], img)
         await asyncio.sleep(msgDelay)  # too fast and esp restarts
@@ -82,11 +81,11 @@
     renderer = WebRenderer()
     async with aiomqtt.Client("mqtt2") as client:
         asyncio.create_task(sendDirty(client))
-        last_image = Image.new('RGB', (320, 320))
+        last_image = Image.new('RGB', (320, 480))
         while True:
             last_image = await check_for_changes(renderer, client, last_image)
             # we could get the web page to tell us when any dom changes
-            await asyncio.sleep(5)
+            await asyncio.sleep(1)
 
 
 if __name__ == "__main__":