From a95e0305aeaffadf071e963863c102b30b76993a Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 27 Dec 2013 03:02:26 +0100 Subject: Some fixes to the host software geom stuff, added a small demo script --- host/matelight/host.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'host/matelight/host.py') 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') -- cgit