diff options
author | jakob.stendahl <jakob.stendahl@infomedia.dk> | 2022-12-06 11:37:46 +0100 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2022-12-06 11:37:46 +0100 |
commit | 98bb009777de51ef8900155cda05c92cc1cb3ab1 (patch) | |
tree | 1b866d1ac3bcba187a397f99b396162f337a6d23 /NeoRuntime/builtin/running | |
parent | 629503252de51f3a95ae3dd19ef837012eea9fc2 (diff) | |
download | Luxcena-Neo-98bb009777de51ef8900155cda05c92cc1cb3ab1.tar.gz Luxcena-Neo-98bb009777de51ef8900155cda05c92cc1cb3ab1.zip |
Add some modes
Diffstat (limited to 'NeoRuntime/builtin/running')
-rw-r--r-- | NeoRuntime/builtin/running/script.py | 27 |
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 |