These are chat archives for Makuna/NeoPixelBus

13th
Nov 2016
Michael Miller
@Makuna
Nov 13 2016 07:12
@protolyser Yeah, the animation examples are rather simple and I have learned that they confuse many people. So don't feal bad. The animation system is built really general to provide time management. The best way to use depends greatly on the problem you are trying to solve.
What I would suggest is to have a animation "channel" (index) for each of your modes. This way, switching modes is stop one animation and start another. But this really only works for simple animations. If you need more than one channel to accomplish what you want for a mode; then it gets a little more complex.
You can start and stop animation in the loop and even in the animation callback. There is no restriction other than calling it from a Interrupt Service Routine.
Michael Miller
@Makuna
Nov 13 2016 07:19
The animation channel (index) is not really tied to any single pixel; it just tracks the time and callback to use when your animation needs to be updated.
Michael Miller
@Makuna
Nov 13 2016 07:25
A case in point about the examples being confusing, the NeoPixelCylon example shows a technique that I would not recommended; but I did want to show how two channels could effect the same pixels. There are better ways to do it (like draw the fading line in the animation update after clearing everything) which would allow you directly control the length of the fade line. But it currently does match the concept of phosphorus fade so I left it that way.
protolyser
@protolyser
Nov 13 2016 17:55
I see. yeah especially when you're new to all this (arduino, c++,..) it's a bit confusing and hard to figure out how to do it correctly. But learning is fun in that case so I try to figure it out via trail and error. (and learning the techniques behind it additionally).
protolyser
@protolyser
Nov 13 2016 18:00
how can I get this to work?
void callback(char* topic, byte* payload, unsigned int length) { if (topicer == "ledmatrix/color"){ COLOR = hslCustom(float(payload) / 360.0f, saturationValue, lightnessValue); } }
protolyser
@protolyser
Nov 13 2016 19:08
tried it with this. that works partially, but that only shows the main colors red blue green and not the ones in between, how can I do it better?
if (topicer == "ledmatrix/color"){
      int i;
      float got_float;
      int got_int;

      for (i = 0; i<length; i++) {
      message_buff[i] = payload[i];
      }
      message_buff[i] = '\0';
      const char *p_payload = message_buff;

      got_float = atof(p_payload);
      got_int = (int)got_float;
      HslColor hslCustom(got_int / 360.0f, saturationValue, lightnessValue); 
      COLOR = hslCustom;
  }
protolyser
@protolyser
Nov 13 2016 21:43
works.. I had the lightness value so low that all variants of the different colors pretty much looked the same, anyway if there's a better way to do it I'm open suggestions