From 93592ee43978005a86e0d83486c7b866e2c1b61f Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 18 Dec 2013 18:22:00 +0100 Subject: Moving on with the host program --- host/matelight/host.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 host/matelight/host.py (limited to 'host/matelight/host.py') 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') -- cgit