Skip to content

Commit

Permalink
Merge pull request #2 from adafruit/master
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
twa127 authored Dec 31, 2020
2 parents fd6b194 + 6c82519 commit b5c2c19
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/adafruit_blinka/microcontroller/bcm283x/neopixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@
# 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 = None


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 # we save a reference to the buf, and if it changes we will cleanup and re-init.

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()

if _led_strip is None:
# Create a ws2811_t structure from the LED configuration.
# Note that this structure will be created on the heap so you
# 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 = buf

# Initialize all channels to off
for channum in range(2):
Expand Down

0 comments on commit b5c2c19

Please sign in to comment.