From 76cd8292c5b80749ece1ab6558f3ed410a618f0d Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Sun, 10 Oct 2021 23:27:32 +0200 Subject: :hammer: Update some of the builtin scripts --- NeoRuntime/builtin/static/script.py | 36 +++++++-------------------------- NeoRuntime/builtin/strandtest/script.py | 2 +- 2 files changed, 8 insertions(+), 30 deletions(-) (limited to 'NeoRuntime/builtin') diff --git a/NeoRuntime/builtin/static/script.py b/NeoRuntime/builtin/static/script.py index 505ab67..8916106 100644 --- a/NeoRuntime/builtin/static/script.py +++ b/NeoRuntime/builtin/static/script.py @@ -1,39 +1,17 @@ from luxcena_neo import NeoBehaviour, ColorVariable, utils -import time class Main(NeoBehaviour): - + def declare_variables(self): self.declare(ColorVariable("color", "#fafafa", on_change=self.set_color)) - self.declare(ColorVariable("color2", "#fafafa", on_change=self.set_color)) def on_start(self): - print(f"Script started, color: {self.var.color}") - self.set_color(self.var.color) - strip.power_on = True - self.current_color = self.var.color - + print("Script started, color: {}".format(self.var.color)) + def set_color(self, value): - print(f"Color var changed: {value}") - # transition_color(self.current_color, value, 1) - -def lerp(a, b, u): - return (1 - u) * a + u * b - -def transition_color(start_color, end_color, duration): - start_color = utils.hex_to_rgb(start_color) - end_color = utils.hex_to_rgb(end_color) - interval = 10 - steps = duration / interval - step_u = 1.0 / steps - u = 0 - - while u < 1: - r = round(lerp(start_color[0], end_color[0], u)) - g = round(lerp(start_color[1], end_color[1], u)) - b = round(lerp(start_color[2], end_color[2], u)) - for i in len(strip.LED_COUNT): - strip.set_pixel_color(i, (r, g, b)) + print("Color var changed: {}".format(value)) + print(utils.detect_format_convert_color(value)) + for i in range(strip.LED_COUNT): + strip.set_pixel_color(i, value) strip.show() - time.sleep(interval / 100) \ No newline at end of file diff --git a/NeoRuntime/builtin/strandtest/script.py b/NeoRuntime/builtin/strandtest/script.py index f7d013a..6d263ab 100644 --- a/NeoRuntime/builtin/strandtest/script.py +++ b/NeoRuntime/builtin/strandtest/script.py @@ -60,7 +60,7 @@ def theaterChaseRainbow(wait_ms=50): class Main(NeoBehaviour): - def onStart(self): + def on_start(self): # Do an endless loop with some default ixel test patterns while True: colorWipe(*(255, 0, 0)) # Red wipe -- cgit v1.2.3