diff --git a/deploy/roles/collectd/templates/demo.py b/deploy/roles/collectd/templates/demo.py index 232713c..d812f9b 100644 --- a/deploy/roles/collectd/templates/demo.py +++ b/deploy/roles/collectd/templates/demo.py @@ -1,77 +1,79 @@ #!/usr/bin/env python2 import serial import time DEBUG = 1 SERIAL = 1 PORT = '/dev/ttyS1' SPEED = 9600 LEDS_NUMBER = 8 LEDS_MAX = 100 TIME = 0.1 def debug(msg): if DEBUG: f = open('/tmp/debug_demo', 'a+') f.write(str(msg) + "\n") f.close() def write(line): if SERIAL: ser.write(line) debug(line) def kitt(ser): for i in [0, 1, 2, 3, 2, 1]: for j in xrange(4): line = 'l%d ' % j + '%d 0 0 ' % (LEDS_MAX if i==j else 0) * LEDS_NUMBER write(line) time.sleep(TIME) def colors(): step = 32 for r in xrange(0, LEDS_MAX, step): for g in xrange(0, LEDS_MAX, step): for b in xrange(0, LEDS_MAX, step): for index in xrange(4): line = 'l%d ' % index + '%d %d %d ' % (r, g, b) * LEDS_NUMBER write(line) time.sleep(TIME) def text(): letters = [ [[0,1,0,0,0,1,0,0],[0,1,0,1,0,1,0,0],[0,1,0,1,0,1,0,0],[0,1,1,1,1,1,0,0]], # E [[0,1,1,1,0,0,0,0],[0,1,0,1,0,0,0,0],[0,1,0,1,0,0,0,0],[0,1,1,1,1,1,0,0]], # P [[0,1,0,0,0,0,0,0],[0,1,0,1,0,0,0,0],[0,1,0,1,0,0,0,0],[0,1,1,1,1,1,0,0]], # F [[0,0,0,0,0,1,0,0],[0,0,0,0,0,1,0,0],[0,0,0,0,0,1,0,0],[0,1,1,1,1,1,0,0]], # L #[[0,1,0,1,1,1,0,0],[0,1,0,1,0,1,0,0],[0,1,0,1,0,1,0,0],[0,1,1,1,0,1,0,0]], #[[0,1,1,1,1,1,0,0],[0,1,0,0,0,1,0,0],[0,1,0,0,0,1,0,0],[0,1,1,1,1,1,0,0]], #[[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,1,1,1,1,1,0,0],[0,0,0,0,0,0,0,0]], #[[0,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0],[0,1,1,1,1,1,0,0],[0,1,0,0,0,0,0,0]], #[[0,1,1,1,1,1,0,0],[0,1,0,1,0,0,0,0],[0,1,0,1,0,0,0,0],[0,1,1,1,1,1,0,0]], #[[0,1,0,1,1,1,0,0],[0,1,0,1,0,1,0,0],[0,1,0,1,0,1,0,0],[0,1,1,1,0,1,0,0]], [[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0]], # NULL ] for l in letters: - for r in letters[l]: - line = 'l%d ' % l \ + index = 0 + for r in l: + line = 'l%d ' % index \ + ' '.join([str(x).replace("1", str(LEDS_MAX)) + ' 0 0 ' for x in r]) write(line) time.sleep(0.06) + index += 1 time.sleep(0.6) ser = None if SERIAL: ser = serial.Serial(PORT, SPEED) try: while True: text() #colors() #kitt() except KeyboardInterrupt: if SERIAL: ser.close()