These are chat archives for Makuna/NeoPixelBus

24th
Jan 2016
probonopd
@probonopd
Jan 24 2016 16:45
hi @Makuna I am using your NeoPixelBus DmaDriven branch in my esp8266-mqtt-neopixels-ota sketch and would like to add fades and animations, without breaking mqtt and/or ota. what do you recommend?
sticilface
@sticilface
Jan 24 2016 16:53
You should be able to use the neopixel animator class? See the examples..
probonopd
@probonopd
Jan 24 2016 16:54
will try that. thanks
sticilface
@sticilface
Jan 24 2016 17:00
I think the example actually are blocking and call delay.
You can easily change it to use a time diff function instead. I regularly run all this together with no issues.
If ur struggling I can give you an example. Just not now.
probonopd
@probonopd
Jan 24 2016 17:09
thanks @sticilface - would be great if you could post an example sketch with "all this together" once you have time
sticilface
@sticilface
Jan 24 2016 17:15
And by all this together what u mean exactly....
Aditya Tannu
@AdySan
Jan 24 2016 17:16
@sticilface yep me looking for a non-blocking example too. all this I guess is MQTT, OTA and NeoPixel animations.
sticilface
@sticilface
Jan 24 2016 17:20
Well...ota is blocking so pixels won't working during update. Can update them pre and post update but the loop is not called so u have to call show().
How complex are the effects your trying to run? The animations are done via callbacks. So one fade to, fade from, or sequence running from 0 to 1 (float) can be done by 1 call to a function. So managing complex sequences becomes about firing this function at regular intervals. Again this can be done in a non blocking way by comparing millis() - lasttime > x type question.
Got my drift?
sticilface
@sticilface
Jan 24 2016 18:10
here is the function i put in my main loop to drive neopixels in non-blocking way every 30ms. The bool allows override of the timer.... so pixels are updated regardless.
void Show_pixels(bool override)
{
  static uint32_t tick = 0;
  if (override) { tick = 0; }
  if ( millis() - tick < 30) { return; }
  if ( animator.IsAnimating() ) { animator.UpdateAnimations(100); }
  strip.Show();
  tick = millis();
}
place Show_pixels(false) in your loop.
this requires your pixels to be called strip, and animator to be called animator.
Aditya Tannu
@AdySan
Jan 24 2016 19:45
well, OTA is blocking but you can do things while it is updating, in the onProgress() function. Like I update the OLED here, https://twitter.com/Ady/status/683342658916384768
Could do a progress bar on the neopixels?
Michael Miller
@Makuna
Jan 24 2016 19:49
I do not think they meant the onProgress() to be used to continuing doing work, I think they meant it to provide some sort of progress feedback. How often is onProgress() called?
Lets just say its called once a second (I really don't know), this means you could only change the state of the NeoPixels once a second. That won't be a very smooth animation. If all you want to do is just change the state of pixels (think of a line of them as a progress bar), then just set the pixels and call show().
Now if they call 30 times a second, then you could replicate what you put in your loop() function for the pixels and the animations will run smoothly.
Does that make sense?
Aditya Tannu
@AdySan
Jan 24 2016 19:51
Not sure, I think they call it every 1%
I'll give it a try, this progress bar has around 100 pixels, and this looks pretty smooth.
Michael Miller
@Makuna
Jan 24 2016 20:08
On an Advanced Animation Topic, the UpdateAnimations() call takes a delta time. Normally you call millis(), remember the time the last time you call it, then pass the delta between the last time and this time to this function.
But sometimes you want to watch the animations closely to see that they are doing what you want them to do; but they run so fast its hard to track. To test, you could just divide the passed in delta by 10 and the animations will run 10 times slower.
sticilface
@sticilface
Jan 24 2016 20:18
oh u added that
cool
probonopd
@probonopd
Jan 24 2016 22:57
with "all this together" i meant a OTA-updateable sketch that can display colors set by MQTT using animations, e.g., crossfades. So that I can set "yellow", then "red" via MQTT and it will fade via orange.
is there any demo/example sketch for this?
@AdySan a progress bar during the OTA using the pixels is also a neat idea
Aditya Tannu
@AdySan
Jan 24 2016 22:58
@probonopd will definitely try it out later today.
oh yeah fading in the Hue use case would be neat, I just set the color.
Aditya Tannu
@AdySan
Jan 24 2016 23:55
Can I use HslColor in SetPixelColor somehow, I don't understand why this object exists if it cannot be used to set HSL values