Skip to content
Closed
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
20 changes: 20 additions & 0 deletions lib/aiko/oled.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# (oled:log This is a test !)
# (oled:pixel x y)
# (oled:text x y This is a test !)
# (oled:blit0 {base64 bits} {base64 bits} ...)
# (oled:blit1 {base64 bits} {base64 bits} ...)
# oled.bg=1; oled.fg=0
#
# Topic: /in (oled:traits)
Expand Down Expand Up @@ -63,6 +65,7 @@
import gc
from machine import Pin
import machine, ssd1306
import binascii

import aiko.common as common

Expand Down Expand Up @@ -234,6 +237,23 @@ def on_oled_message(topic, payload_in):
oleds_show()
return True

if (payload_in.startswith("(oled:blit0 ") or
payload_in.startswith("(oled:blit1 ")):
blit = payload_in[12:-1].split()
out = ord(payload_in[10])-0x30
row = 128//8
image = bytearray(row*len(blit)+2)
padding = "AAAA"
line = 0
for blitline in blit:
bin = binascii.a2b_base64(blitline+padding[(len(blitline)-1)%4+1:])
image[line:len(bin)] = bin
line += row
fbuf = framebuf.FrameBuffer(image, 128, len(blit), framebuf.MONO_HLSB)
oleds[out].blit(fbuf, 0, 0)
oleds_show()
return True

# (oled:text x y message)
if payload_in.startswith("(oled:text "):
tokens = payload_in[11:-1].split()
Expand Down