summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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