Make display controlled via uart

This commit is contained in:
Korneliusz Osmenda
2022-09-06 21:33:51 +02:00
parent 47f2379d41
commit 98a526c3cd
5 changed files with 58 additions and 9 deletions

31
scripts/image.py Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env python3
import tlay2_client
import struct
from PIL import Image
def send_image(img):
img = img.convert("1")
w,h = img.size
if w != 200 or h != 128:
raise Exception("bad format")
data = []
for i in range(h//8):
data.append(bytearray([255])*w)
for x in range(w):
for y in range(h):
if img.getpixel((x,y)) == 0:
data[y//8][x] &= ~(1<<(7-y%8))
a=tlay2_client.Tlay2_msg(2)
for i in range(len(data)):
line = data[i]
for j in range(0, len(line), 32):
chunk = line[j:j+32]
a.msg(struct.pack("<H",96+j+i*(296//8)*8)+chunk)
if __name__ == "__main__":
import sys
send_image(Image.open(sys.argv[1]))

BIN
scripts/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB