From 2389ba6cd27dadabf020b128c131aa5086389d87 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Thu, 21 Oct 2021 22:25:38 +0200 Subject: :sparkles: Blank pixels on exit --- NeoRuntime/Runtime/luxcena_neo/strip.py | 15 ++++++++------- NeoRuntime/Runtime/neo_runtime.py | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'NeoRuntime/Runtime') diff --git a/NeoRuntime/Runtime/luxcena_neo/strip.py b/NeoRuntime/Runtime/luxcena_neo/strip.py index 9a12969..d673e1b 100644 --- a/NeoRuntime/Runtime/luxcena_neo/strip.py +++ b/NeoRuntime/Runtime/luxcena_neo/strip.py @@ -49,13 +49,8 @@ class Strip: self.strip.begin() # Blank out all the LEDs - i = 0 - while True: - self.strip.setPixelColor(i, 0) - i += 1 - if (i > self.LED_COUNT): break - self.strip.show() - + self.blank() + # Setup matrix print(" * Generating matrix") # try: @@ -150,6 +145,12 @@ class Strip: def get_pixel_color(self, n): """Get the 24-bit RGB color value for the LED at position n.""" return self.strip.getPixelColor(n) + + def blank(self): + """Will turn off all pixels, this also calls show for you.""" + for n in range(self.LED_COUNT): + self.set_pixel_color(n, 0) + self.show() def color_from_rgb(red, green, blue, white=0): diff --git a/NeoRuntime/Runtime/neo_runtime.py b/NeoRuntime/Runtime/neo_runtime.py index caa367e..01e5a9e 100644 --- a/NeoRuntime/Runtime/neo_runtime.py +++ b/NeoRuntime/Runtime/neo_runtime.py @@ -80,6 +80,7 @@ class NeoRuntime: traceback.print_exc() finally: self.__close_socket() + self.__strip.blank() def __bind_socket(self): -- cgit v1.2.3