Created
April 27, 2017 00:11
-
-
Save wyojustin/844bbd35203527b35c026432489a1482 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from pixel_maps import ultim8x8, ultim8x24, ultim8x72, ultim24x24, ultim16x56 | |
from bibliopixel.drivers.serial_driver import DriverSerial, LEDTYPE | |
from bibliopixel.drivers.visualizer import DriverVisualizer | |
from bibliopixel import LEDMatrix, log, MatrixRotation | |
from BiblioPixelAnimations.matrix.bloom import Bloom | |
ROTATE_0 = MatrixRotation.ROTATE_0 | |
ROTATE_90 = MatrixRotation.ROTATE_90 | |
ROTATE_180 = MatrixRotation.ROTATE_180 | |
ROTATE_270 = MatrixRotation.ROTATE_270 | |
def getPixelArray(dev, rotation, vert_flip): | |
''' | |
pixel_map -- MultiMap Builder | |
dev -- com port ident string | |
''' | |
width = 4 * 16 | |
height = 6 * 8 / 3 | |
n_pixel = width * height | |
if False: ## array simulator (does not use ultim8x8 layout) | |
driver = DriverVisualizer(num=0, width=width, height=height, | |
pixelSize=15, port=1618, stayTop=True) | |
else: | |
driver = DriverSerial(LEDTYPE.GENERIC, | |
n_pixel, | |
hardwareID="16C0:0483", | |
dev=dev) | |
led = LEDMatrix(driver, | |
width=width, | |
height=height, | |
rotation=rotation, | |
vert_flip=vert_flip) | |
return led | |
leds = [ | |
getPixelArray('/dev/ttyACM0', rotation=ROTATE_0, vert_flip=False), | |
getPixelArray('/dev/ttyACM1', rotation=ROTATE_0, vert_flip=False), | |
getPixelArray('/dev/ttyACM2', rotation=ROTATE_0, vert_flip=False) | |
] | |
[led.setMasterBrightness(32) ## use low brightness for running off of USB | |
for led in leds] | |
try: | |
## Initialize and run animation | |
anims = [Bloom(led, dir=True) for led in leds] | |
# anim.run(amt=10, fps=15) | |
for i in range(2): | |
[anim.step() for anim in anims] | |
[led.update() for led in leds] | |
print i, 'ok' | |
time.sleep(2) | |
except KeyboardInterrupt: | |
## Quietly exit with keyboard interrupt (CTRL-C) | |
pass | |
finally: | |
for led in leds: | |
led.all_off() | |
led.update() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment