From de76400657d7c5e164e2afcddc2f10728b9478e1 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Fri, 23 Sep 2016 07:34:02 +0200 Subject: Update python.py --- Raspberry Pi/python.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'Raspberry Pi') diff --git a/Raspberry Pi/python.py b/Raspberry Pi/python.py index 9189f8e..71df0de 100644 --- a/Raspberry Pi/python.py +++ b/Raspberry Pi/python.py @@ -12,28 +12,37 @@ def hexToRgb(value): return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3)) def main(): - + """ Setup i2c communication """ i2cPixel.version() i2cPixel.setBus(1) i2cPixel.setAddress(0x04) - + """ Wait for heartbeat from Arduino """ while True: - if i2cPixel.greeting(): - print "Arduino is Online" - break + try: + if i2cPixel.greeting(): + print "Arduino is Online" + break + except Exception: + pass -while True: - test = raw_input() + """while True: + i2cPixel.waitForSensor()""" + + """ Test, set all pixels to entered color """ + while True: + test = raw_input() colour = hexToRgb(test) i = 0 while i < 10: i2cPixel.setPixel(i, colour[0], colour[1], colour[2]) i = i + 1 - i2cPixel.showPixel() - + i2cPixel.show() + i2cPixel.waitForSensor() + + """ Start script """ main() -- cgit v1.2.3