Skip to content

neopixel_cleanup should be called on deinit() #98

@jamesrusso

Description

@jamesrusso

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions