From 629503252de51f3a95ae3dd19ef837012eea9fc2 Mon Sep 17 00:00:00 2001 From: "jakob.stendahl" Date: Mon, 5 Dec 2022 20:24:23 +0100 Subject: Add another builtin, and remove a debug print --- NeoRuntime/builtin/candy_cane/script.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 NeoRuntime/builtin/candy_cane/script.py (limited to 'NeoRuntime/builtin/candy_cane/script.py') diff --git a/NeoRuntime/builtin/candy_cane/script.py b/NeoRuntime/builtin/candy_cane/script.py new file mode 100644 index 0000000..5899d92 --- /dev/null +++ b/NeoRuntime/builtin/candy_cane/script.py @@ -0,0 +1,19 @@ +from luxcena_neo import NeoBehaviour, ColorVariable, IntegerVariable + +class Main(NeoBehaviour): + + def declare_variables(self): + self.declare(ColorVariable("Color 1", "#ff0000")) + self.declare(ColorVariable("Color 2", "#ffffff")) + self.declare(IntegerVariable("LED Groups", 3, min_val=1, max_val=10)) + + def update_self(self): + N = self.var["LED Groups"].value + for i in range(strip.num_pixels()): + c = self.var["Color 1"].value if i % (2 * N) < N else self.var["Color 2"].value + strip.set_pixel_color(i, c) + strip.show() + + def each_tick(self): + self.update_self() + \ No newline at end of file -- cgit v1.2.3