diff options
| author | Ingar <ingar@telenet.be> | 2022-02-06 16:37:35 +0100 |
|---|---|---|
| committer | Ingar <ingar@telenet.be> | 2022-02-06 16:37:35 +0100 |
| commit | 71cc164bd43714363432d39165c95017ec0943af (patch) | |
| tree | 29b668a0727c2771708fdb3f26f790aec7e3765e | |
| parent | 0133a185af1600d6bf8b432bb722b315a90487b1 (diff) | |
Fixed a major bug while reading the state file.
| -rw-r--r-- | ledctl.py | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -27,14 +27,14 @@ leds_array = neopixel.NeoPixel(board.D18, leds_max) statefile = '/tmp/ledctl.state' if exists(statefile): - print('reading ' + statefile) + #print('reading ' + statefile) with open(statefile, 'r') as f: lines = f.readlines() i = 0; for line in lines: - values = line.split(' ') - if (i < leds_num): + values = [ int(number) for number in line.rstrip().split(' ')] + if (i < leds_max): leds_array[i] = (values[0], values[1], values[2]); i = i + 1 f.close() @@ -63,21 +63,21 @@ def rgbval(colorname): return switch.get(colorname, 'Valid colors are black, white, ired, green, blue, yellow, on, off') if args.color: - print('color ' + args.color) + #print('color ' + args.color) leds_color = rgbval(args.color); if (leds_num > 0): - print('setting LED ' + leds_num) + #print('setting LED %d' % leds_num) - leds_array[leds_num] = leds_color + leds_array[leds_num - 1] = leds_color else: - print('setting all LEDs') + #print('setting all LEDs') leds_array.fill(leds_color) # write LED array to state file -print('writing ' + statefile) +#print('writing ' + statefile) with open(statefile, 'w') as f: for i in range(leds_max): |
