]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Update neopixel.py
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Wed, 23 Dec 2020 17:13:12 +0000 (09:13 -0800)
committerGitHub <noreply@github.com>
Wed, 23 Dec 2020 17:13:12 +0000 (09:13 -0800)
src/adafruit_blinka/microcontroller/bcm283x/neopixel.py

index 1753419c136608fcc3f380fc5968d4c8ce02204c..70c9f38a9271d92f3a2e0abb9f3d565bc64e6eb6 100644 (file)
@@ -16,15 +16,15 @@ LED_STRIP = None  # We manage the color order within the neopixel library
 # a 'static' object that we will use to manage our PWM DMA channel
 # we only support one LED strip per raspi
 _led_strip = None
 # a 'static' object that we will use to manage our PWM DMA channel
 # we only support one LED strip per raspi
 _led_strip = None
-_buf_len = None
+_buf = None
 
 
 def neopixel_write(gpio, buf):
     """NeoPixel Writing Function"""
     global _led_strip  # we'll have one strip we init if its not at first
 
 
 def neopixel_write(gpio, buf):
     """NeoPixel Writing Function"""
     global _led_strip  # we'll have one strip we init if its not at first
-    global _buf_len # we save the length of the buf, and if it changes we will cleanup and re-initalize.
+    global _buf  # we save a reference to the buf, and if it changes we will cleanup and re-initalize.
 
 
-    if _led_strip is None or _buf_len != len(buf):
+    if _led_strip is None or buf is not _buf:
         # This is safe to call since it doesn't do anything if _led_strip is None
         neopixel_cleanup()
 
         # This is safe to call since it doesn't do anything if _led_strip is None
         neopixel_cleanup()
 
@@ -33,7 +33,7 @@ def neopixel_write(gpio, buf):
         # need to be careful that you delete its memory by calling
         # delete_ws2811_t when it's not needed.
         _led_strip = ws.new_ws2811_t()
         # need to be careful that you delete its memory by calling
         # delete_ws2811_t when it's not needed.
         _led_strip = ws.new_ws2811_t()
-        _buf_len = len(buf)
+        _buf = buf
 
         # Initialize all channels to off
         for channum in range(2):
 
         # Initialize all channels to off
         for channum in range(2):