aboutsummaryrefslogtreecommitdiff
path: root/NeoRuntime/builtin/fade
diff options
context:
space:
mode:
authorJakob Stendahl <14180120+JakobST1n@users.noreply.github.com>2021-10-11 20:02:04 +0200
committerGitHub <noreply@github.com>2021-10-11 20:02:04 +0200
commitc67531161e56488166a33232f87566309ba8676e (patch)
tree846e59a020e80bea48557d5a06af5728e44961ff /NeoRuntime/builtin/fade
parente6880cd8ccf82d993f222cb14b4860581654acb8 (diff)
parentc1b6eec770b885a9829e1f62bad5cc99389ca429 (diff)
downloadLuxcena-Neo-c67531161e56488166a33232f87566309ba8676e.tar.gz
Luxcena-Neo-c67531161e56488166a33232f87566309ba8676e.zip
Merge pull request #24 from JakobST1n/rebuild
v1.0.0
Diffstat (limited to 'NeoRuntime/builtin/fade')
-rw-r--r--NeoRuntime/builtin/fade/script.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/NeoRuntime/builtin/fade/script.py b/NeoRuntime/builtin/fade/script.py
new file mode 100644
index 0000000..8fe902a
--- /dev/null
+++ b/NeoRuntime/builtin/fade/script.py
@@ -0,0 +1,28 @@
+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):
+ """ 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()