From 66c3eb34a121c591e372ed6cee5536a9b7ec5db1 Mon Sep 17 00:00:00 2001 From: Glenn McIntosh Date: Sun, 31 Jan 2021 17:28:49 +1100 Subject: [PATCH] mqtt monochrome blit to oled --- lib/aiko/oled.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/aiko/oled.py b/lib/aiko/oled.py index cb6dabe..17fd982 100644 --- a/lib/aiko/oled.py +++ b/lib/aiko/oled.py @@ -20,6 +20,7 @@ # (oled:log This is a test !) # (oled:pixel x y) # (oled:pixels x y x y ...) +# (oled:blitm x y width height base64_data) # (oled:text x y This is a test !) # oled.bg=1; oled.fg=0 # @@ -68,6 +69,7 @@ import aiko.common as common import configuration.oled +import binascii oleds = [] width = None @@ -244,6 +246,22 @@ def on_oled_message(topic, payload_in): oleds_show() return True + if payload_in.startswith("(oled:blitm "): + param = payload_in[12:-1].split() + try: + x = int(param[0]) + y = int(param[1]) + w = int(param[2]) + h = int(param[3]) + image = bytearray(binascii.a2b_base64(param[4])) + fbuf = framebuf.FrameBuffer(image, w, h, framebuf.MONO_HLSB) + out = x//width + oleds[out].blit(fbuf, x%width, y) + oleds_show() + except Exception: + print("Error: Expected (oled:blitm x y w h data) where data is a padded base64 mono image") + return True + # (oled:text x y message) if payload_in.startswith("(oled:text "): tokens = payload_in[11:-1].split()