diff options
author | jaseg <jaseg@jaseg.net> | 2013-12-18 18:22:00 +0100 |
---|---|---|
committer | jaseg <jaseg@jaseg.net> | 2013-12-18 18:22:00 +0100 |
commit | 93592ee43978005a86e0d83486c7b866e2c1b61f (patch) | |
tree | 90d0e090eb62418635081370eb3b83c132ad56ba /host/matelight/host.py | |
parent | 037b3fc1d453e60a3cca0cf0775f6397bd7337cb (diff) | |
download | matelight-93592ee43978005a86e0d83486c7b866e2c1b61f.tar.gz matelight-93592ee43978005a86e0d83486c7b866e2c1b61f.tar.bz2 matelight-93592ee43978005a86e0d83486c7b866e2c1b61f.zip |
Moving on with the host program
Diffstat (limited to 'host/matelight/host.py')
-rw-r--r-- | host/matelight/host.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/host/matelight/host.py b/host/matelight/host.py new file mode 100644 index 0000000..461a4fa --- /dev/null +++ b/host/matelight/host.py @@ -0,0 +1,16 @@ +from pyusb import usb +import colorsys +import numpy as np + +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)) + + 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') |