Skip to content

Commit 65eefcc

Browse files
authored
Allow NEOPIXEL_POWER* init outside of NeoPixel lib
Ignore exception when trying to set up `NEOPIXEL_POWER`* pin, since user may have set that up already for controlling power independently of this library. Tested on `Adafruit CircuitPython 7.0.0-alpha.5-187-g1e53cf40a on 2021-08-11; Adafruit MagTag with ESP32S2`; code snippet: ```py import digitalio, neopixel # NeoPixels & light sensor aux_power_io = digitalio.DigitalInOut(board.NEOPIXEL_POWER_INVERTED) aux_power_io.direction = Direction.OUTPUT aux_power_io.value = False # active low status_light = neopixel.NeoPixel(board.NEOPIXEL, 4, brightness=0.05, pixel_order=neopixel.GRB) ```
1 parent b2f21e6 commit 65eefcc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

neopixel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,11 @@ def __init__(
120120
if not power:
121121
power = getattr(board, "NEOPIXEL_POWER", None)
122122
if power:
123-
self._power = digitalio.DigitalInOut(power)
124-
self._power.switch_to_output(value=polarity)
123+
try:
124+
self._power = digitalio.DigitalInOut(power)
125+
self._power.switch_to_output(value=polarity)
126+
except ValueError:
127+
pass
125128

126129
super().__init__(
127130
n, brightness=brightness, byteorder=pixel_order, auto_write=auto_write

0 commit comments

Comments
 (0)