diff options
author | Jakob Stendahl <jakobste@uio.no> | 2021-10-21 22:14:58 +0200 |
---|---|---|
committer | Jakob Stendahl <jakobste@uio.no> | 2021-10-21 22:14:58 +0200 |
commit | f6d2fa6faee7ca5482711c2737170f61e8342425 (patch) | |
tree | 7a1ba56a88b4967d3b0d31d8f38ae33d326a9860 /NeoRuntime/builtin | |
parent | 7366ae92038e94e74472cb21a02b24124b72dd93 (diff) | |
download | Luxcena-Neo-f6d2fa6faee7ca5482711c2737170f61e8342425.tar.gz Luxcena-Neo-f6d2fa6faee7ca5482711c2737170f61e8342425.zip |
:lipstick: Improve simulation by changing to using a svg. and some small fixes
Diffstat (limited to 'NeoRuntime/builtin')
-rw-r--r-- | NeoRuntime/builtin/fade/script.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/NeoRuntime/builtin/fade/script.py b/NeoRuntime/builtin/fade/script.py index 8fe902a..e7e7481 100644 --- a/NeoRuntime/builtin/fade/script.py +++ b/NeoRuntime/builtin/fade/script.py @@ -1,4 +1,5 @@ -from luxcena_neo import NeoBehaviour, IntegerVariable +from luxcena_neo import NeoBehaviour, FloatVariable +from time import perf_counter def wheel(pos): """Generate rainbow colors across 0-255 positions.""" @@ -14,15 +15,18 @@ def wheel(pos): class Main(NeoBehaviour): def declare_variables(self): - self.declare(IntegerVariable("speed", 2, min_val=1, max_val=50)) + self.declare(FloatVariable("speed", 1, min_val=1, max_val=6, step=0.1)) def on_start(self): """ Execute when mode is selected. """ self.i = 0 + self.last_inst = perf_counter() 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() + if (perf_counter() - self.last_inst) > (6-self.var.speed): + self.i += 1 + if self.i > 255: self.i = 0 + for i in range(strip.num_pixels()): + strip.set_pixel_color(i, wheel(self.i)) + strip.show() + self.last_inst = perf_counter() |