aboutsummaryrefslogtreecommitdiff
path: root/Raspberry Pi/python.py
diff options
context:
space:
mode:
authorJakob Stendahl <jakob@Jakobs-MacBook-Pro.local>2016-10-27 09:09:30 +0200
committerJakob Stendahl <jakob@Jakobs-MacBook-Pro.local>2016-10-27 09:09:30 +0200
commitd17acdc5a9885fdcc96bbe2ee0a4c88b68d0c07e (patch)
tree1d50929069c70d965e2aea5ee5e9e65752cc877a /Raspberry Pi/python.py
parent3c6a622c71c8f092e3de3f9a2fbbbfcca67cf720 (diff)
downloadi2c-Neopixel-d17acdc5a9885fdcc96bbe2ee0a4c88b68d0c07e.tar.gz
i2c-Neopixel-d17acdc5a9885fdcc96bbe2ee0a4c88b68d0c07e.zip
Update
Diffstat (limited to 'Raspberry Pi/python.py')
-rw-r--r--Raspberry Pi/python.py56
1 files changed, 13 insertions, 43 deletions
diff --git a/Raspberry Pi/python.py b/Raspberry Pi/python.py
index 3078683..bd43944 100644
--- a/Raspberry Pi/python.py
+++ b/Raspberry Pi/python.py
@@ -1,32 +1,13 @@
""" Imports """
import logging
-import smbus
import sys
import time
import json
-import i2cPixel
+import i2cPixel as strip
""" Decalrations """
pixels = 348 # Change this to the appropriate number for your setup
-addresses = [0, 24, 25, 35] # legg til en start og en stopp for hvert trinn
-
-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 lightStaircase(direction):
- repeats = len(addresses)
- repeats = repeats / 2
-
- if direction == "up":
- loopCondition = repeats
-
-
- else:
- loopCondition = 0
-
- return true
+pixelsPerStair = [21, 23, 23, 24, 25, 27, 31, 33, 28, 26, 25, 24, 24]
def errorHandler(type, errorMsg):
if type == 1: # Debug
@@ -56,26 +37,21 @@ def setup():
""" Set time """
start_time = time.time()
-
+
""" Setup i2c communication """
- i2cPixel.version()
- i2cPixel.setBus(1)
- i2cPixel.setAddress(0x04)
+ strip.version()
+ strip.setBus(1)
+ strip.setAddress(0x04)
""" Wait for heartbeat from Arduino """
while True:
try:
- if i2cPixel.greeting():
+ if strip.greeting():
print "Arduino is Online"
time.sleep(1)
break
except Exception:
pass
-
- """i = 0
- while i < pixels:
- i2cPixel.setPixel(i, 0, 0, 0)
- i2cPixel.show()"""
def main():
@@ -84,20 +60,18 @@ def main():
timer = time.time()
i = 0
while i < pixels:
- i2cPixel.setPixel(i, 255, 255, 255)
- i2cPixel.show()
+ strip.setPixel(i, 255, 255, 255)
+ strip.show()
i = i + 1
print("--- %s seconds ---" % (time.time() - timer))
timer = time.time()
i = 0
while i < pixels:
- i2cPixel.setPixel(i, 255, 255, 255)
+ strip.setPixel(i, 255, 255, 255)
i = i + 1
- i2cPixel.show()
+ strip.show()
print("--- %s seconds ---" % (time.time() - timer))
-
- pixelsPerStair = [21, 23, 23, 24, 25, 27, 31, 33, 28, 26, 25, 24, 24]
i = 0
o = 0
@@ -124,17 +98,13 @@ def main():
j = 0
while o <= mellomRekning:
- i2cPixel.setPixel(o, *color)
+ strip.setPixel(o, *color)
o = o + 1
- i2cPixel.show()
+ strip.show()
i = i + 1
print("--- %s seconds ---" % (time.time() - timer))
-
-
-
-
""" Start script """
setup() #configure
main() #Start main