aboutsummaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/matelight/config.py22
-rw-r--r--host/matelight/host.py21
-rwxr-xr-xhost/matelight/nyancat-test.py29
-rw-r--r--host/nyancat.pngbin0 -> 483 bytes
-rw-r--r--host/nyancat.xcfbin0 -> 1658 bytes
-rw-r--r--host/nyancat2.pngbin0 -> 477 bytes
-rw-r--r--host/nyancat2.xcfbin0 -> 1655 bytes
-rw-r--r--host/scroller.pngbin0 -> 1557 bytes
8 files changed, 54 insertions, 18 deletions
diff --git a/host/matelight/config.py b/host/matelight/config.py
index 2177292..2bc97c1 100644
--- a/host/matelight/config.py
+++ b/host/matelight/config.py
@@ -9,23 +9,27 @@ DEFAULT_SCROLL_SPEED = 4
# Pixels to leave blank between two letters
LETTER_SPACING = 1
-FONT = bdflib.reader.read_bdf(open('fonts/5x8.bdf').readlines())
-FONT_WIDTH = 5
+#FONT = bdflib.reader.read_bdf(open('fonts/5x8.bdf').readlines())
+#FONT_WIDTH = 5
# Computed value
-FONT_PADDED_BINARY = ('{:0'+str(FONT_WIDTH+'b}').format
+#FONT_PADDED_BINARY = ('{:0'+str(FONT_WIDTH+'b}').format
# Display geometry
# ┌─────────┐ ┌───┬───┬ ⋯ ┬───┬───┐
-# │1 o o o 5│ │ 1 │ │ │ │16 │
+# │1 o o o 5│ │ 1 │ │ │ │ 8│
# │6 o o o o│ ├───┼───┼ ⋯ ┼───┼───┤
-# │o o o o o│ │17 │ │ │ │32 │
-# │o o o o20│ └───┴───┴ ⋯ ┴───┴───┘
-# └─────────┘
+# │o o o o o│ │ 9 │ │ │ │16 │
+# │o o o o20│ ├───┼───┼ ⋯ ┼───┼───┤
+# └─────────┘ │17 │ │ │ │24 │
+# ├───┼───┼ ⋯ ┼───┼───┤
+# │25 │ │ │ │32 │
+# └───┴───┴ ⋯ ┴───┴───┘
+
CRATE_WIDTH = 5
CRATE_HEIGHT = 4
-CRATES_X = 16
-CRATES_Y = 2
+CRATES_X = 8
+CRATES_Y = 4
# Computed values
DISPLAY_WIDTH = CRATES_X * CRATE_WIDTH
diff --git a/host/matelight/host.py b/host/matelight/host.py
index 461a4fa..394c299 100644
--- a/host/matelight/host.py
+++ b/host/matelight/host.py
@@ -1,16 +1,19 @@
-from pyusb import usb
+import usb
import colorsys
import numpy as np
+from config import *
+import itertools
dev = usb.core.find(idVendor=0x1cbe, idProduct=0x0003)
def sendframe(framedata):
- if not isinstance(framedata, np.array) or framedata.shape != (DISPLAY_WIDTH, DISPLAY_HEIGHT, 3) or framedata.dtype != np.int8:
- raise ValueError('framedata must be a ({}, {}, 3)-numpy array of int8s'.format(DISPLAY_WIDTH, DISPLAY_HEIGHT))
+ # not isinstance(framedata, np.array) or
+ if framedata.shape != (DISPLAY_HEIGHT, DISPLAY_WIDTH, 3) or framedata.dtype != np.uint8:
+ raise ValueError('framedata must be a ({}, {}, 3)-numpy array of int8s. Got a {}-numpy array of {}'.format(DISPLAY_WIDTH, DISPLAY_HEIGHT, framedata.shape, framedata.dtype))
- for cx, cy in itertools.product(range(16), range(2)):
- cratedata = framedata[cx*CRATE_WIDTH:(cx+1)*CRATE_WIDTH, cy*CRATE_HEIGHT:(cy+1)*CRATE_HEIGHT]
- # Send framebuffer data
- dev.write(0x01, bytes([0, x, y])+bytes(list(cratedata.flatten())))
- # Send latch command
- dev.write(0x01, b'\x01')
+ for cy, cx in itertools.product(range(CRATES_Y), range(CRATES_X)):
+ cratedata = framedata[cy*CRATE_HEIGHT:(cy+1)*CRATE_HEIGHT, cx*CRATE_WIDTH:(cx+1)*CRATE_WIDTH]
+ # Send framebuffer data
+ dev.write(0x01, bytes([0, cx, cy])+bytes(list(cratedata.flatten())))
+ # Send latch command
+ dev.write(0x01, b'\x01')
diff --git a/host/matelight/nyancat-test.py b/host/matelight/nyancat-test.py
new file mode 100755
index 0000000..aaabe85
--- /dev/null
+++ b/host/matelight/nyancat-test.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+import host
+import numpy as np
+from config import *
+from PIL import Image, ImageSequence
+import time
+
+img1 = Image.open(open('../nyancat.png', 'rb'))
+img2 = Image.open(open('../nyancat2.png', 'rb'))
+scroller = Image.open(open('../scroller.png', 'rb'))
+datas = []
+for img in [img1, img2]:
+ im = img.convert("RGB")
+ im.thumbnail((DISPLAY_WIDTH, DISPLAY_HEIGHT), Image.NEAREST)
+ data = np.array(im.getdata(), dtype=np.uint8)
+ datas += [data.reshape((DISPLAY_HEIGHT, DISPLAY_WIDTH, 3))]
+
+im = scroller.convert("RGB")
+bar = np.array(im.getdata(), dtype=np.uint8)
+foo = bar.reshape((DISPLAY_HEIGHT, 300, 3))
+
+while True:
+ for i in range(20):
+ for data in datas:
+ host.sendframe(data)
+ time.sleep(0.1)
+ for i in range(260):
+ host.sendframe(foo[:, i:i+40, :])
+
diff --git a/host/nyancat.png b/host/nyancat.png
new file mode 100644
index 0000000..1e0bf80
--- /dev/null
+++ b/host/nyancat.png
Binary files differ
diff --git a/host/nyancat.xcf b/host/nyancat.xcf
new file mode 100644
index 0000000..af439e2
--- /dev/null
+++ b/host/nyancat.xcf
Binary files differ
diff --git a/host/nyancat2.png b/host/nyancat2.png
new file mode 100644
index 0000000..7e4cbd4
--- /dev/null
+++ b/host/nyancat2.png
Binary files differ
diff --git a/host/nyancat2.xcf b/host/nyancat2.xcf
new file mode 100644
index 0000000..e340edd
--- /dev/null
+++ b/host/nyancat2.xcf
Binary files differ
diff --git a/host/scroller.png b/host/scroller.png
new file mode 100644
index 0000000..2257626
--- /dev/null
+++ b/host/scroller.png
Binary files differ