aboutsummaryrefslogtreecommitdiff
path: root/NeoRuntime/builtin/fade
diff options
context:
space:
mode:
authorJakob Stendahl <14180120+JakobST1n@users.noreply.github.com>2021-10-11 09:08:42 +0200
committerGitHub <noreply@github.com>2021-10-11 09:08:42 +0200
commit9d8ab6ccd04530188caf9a24467e7374bc3c68cf (patch)
tree26d9d72971bb337da4a7c191c8fd9edc79468a33 /NeoRuntime/builtin/fade
parent14335646c5f31047e51cbaa038fc3cec92e49b90 (diff)
downloadLuxcena-Neo-9d8ab6ccd04530188caf9a24467e7374bc3c68cf.tar.gz
Luxcena-Neo-9d8ab6ccd04530188caf9a24467e7374bc3c68cf.zip
:lipstick: Add fade script
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()