adafruit / Adafruit_CircuitPython_NeoPixel

CircuitPython drivers for neopixels.
MIT License
302 stars 98 forks source link

Automatically turn on NEOPIXEL_POWER when using the NEOPIXEL pin #111

Closed tannewt closed 3 years ago

anecdata commented 3 years ago

I wonder if there's another approach. We have a number of boards with power control of various peripherals, and in some cases, the power control pin also controls something else, e.g., MagTag NEOPIXEL_POWER_INVERTED also powers the analog light sensor.

Also in the NeoPixel case, currently a private variable is needed to turn off power once init'd (or deinit the neopixel) - easily fixed independent of the larger issue.

And we have other peripherals with power control pins where the power control remains separate, e.g., MagTag speaker.

FeatherS2 has Dotstar with a power control pin that also controls the 2° LDO 3v3.

I suspect as time goes on, the variations will increase, depending on the peripherals and low-power needs of the particular board.

It seems to me that power control is a feature of the board rather than of a specific peripheral, and board-specific libraries could certainly account for power control (or leave power control to the user if they are not using the standard board library).

tannewt commented 3 years ago

I think we changed things here so that the power change would be backwards compatible. I think the simplest fix is to catch the pin in use exception and assume the user is doing it correctly when in use.