Led animation usage

Good day.

This is my use case. In the BU16, I create midi messages. The DJ app replies with a midi message with the corresponding status. In midi rx I map this to the correct led to switch it. This works.

Next step is to add a shift function to the buttons. Another button, on another module, toggles a variable that represents shift on/off with immediate_send. Depending on the shift, the midi message gets a different note. The buttons are used as CUE pad, the shift is used to delete the CUE point. This also works.

Now I want to show with the leds of the buttons if shift is active or not by blinking them when shift is on and stop blinking when shift is off. What I assumed is that you could add an animation to a led that would not influence the intensity. But it now looks like the intensity and animation are dependant. If you set an animation, you also get maximum intensity ‘for free’, regardless what intensity was set before.

Why do I think it needs to be independent? The shift is triggered by a button, the switching on/off by midi-rx, two separate paths. It would be nice that it is not needed to mingle this code, i.e. keep it simple. The midi-rx does not need to check the shift, but just sets intensity and the shift does not have to check if it is on or not, but just adds the animation and applies it to any existing intensity.

This would be a nice programming concept, let’s discuss, but maybe I will do a feature request.

Next step, regardless of the feature discussion / request, is to try this work around, but also have questions. First get the value with led_value() and feed that into led_animation_phase_rate_type(num,1,val,x,y).

  • The documentation is unclear about phase/val.
  • Can the led value be read by led_value(num), is not documented.

Cheers, Bart.

This workaround does not seem to work.

You can make the led stop blinking by setting a frequency of 0, but to set the intensity differently? Looks like led_value is ignored after it blinks or blinked?

I would advise you to combine led_color_min() and the others from your other post to create more feedback on the LED itself as I also described there, the led_color_min()/mid()/max() will combine with intensity modifying effects to create color based feedback.

In this case, when pressing the button down while an animation is in progress, the animation color would change the intensity values of the button being pressed and the color values of the animation get added together.

Hope this helps make it clearer.

Thanks!

Edit: Removed some information so that someone actually will take time to read it … was a bit much … but please answer my questions … if RTFM is the answer, so be it … :innocent:

I do not use the colour mapping for buttons, but I think I understand the analogy. The animation is a different state or mode of the led where the intensity is used differently. Like it is for color_min/mid/max, but for animation mode, the intensity is not used at all.

Edit: Just decided to remove my ‘custom beautifier’ to keep it simple, will use max 127 for on, eliminating the need to use set_value() with other than 0 or 127 for button leds. (Except for the color map enc led).

My questions please.

  • In led_animation_phase_rate_type, what does ‘phase’ do?
  • How do I stop the animation with led intensity 0?
  • How do I, after that, switch the led on without anymation?

Thanks!

Cheers, Bart.

I think just now a quarter dropped … :slight_smile:

As for the intensity, I can tweak the RGB values in the colour blocks to yield less intensity and still use 0 and 127 for switching. This way, also, the blinking will be less intense.

But the questions about how to through all the blinking states remain.

Sorry, I planned to expand my original answer with an Edit, but a meeting took priority, so I’ll just answer them here:

The term “phase” basically changes where the waveform “begins”. In practice this means that for example when using a sine wave the maximum value of that sine will be at 3pi/2 or at three fourths of the wave itself.
Putting that into practice, if you give the phase parameter the value 0 when using a sine, the animation will start at medium intensity, then decrease to zero and then increase to maximum.

For stopping the animation, you would just use 0 for the frequency parameter.

After that you would have to once again define what controls the intensity parameter of the led_value() function after you’ve turned off the animation. So as an example:

led_animation_phase_rate_type(num, 2, 0, 0, 0)
led_value(num, 2, val)
1 Like

Thanks, it now works, but before it didn’t. The problem apparently was that I used 3 for type because I thought there is no ‘off’ type so why bother. But looks like the type 0 makes the difference in addition to the rate 0.

I think this is some kind of undocumented specific interaction. Only the parameters led_animation_phase_rate_type(self:element_index(), layer, phase, 0, 0) are able to completely stop the animation.

If you check the Animation Stop block itself as code, you’ll see it there as well.

I’ve added this interaction to the documentation.

1 Like