Skip to content
Open
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
18 changes: 18 additions & 0 deletions lib/aiko/oled.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -68,6 +69,7 @@
import aiko.common as common

import configuration.oled
import binascii

oleds = []
width = None
Expand Down Expand Up @@ -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()
Expand Down