diff options
author | jaseg <jaseg@jaseg.net> | 2013-12-27 03:02:26 +0100 |
---|---|---|
committer | jaseg <jaseg@jaseg.net> | 2013-12-27 03:02:26 +0100 |
commit | a95e0305aeaffadf071e963863c102b30b76993a (patch) | |
tree | c499d709443fbef32c3b03c8ecaee5e23d3ce2a9 | |
parent | f2731bac95ebcd91a2a4b289fefa635ae7c34094 (diff) | |
download | matelight-a95e0305aeaffadf071e963863c102b30b76993a.tar.gz matelight-a95e0305aeaffadf071e963863c102b30b76993a.tar.bz2 matelight-a95e0305aeaffadf071e963863c102b30b76993a.zip |
Some fixes to the host software geom stuff, added a small demo script
-rw-r--r-- | firmware/main.c | 9 | ||||
-rw-r--r-- | host/matelight/config.py | 22 | ||||
-rw-r--r-- | host/matelight/host.py | 21 | ||||
-rwxr-xr-x | host/matelight/nyancat-test.py | 29 | ||||
-rw-r--r-- | host/nyancat.png | bin | 0 -> 483 bytes | |||
-rw-r--r-- | host/nyancat.xcf | bin | 0 -> 1658 bytes | |||
-rw-r--r-- | host/nyancat2.png | bin | 0 -> 477 bytes | |||
-rw-r--r-- | host/nyancat2.xcf | bin | 0 -> 1655 bytes | |||
-rw-r--r-- | host/scroller.png | bin | 0 -> 1557 bytes |
9 files changed, 58 insertions, 23 deletions
diff --git a/firmware/main.c b/firmware/main.c index a7a0436..93351cb 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -272,11 +272,10 @@ int main(void) { MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3); - /* 200kBd */ - MAP_SSIConfigSetExpClk(SSI0_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8); - MAP_SSIConfigSetExpClk(SSI1_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8); - MAP_SSIConfigSetExpClk(SSI2_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8); - MAP_SSIConfigSetExpClk(SSI3_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8); + MAP_SSIConfigSetExpClk(SSI0_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2000000, 8); + MAP_SSIConfigSetExpClk(SSI1_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2000000, 8); + MAP_SSIConfigSetExpClk(SSI2_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2000000, 8); + MAP_SSIConfigSetExpClk(SSI3_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2000000, 8); /* Configure the µDMA controller for use by the SPI interface */ MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); 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 Binary files differnew file mode 100644 index 0000000..1e0bf80 --- /dev/null +++ b/host/nyancat.png diff --git a/host/nyancat.xcf b/host/nyancat.xcf Binary files differnew file mode 100644 index 0000000..af439e2 --- /dev/null +++ b/host/nyancat.xcf diff --git a/host/nyancat2.png b/host/nyancat2.png Binary files differnew file mode 100644 index 0000000..7e4cbd4 --- /dev/null +++ b/host/nyancat2.png diff --git a/host/nyancat2.xcf b/host/nyancat2.xcf Binary files differnew file mode 100644 index 0000000..e340edd --- /dev/null +++ b/host/nyancat2.xcf diff --git a/host/scroller.png b/host/scroller.png Binary files differnew file mode 100644 index 0000000..2257626 --- /dev/null +++ b/host/scroller.png |