summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2013-08-15 07:06:52 +0200
committerFlorian Bruhin <git@the-compiler.org>2013-08-15 07:06:52 +0200
commite4aef6f371efe9671593802f39b5c512787ddb55 (patch)
tree75154726cc97888e42a3943f7bb784d5a55b2280
parent90e777cea8f0e38477c6d3bb1c3b74cb0af16923 (diff)
downloadfarbrauch-master.tar.gz
farbrauch-master.zip
Add farbrauch_fade.pyHEADmaster
-rw-r--r--farbrauch_fade.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/farbrauch_fade.py b/farbrauch_fade.py
new file mode 100644
index 0000000..9c2bab7
--- /dev/null
+++ b/farbrauch_fade.py
@@ -0,0 +1,20 @@
+import sys,serial,struct,random,time
+ser = serial.Serial(sys.argv[1])
+
+def write(num):
+ ser.write(struct.pack('B', num))
+
+dt = 30
+
+oldcol = [0,0,0,0,0,0]
+
+while True:
+ newcol = [ random.randint(0,254), random.randint(0,254), random.randint(0,254),
+ random.randint(0,254), random.randint(0,254), random.randint(0,254) ]
+ for i in range(1,dt+1):
+ write(255)
+ for (k, val) in enumerate(oldcol):
+ val = val + ((newcol[k] - val) / dt) * i
+ write(int(val))
+ time.sleep(0.01)
+ oldcol = newcol