From 1fb2bdefd7627fde5a5adf594926ccc72d99fb19 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Tue, 18 Oct 2016 10:29:40 +0200 Subject: Source update --- Raspberry Pi/python.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'Raspberry Pi/python.py') diff --git a/Raspberry Pi/python.py b/Raspberry Pi/python.py index 9189f8e..bdb939e 100644 --- a/Raspberry Pi/python.py +++ b/Raspberry Pi/python.py @@ -1,22 +1,27 @@ """ Imports """ +import logging import smbus import time +import json import i2cPixel """ Decalrations """ -pixels = 10 +pixels = 72 # Change this to the appropriate number for your setup def hexToRgb(value): value = value.lstrip('#') lv = len(value) return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3)) -def main(): +def setup(): + # Get settings from config.json """ Setup i2c communication """ i2cPixel.version() i2cPixel.setBus(1) i2cPixel.setAddress(0x04) + +def main(): """ Wait for heartbeat from Arduino """ while True: @@ -24,16 +29,17 @@ def main(): print "Arduino is Online" break -while True: - test = raw_input() + while True: + test = raw_input() colour = hexToRgb(test) i = 0 - while i < 10: + while i < pixels: i2cPixel.setPixel(i, colour[0], colour[1], colour[2]) i = i + 1 i2cPixel.showPixel() """ Start script """ -main() +setup() #configure +main() #Start main -- cgit v1.2.3