aboutsummaryrefslogtreecommitdiff
path: root/NeoRuntime/builtin/fade
diff options
context:
space:
mode:
Diffstat (limited to 'NeoRuntime/builtin/fade')
-rw-r--r--NeoRuntime/builtin/fade/script.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/NeoRuntime/builtin/fade/script.py b/NeoRuntime/builtin/fade/script.py
index c88650d..8fe902a 100644
--- a/NeoRuntime/builtin/fade/script.py
+++ b/NeoRuntime/builtin/fade/script.py
@@ -1,8 +1,28 @@
-from luxcena_neo import NeoBehaviour
-import time
+from luxcena_neo import NeoBehaviour, IntegerVariable
+
+def wheel(pos):
+ """Generate rainbow colors across 0-255 positions."""
+ if pos < 85:
+ return (pos * 3, 255 - pos * 3, 0)
+ elif pos < 170:
+ pos -= 85
+ return (255 - pos * 3, 0, pos * 3)
+ else:
+ pos -= 170
+ return (0, pos * 3, 255 - pos * 3)
class Main(NeoBehaviour):
+ def declare_variables(self):
+ self.declare(IntegerVariable("speed", 2, min_val=1, max_val=50))
+
def on_start(self):
- pass
+ """ Execute when mode is selected. """
+ self.i = 0
+ def each_tick(self):
+ self.i += self.var.speed
+ if self.i > 255: self.i = 0
+ for i in range(strip.num_pixels()):
+ strip.set_pixel_color(i, wheel(self.i))
+ strip.show()