Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. import time
  2. from pixel_maps import ultim8x8, ultim8x24, ultim8x72, ultim24x24, ultim16x56
  3. from bibliopixel.drivers.serial_driver import DriverSerial, LEDTYPE
  4. from bibliopixel.drivers.visualizer import DriverVisualizer
  5. from bibliopixel import LEDMatrix, log, MatrixRotation
  6. from BiblioPixelAnimations.matrix.bloom import Bloom
  7.  
  8. ROTATE_0 = MatrixRotation.ROTATE_0
  9. ROTATE_90 = MatrixRotation.ROTATE_90
  10. ROTATE_180 = MatrixRotation.ROTATE_180
  11. ROTATE_270 = MatrixRotation.ROTATE_270
  12.  
  13. def getPixelArray(dev, rotation, vert_flip):
  14. '''
  15. pixel_map -- MultiMap Builder
  16. dev -- com port ident string
  17. '''
  18. width = 4 * 16
  19. height = 6 * 8 / 3
  20. n_pixel = width * height
  21. if False: ## array simulator (does not use ultim8x8 layout)
  22. driver = DriverVisualizer(num=0, width=width, height=height,
  23. pixelSize=15, port=1618, stayTop=True)
  24. else:
  25. driver = DriverSerial(LEDTYPE.GENERIC,
  26. n_pixel,
  27. hardwareID="16C0:0483",
  28. dev=dev)
  29.  
  30. led = LEDMatrix(driver,
  31. width=width,
  32. height=height,
  33. rotation=rotation,
  34. vert_flip=vert_flip)
  35. return led
  36.  
  37. leds = [
  38. getPixelArray('/dev/ttyACM0', rotation=ROTATE_0, vert_flip=False),
  39. getPixelArray('/dev/ttyACM1', rotation=ROTATE_0, vert_flip=False),
  40. getPixelArray('/dev/ttyACM2', rotation=ROTATE_0, vert_flip=False)
  41. ]
  42.  
  43. [led.setMasterBrightness(32) ## use low brightness for running off of USB
  44. for led in leds]
  45. try:
  46. ## Initialize and run animation
  47. anims = [Bloom(led, dir=True) for led in leds]
  48. # anim.run(amt=10, fps=15)
  49. for i in range(2):
  50. [anim.step() for anim in anims]
  51. [led.update() for led in leds]
  52. print i, 'ok'
  53. time.sleep(2)
  54.  
  55. except KeyboardInterrupt:
  56. ## Quietly exit with keyboard interrupt (CTRL-C)
  57. pass
  58. finally:
  59. for led in leds:
  60. led.all_off()
  61. led.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement