adafruit / Adafruit_CircuitPython_NeoPixel_SPI

SPI driven CircuitPython driver for neopixels.
MIT License
24 stars 11 forks source link

Make things tunable #21

Closed caternuson closed 4 years ago

caternuson commented 4 years ago

For #19 and as another option to #20

This will allow for "tuning" of the underlying timings for better support of other flavor addressable RGBs. There are four parameters that are involved:

This example shows tweaking the bit 1 pattern which may work for the case discussed in #19 and #20:

$ python3
Python 3.6.9 (default, Jul 17 2020, 12:50:27) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> import neopixel_spi as neopixel
>>> pixels = neopixel.NeoPixel_SPI(board.SPI(), 1, pixel_order=neopixel.RGB)
>>> pixels.bit1 = 0b11111000
>>> pixels.fill(0xADAF00)
>>> 
caternuson commented 4 years ago

More commentary. Another possible approach would be to have something like a type parameter with several pre-defined types. So could then do something like:

pixels = neopixel.NeoPixel_SPI(board.SPI(), 1, pixel_order=neopixel.RGB. type=neopixel.WS2812B)

This would then programmatically set pre-defined timings under the hood based on type.

tannewt commented 4 years ago

I think the four attributes in the first post should be constructor kwargs. They don't need to be properties because they should be the same for the entire lifetime of the object.

I would avoid type because it's a Python keyword and is also less flexible.

caternuson commented 4 years ago

Thanks. Submitted as a separate PR #22.

caternuson commented 4 years ago

Closing this in favor of #22