Skip to content

Make things tunable #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Conversation

caternuson
Copy link
Collaborator

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:

  • frequency - The SPI bus frequency, really only two values that matter. Added as an init parameter.
  • reset_time - The reset time value (TRST). Added as a new property.
  • bit0 - The byte that defines timing for a 0 bit (T0H+T0L). Added as a new property.
  • bit1 -The byte that defines timing for a 1 bit (T1H+T1L). Added as a new property.

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
Copy link
Collaborator Author

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.

@caternuson caternuson mentioned this pull request Sep 3, 2020
@caternuson caternuson requested a review from a team September 3, 2020 19:01
@tannewt
Copy link
Member

tannewt commented Sep 8, 2020

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
Copy link
Collaborator Author

Thanks. Submitted as a separate PR #22.

@caternuson
Copy link
Collaborator Author

Closing this in favor of #22

@caternuson caternuson closed this Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Frequency a Parameter to run Neopixels at 400 kHz (WS2811) or 800 kHz (WS2812)?
2 participants