bigjosh / SimpleNeoPixelDemo

A demonstration showing how easy it can be to drive WS2812 NeoPixels
MIT License
223 stars 59 forks source link

updating singular leds #6

Closed agrath closed 6 years ago

agrath commented 6 years ago

Hi Josh

Just wanted to check my understanding of your code - you must update all leds in the chain each time you call show (which in effect, is just a delay to allow the leds to latch)

The adafruit neopixel library does not require you to update all leds each time because it maintains an internal buffer (3 bytes per pixel) of the current RGB state for that pixel, correct, so when you call leds.show it sends the entire buffer (which is timing data passed down the chain containing state for all leds)

Would it be possible to selectively update individual pixels in the chain with this technique, without a buffer? I am thinking that the answer is no?

bigjosh commented 6 years ago

You can not communicate to a pixel at the end of a string of neopixels with out passing though all the pixels before it in the chain, so there is no way to selectively update a pixel in a string without also updating all the pixels between you and it. One way to make it seem like you are just updating the one specific pixel is to keep a copy of all the values in the chain and then resend all the ones that did not change every time you need to change one. The problem with this is that you need enough memory to remember the values of all the pixels all the time. This can be more memory than an Arduino has for longer strings.

The primary motivation behind this code is to avoid needing the buffer, so pixels are generated on the fly. In theory, if you can generate the pixels in the buffer then you can also generate them without the buffer - it just means taking a different perspective since without the buffer you must generate them in order. In practice this is easy for some kinds of displays (like repeating or algorithmic patterns, or text) and hard for others.