diff --git a/deploy/roles/collectd/templates/demo.py b/deploy/roles/collectd/templates/demo.py index 2e9e112..a7f2392 100644 --- a/deploy/roles/collectd/templates/demo.py +++ b/deploy/roles/collectd/templates/demo.py @@ -1,79 +1,82 @@ #!/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(): 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) + rgbColour = [LEDS_MAX, 0, 0] + for deccol in xrange(3): + inccol = 0 if deccol == 2 else deccol + 1 + for i in xrange(LEDS_MAX): + rgbColour[deccol] -= 1 + rgbColour[inccol] += 1 + debug(rgbColour) + for index in xrange(4): + line = 'l%d ' % index + '%d %d %d ' % (rgbColour[0], rgbColour[1],rgbColour[2]) * 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: 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.08) index += 1 time.sleep(0.6) ser = None if SERIAL: ser = serial.Serial(PORT, SPEED) try: while True: - text() - #colors() + #text() + colors() #kitt() except KeyboardInterrupt: if SERIAL: ser.close()