aboutsummaryrefslogtreecommitdiff
path: root/NeoRuntime/builtin/running
diff options
context:
space:
mode:
authorjakob.stendahl <jakob.stendahl@infomedia.dk>2022-12-06 11:37:46 +0100
committerJakob Stendahl <jakob.stendahl@outlook.com>2022-12-06 11:37:46 +0100
commit98bb009777de51ef8900155cda05c92cc1cb3ab1 (patch)
tree1b866d1ac3bcba187a397f99b396162f337a6d23 /NeoRuntime/builtin/running
parent629503252de51f3a95ae3dd19ef837012eea9fc2 (diff)
downloadLuxcena-Neo-98bb009777de51ef8900155cda05c92cc1cb3ab1.tar.gz
Luxcena-Neo-98bb009777de51ef8900155cda05c92cc1cb3ab1.zip
Add some modes
Diffstat (limited to 'NeoRuntime/builtin/running')
-rw-r--r--NeoRuntime/builtin/running/script.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/NeoRuntime/builtin/running/script.py b/NeoRuntime/builtin/running/script.py
new file mode 100644
index 0000000..24147ce
--- /dev/null
+++ b/NeoRuntime/builtin/running/script.py
@@ -0,0 +1,27 @@
+from luxcena_neo import NeoBehaviour, ColorVariable, utils
+from time import perf_counter
+from math import sin
+
+class Main(NeoBehaviour):
+
+ def declare_variables(self):
+ self.declare(ColorVariable("color", "#ffffff", on_change=self.change_color))
+
+ def change_color(self, color):
+ self.red, self.green, self.blue = utils.hex_to_rgb(color)
+
+ def on_start(self):
+ self.red, self.green, self.blue = 255, 255, 255
+ self.position = 0
+ self.last_inst = perf_counter()
+
+ def each_tick(self):
+ if (perf_counter() - self.last_inst) > (0.07):
+ self.position = (self.position + 1) % (strip.num_pixels() * 2)
+ for i in range(strip.num_pixels()):
+ level = int(sin(i+self.position) * 127 + 128);
+ strip.set_pixel_color(i,int(((sin(i+self.position) * 127 + 128)/255)*self.red),
+ int(((sin(i+self.position) * 127 + 128)/255)*self.green),
+ int(((sin(i+self.position) * 127 + 128)/255)*self.blue));
+ self.last_inst = perf_counter()
+ \ No newline at end of file