aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Stendahl <jakob@Jakobs-MacBook-Pro.local>2016-10-18 10:29:40 +0200
committerJakob Stendahl <jakob@Jakobs-MacBook-Pro.local>2016-10-18 10:29:40 +0200
commit1fb2bdefd7627fde5a5adf594926ccc72d99fb19 (patch)
treedc94a1278cff5ed67b1a99c53973781068c498ed
parent0c0e5022ed2e03e422440fb08cf50a9e550c2673 (diff)
downloadi2c-Neopixel-1fb2bdefd7627fde5a5adf594926ccc72d99fb19.tar.gz
i2c-Neopixel-1fb2bdefd7627fde5a5adf594926ccc72d99fb19.zip
Source update
-rw-r--r--Raspberry Pi/config.json0
-rw-r--r--Raspberry Pi/python.py18
2 files changed, 12 insertions, 6 deletions
diff --git a/Raspberry Pi/config.json b/Raspberry Pi/config.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Raspberry Pi/config.json
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