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/fade_all | |
parent | 629503252de51f3a95ae3dd19ef837012eea9fc2 (diff) | |
download | Luxcena-Neo-98bb009777de51ef8900155cda05c92cc1cb3ab1.tar.gz Luxcena-Neo-98bb009777de51ef8900155cda05c92cc1cb3ab1.zip |
Add some modes
Diffstat (limited to 'NeoRuntime/builtin/fade_all')
-rw-r--r-- | NeoRuntime/builtin/fade_all/script.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/NeoRuntime/builtin/fade_all/script.py b/NeoRuntime/builtin/fade_all/script.py new file mode 100644 index 0000000..ee07324 --- /dev/null +++ b/NeoRuntime/builtin/fade_all/script.py @@ -0,0 +1,26 @@ +from luxcena_neo import NeoBehaviour, FloatVariable +from time import perf_counter + +class Main(NeoBehaviour): + + def declare_variables(self): + self.declare(FloatVariable("speed", 0.99, min_val=0.5, max_val=1, step=0.001)) + + def on_start(self): + self.intensity = 0 + self.color = 0 + self.inc = 1 + self.last_inst = perf_counter() + + def each_tick(self): + if (perf_counter() - self.last_inst) > (1.001-self.var.speed): + self.intensity += self.inc + if self.intensity % 256 == 0: self.inc *= -1 + if self.intensity <= 0: self.color = (self.color + 1) % 3 + set_all(*[self.intensity if i == self.color else 0 for i in range(3)]) + self.last_inst = perf_counter() + +def set_all(*color): + for i in range(strip.num_pixels()): + strip.set_pixel_color(i, *color) + strip.show() |