aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2015-07-23 00:07:57 +0200
committerKing Kévin <kingkevin@cuvoodoo.info>2015-07-23 00:07:57 +0200
commit1b86a08e5cbd48fcf28fe3cdc713fcb61c115637 (patch)
tree14135f586c2c411cced34f0e92094b741fd5c73c
parentf3783caf432bc391ffb64a9288a3467c390ef50a (diff)
replace with fading with nice looking pattern
-rwxr-xr-xtest.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/test.rb b/test.rb
index a768708..d7c2530 100755
--- a/test.rb
+++ b/test.rb
@@ -27,13 +27,19 @@ NB_LEDS.times do |led|
sleep 0.1
end
-puts "white fading"
-white = 0
+puts "nice colors"
+phase = 0
+msg = [0xff,0x00,0x00,3*NB_LEDS]+[0x00]*3*NB_LEDS
+led_num = [10,9,8,7,6,5,4,3,2,1,0,11,12,13,14,15,16,17,18]+[29,28,27,26,25,24,23,22,21,20,19]+[41,42,43,44,45,46,47,48,40,39,38,37,36,35,34,33,32,31,30].reverse+[59,58,57,56,55,54,53,52,51,50,49].reverse
while true do
- start = Time.now
- screenlight.write ([0xff,0x00,0x00,3*NB_LEDS]+[white]*3*NB_LEDS).pack("C*") # set LED to red
- screenlight.flush_output
+ NB_LEDS.times do |i|
+ led = led_num[i]
+ msg[led*3+4] = (Math::sin(phase*0.9+i*0.2)+1)*128
+ msg[led*3+5] = (Math::sin(phase+Math::PI/2+i*0.2)+1)*128
+ msg[led*3+6] = (Math::sin(phase*1.1+Math::PI+i*0.2)+1)*128
+ end
+ screenlight.write msg.pack("C*")
+ screenlight.flush_output
+ phase += 0.025
sleep 0.02
- white = (white+1)%256
- puts "set white #{white} in #{Time.now-start} s"
end