From de2a04bdca1feb94d8e2a3a7891e16db776a5774 Mon Sep 17 00:00:00 2001 From: Jesper Larsson Date: Sun, 27 Mar 2016 23:45:51 +0200 Subject: [PATCH] Completed second animation. --- OvveLeds.ino | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/OvveLeds.ino b/OvveLeds.ino index 58453d9..81645b6 100644 --- a/OvveLeds.ino +++ b/OvveLeds.ino @@ -57,7 +57,20 @@ void loop() { } void tickColorCircleAnimation() { - + for(int i = 0; i < strip1.numPixels(); i++) { + int n = state + i; + strip1.setPixelColor(i, R(n), G(n), B(n)); + } + for(int i = 0; i < strip2.numPixels(); i++) { + int n = state + i; + strip2.setPixelColor(i, R(n), G(n), B(n)); + } + + state++; + state = state % 6*255; + + strip1.show(); + strip2.show(); } void tickStaticWineredAnimation() { @@ -88,3 +101,52 @@ void toggleMode() { break; } } + +byte R(int n) { + n = n % 6*255; + if(n <= 1*255 || 5*255 < 255) { + return 255; + } + else if(1*255 < n && n <= 2*255) { + return 255 - (n % 255); + } + else if(2*255 < n && n <= 4*255) { + return 0; + } + else if(4*255 < n && n <= 5*255) { + return n % 255; + } +} + +byte G(int n) { + n = n % 6*255; + if(n <= 1*255) { + return n % 255; + } + else if(1*255 < n && n <= 3*255) { + return 255; + } + else if(3*255 < n && n <= 4*255) { + return 255 - (n % 255); + } + else if(4*255 < n) { + return 0; + } +} + +byte B(int n) { + n = n % 6*255; + if(n <= 2*255) { + return 0; + } + else if(2*255 < n && n <= 3*255) { + return n % 255; + } + else if(3*255 < n && n <= 5*255) { + return 255; + } + else if(5*255 < n) { + return 255 - (n % 255); + } +} +