kitesurfer1404 / WS2812FX

WS2812 FX Library for Arduino and ESP8266
MIT License
1.58k stars 344 forks source link

Multiple Strand Aggregation Part 1: Composition #225

Closed trshafer closed 4 years ago

trshafer commented 4 years ago

Hey @kitesurfer1404 and @moose4lord,

Thanks for this fantastic library. This is the best non-blocking LED library I have found.

I have a use-case where I would like to have multiple strips appear as a single strip but use different Arduino data out pins. I was thinking that with minimally invasive changes I could refactor this library to support multiple strands across a single animation. The code changes would look like this:

  1. Replace inheritance of WS2812FX on AdafruitNeoPixel for composition and initialize AdafruitNeoPixel in the constructor. (this PR)
  2. Support passing in an AdafruitNeoPixel strip in WS2812FX initialize. Have an overloaded constructor where WS2812FX(uint16_t n, uint8_t p, neoPixelType t) would call WS2812FX(AdafruitNeoPixel strip). This will require also probably passing in the neoPixelType, as there's no way to pull out the neoPixelType from AdafruitNeoPixel. There would probably be some bug where different strands with different neoPixelTypes could have unexpected behavior.
  3. Support passing in an array of strips into WS2812FX. Something like WS2812FX(AdafruitNeoPixel strip[]). The getLength() call will add all of the individual strands and the setPixelColor will check the strand lengths and set the appropriate underlying strand pixel. We would probably default all existing non-individual-pixel code to just access the first strand such as getBrightness.

All existing usecases would still continue to work by still supporting a WS2812FX(uint16_t n, uint8_t p, neoPixelType t) constructor and users could still use the WS2812FX as if it is one-to-one with AdafruitNeoPixel.

Thoughts?

Thanks for your consideration!

trshafer commented 4 years ago

Closing in favor of discussion in https://github.com/kitesurfer1404/WS2812FX/pull/226