-
-
Notifications
You must be signed in to change notification settings - Fork 264
NeoPixelBus object API
The constructor will require the declaration of several template arguments that specialize the class to the sketch writer's needs. These class types are provided for the author and there is no need to implement them.
T_COLOR_FEATURE - the specialization class for the color feature.
T_METHOD - the specialization class for the method.
This will define the object with the given Feature and Method, and construct it to handle the countPixels on the given pin.
- countPixels - The number of pixels on the physical bus. This is limited primarily by memory to contain a buffer for them.
- pin - The output pin to use. Note that some platforms and Methods restrict the Pin and thus this constructor should not be used on them. On Esp8266 use the constructor that omits the pin.
This will define the object with the given Feature and Method, and construct it to handle the countPixels on the given pin. Further, it takes the Methods multiplex channel to use for this instance. Not all methods support the channel feature.
- countPixels - The number of pixels on the physical bus. This is limited primarily by memory to contain a buffer for them.
- pin - The output pin to use. Note that some platforms and Methods restrict the Pin and thus this constructor should not be used on them. On Esp8266 use the constructor that omits the pin.
- channel - The channel number defined by the enum NeoBusChannel to use.
This will define the object with the given Feature and Method, and construct it to handle the countPixels using a hardware defined pin.
For Esp8266 this is the constructor to use.
For DotStar using SPI this is the constructor to use.
- countPixels - The number of pixels on the physical bus. This is limited primarily by memory to contain a buffer for them. Some Methods (ex. NeoEsp8266Dma800KbpsMethod) require more buffer than others and you should refer to their documentation.
This will define the object with the given Feature and Method, and construct it to handle the countPixels on the given clock and data pins. This is used with DotStars only.
- countPixels - The number of pixels on the physical bus. This is limited primarily by memory to contain a buffer for them.
- pinClock - The clock output pin to use.
- pinData - The data output pin to use.
This will initialize the NeoPixelBus and prepare it for use. Call this first within Setup().
This will initialize the NeoPixelBus and prepare it for use. Call this first within Setup().
This is used with DotStars only using the DotStartSpiMethod
only. Defining the pins here due to the SPI also needing the pins on its begin
.
- sck - The clock output pin to use.
- miso - required by SPI, but not directly used
- mosi - The data output pin to use.
- ss - required by SPI, but not directly used
This will try to send the pixel information to the physical pixels. If there has been no change since the last time it was called, nothing will be sent.
Due to the hardware protocol, if you call this quickly after the last time it was called, it may wait up to 50us extra.
Based upon the Method used, sometimes this may take some time before it returns depending on the number of pixels or it may return almost immediately. If the method defined for the bus uses hardware, it will return quickly and send the data asynchronously. Otherwise, 300 pixel strip can take 9ms to send the data. The more pixels, the longer it takes, the less pixels, the quicker it can send them.
- maintainBufferConsistency - (defaults to true) Some methods are asynchronous and will return quickly before the pixel data is completely sent. Due to this, some of these methods will internally use two buffers that they will swap between, one for sending and one for editing. By default, it will copy the contents between the buffers to maintain consistency between them. If you always overwrite the buffers and never call GetPixelColor(), then you can gain some performance by passing false for this argument.
CAUTION: If you callShow(false)
, You should consider callingShow(true)
once after callingBegin()
so that both internal buffers start with a consistent cleared state, asShow(false)
expects that you overwrite every pixel on every update.
This will return true if enough time has passed since the last time Show() was called. This also means that calling Show() will not cause any undue waiting. If the method for the defined bus is hardware that sends asynchronously, then call CanShow() will let you know if it has finished sending the data from the last Show().
Normally, you really shouldn't worry about this as either you have enough other things in your sketch to process, or you have so little you don't care if Show() waits.
This will return true if SetPixelColor() was called since the last time Show() was called. It will also return true if the Dirty() method was called.
This will force the internal state to think that SetPixelColor() was called. This is handy if you modify the pixel buffer directly using the Pixels() method below.
This will force the internal state to think that Show() has happened and there is nothing new to send.
This will return a pointer to the internal buffer of pixels. See PixelsSize() and PixelSize() to understand how large this buffer is and how its laid out. If you modify the buffer contents, you will need to let the NeoPixelBus know this by calling the Dirty()
method otherwise Show()
will not update the pixels.
CAUTION: The pointer returned should not be cached or retained between calls of Show(). The value may change after calling Show()
This will return the number of bytes of the internal buffer that calling Pixels() returns.
This will return the number of bytes that a single pixel requires, as defined by the Feature given when the NeoPixelBus object was created.
This will return the number pixels the NeoPixelBus manages. This value was passed in to the NeoPixelBus object when it was created.
This will set the color for the given pixel.
- indexPixel - the pixel number
- color - a color object to use, RgbColor, HslColor, and HsbColor will all work and if the NeoPixelBus object was created with the NeoRgbwFeature the RgbwColor will also work.
This will return the color for the given pixel.
- indexPixel - the pixel number
- <return>, a color object, RgbColor or RgbwColor.
This will clear all pixels to the given color.
- color - a color object to use, RgbColor, HslColor, and HsbColor will all work and if the NeoPixelBus object was created with the NeoRgbwFeature the RgbwColor will also work.
This will clear all pixels from first to last to the given color.
- color - a color object to use, RgbColor, HslColor, and HsbColor will all work and if the NeoPixelBus object was created with the NeoRgbwFeature the RgbwColor will also work.
- first - the index to the first pixel to start clearing
- last - the index to the last pixel that will be cleared
This will rotate all the pixels by the given number of pixels. The pixels on the left will wrap around to the right side.
- rotationCount - the number of pixels to rotate left.
This will rotate all the pixels in the given range by the given number of pixels. The pixels on the left will wrap around to the right side.
- rotationCount - the number of pixels to rotate left.
- first - the first pixel to include in the rotation.
- last - the last pixel to include in the rotation.
This will shift all the pixels by the given number of pixels. The first shiftCount
pixels on right will be left alone.
- shiftCount - the number of pixels to shift left.
This will shift all the pixels in the given range by the given number of pixels. The first shiftCount
pixels on right will be left alone.
- shiftCount - the number of pixels to shift left.
- first - the first pixel to include in the shift.
- last - the last pixel to include in the shift.
This will rotate all the pixels by the given number of pixels. The pixels on the right will wrap around to the left side.
- rotationCount - the number of pixels to rotate left.
This will rotate all the pixels in the given range by the given number of pixels. The pixels on the right will wrap around to the left side.
- rotationCount - the number of pixels to rotate left.
- first - the first pixel to include in the rotation.
- last - the last pixel to include in the rotation.
This will shift all the pixels by the given number of pixels. The first shiftCount
pixels on left will be left alone.
- shiftCount - the number of pixels to shift right.
This will shift all the pixels in the given range by the given number of pixels. The first shiftCount
pixels on left will be left alone.
- shiftCount - the number of pixels to shift right.
- first - the first pixel to include in the shift.
- last - the last pixel to include in the shift.