adafruit / Adafruit_CircuitPython_NeoPixel

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

neopixel_cleanup should be called on deinit() #98

Closed jamesrusso closed 5 months ago

jamesrusso commented 3 years ago

The neopixel_cleanup from the underlying neopixel_write module method should be called on deinit(). Without this call it is not possible to change the pixel lengths in the same process. The neopixel_cleanup method is called atexit, but it is likely desirable to have it just happen on the deinit method.

Ex:

The LEDs will never turn WHITE in this example:

import neopixel # pylint: disable=import-error
import time
import board

gpio_port = board.D18
pixels = neopixel.NeoPixel(gpio_port, 5, auto_write=False)
## Turn the first 5 pixels RED.
pixels.fill((255,0,0))
pixels.show()
time.sleep(3)
## Turn the first 3 pixels WHITE.
pixels.deinit()
pixels = neopixel.NeoPixel(gpio_port, 3, auto_write=False)
pixels.fill((255,255,255))
pixels.show()
time.sleep(3)

This will likely require an upstream change to adafruit Blinka, as the neopixel_cleanup method is not exposed in the non-board specific python file.

jamesrusso commented 3 years ago

I've opened this: https://github.com/adafruit/Adafruit_Blinka/issues/378

jamesrusso commented 3 years ago

I've created PR #99 to resolve this along with https://github.com/adafruit/Adafruit_Blinka/pull/379 on the NeoPixel module.

tekktrik commented 5 months ago

@tannewt it sounds like the underlying issue here was solved in another way, but just wanted to check.

tannewt commented 5 months ago

@tekktrik I have no context. Are you suggesting I close this?

jamesrusso commented 5 months ago

As the original opener, I think this was closed as it was discussed in upstream issue and work around was determined

tekktrik commented 5 months ago

@tannewt yes, sorry. I was looking at open issues and saw this and thought it might be considered closed, but wasn't entirely sure.

tannewt commented 5 months ago

Ok thank you both!