aboutsummaryrefslogtreecommitdiff
path: root/host/matelight/host.py
diff options
context:
space:
mode:
authorjaseg <jaseg@jaseg.net>2013-12-27 03:02:26 +0100
committerjaseg <jaseg@jaseg.net>2013-12-27 03:02:26 +0100
commita95e0305aeaffadf071e963863c102b30b76993a (patch)
treec499d709443fbef32c3b03c8ecaee5e23d3ce2a9 /host/matelight/host.py
parentf2731bac95ebcd91a2a4b289fefa635ae7c34094 (diff)
downloadmatelight-a95e0305aeaffadf071e963863c102b30b76993a.tar.gz
matelight-a95e0305aeaffadf071e963863c102b30b76993a.tar.bz2
matelight-a95e0305aeaffadf071e963863c102b30b76993a.zip
Some fixes to the host software geom stuff, added a small demo script
Diffstat (limited to 'host/matelight/host.py')
-rw-r--r--host/matelight/host.py21
1 files changed, 12 insertions, 9 deletions
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')