question

Matt Kruse avatar image
Matt Kruse asked ·

Long "buttonUp" from last response masks new "none" animation?

I have been experimenting with SetLight for several hours, trying to grasp exactly what is happening. It's extremely frustrating, since there is no direct way to test or debug other than deploying a test skill over and over... anyway...

After a lot of experimentation, I've discovered that a long "buttonUp" animation (say, 10s) continues running even after the next response from my skill comes back. So when I respond, I overwrite both the "none" and "buttonUp" values, but the previous buttonUp continues to run to completion before the new settings take effect. Is that expected?

What I'm trying to do is effective STOP the "none" animation from running by masking it with a long buttonUp. But if the buttonUp continues to run even after I deliver a new "none" animation, that doesn't work, either.

I believe the API really needs a way to stop/cancel a running animation, either on button press or when a new response is received. Otherwise behavior is just so limiting that it's tough to develop interesting use cases with the buttons other a buzzer for a game, which is boring.

alexa skills kitbuttonsEcho Buttons Skill API
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Mike Dinescu avatar image
Mike Dinescu answered ·

Animations are not queued on the gadget. However, button up and button down animations do not replace an already playing immediate animation (ie. an animation that had a triggerEvent of "none"). Instead, button up and button down animations are played "over" the immediate animation. What this means is that when a button down or button up animation starts playing, it replaces the effect of the immediate animation for the duration of the button down, then button up animation. And once the button down and button up animations are done playing, the immediate animation that had been playing continues to play out as if it had been playing all along (meaning the immediate animation is not canceled, or paused while the button down/up animations play).

Button down and button up animations replace each other. Meaning that if you start playing a long animation on button down (say 5 sec) and after 1 second you start playing a button up animation that lasts a second, then the button down animation won't continue playing once the button up is done. Instead, the immediate animation will continue playing, as described above.

An immediate animation will stop and replace an existing immediate animation. So, if you want to cancel an immediate animation that is playing, you can send another immediate animation. This could be a "reset"-style animation that has a short duration (100ms) and a color of 0x000000. An immediate animation will NOT stop/replace any button down or button up animations, but it will replace the previous immediate animation, if any.

To stop or replace button down and button up animations, you would need to send a new button down or button up animation. Note, that you don't need to wait for a button press to replace a button down or button up animation that is already playing. The moment the gadget receives the new button down/up animation, the currently playing button down or up animation is replaced and takes effect immediately.

Regarding your observation that animations are not stopped, or otherwise affected, by skill responses, that is correct. Light animations are independent from skill responses during a skill session, unless the response contains specific instructions that would alter the animations as explained above.

Would you be willing to share some more details about the configuration of your input handler (duration, recognizers, and events defined) as well as the animations that you are sending?

3 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks for this clarification. I knew that up/down animations masked immediate animations, as that is in the docs. I wasn't so sure that up replaced down instead of masking it.

In my testing, I was observing that a long up animation masked an immediate animation sent back in the next response. So for example:

1. Skill launch
2. response sets up=<20s green> and waits for button
3. <button press> - button is now green
4. Skill responds with none=<1s red,1s green,1s blue>, up=<20s green>
5. Green continues to show until the up animation is complete, then picks up as if the none animation had been playing all along. 

I'm not positive that I don't have a bug in my code, so I will work on it and create a very specific example that demonstrates what I'm seeing.

My main question was to understand how it is supposed to work, so I'm not battling my own assumptions which may be wrong.

But from what you said, I should be able to return a response with SetLight directives for none, down,and up, and no matter what happens to be playing at the time, the none animation should immediately override and begin playing.

I'll get back to you with a better test case. I appreciate the response, thanks!

0 Likes 0 ·
But from what you said, I should be able to return a response with SetLight directives for none, down,and up, and no matter what happens to be playing at the time, the none animation should immediately override and begin playing.

Just to clarify: an immediate animation will NOT stop/replace any button down or button up animations, but it will replace a previous immediate animation, if any was playing.

If the button is playing out a long animation from a button up event, sending a new "none" animation will not replace that. You would have to also include a new "button up" animation.

0 Likes 0 ·

Right, in my comment I said if I return animations for all 3, then since I returned a buttonUp, which should cancel the running one, the none animation should then begin immediately.

But that's not the behavior I am seeing. Even if I return a new buttonUp animation, the previously-running buttonUp doesn't stop. It continues running until it's done, then the none animation I returned starts playing.

To recreate:

1. Return a buttonUp of 10s green

2. Press the button, the light turns green

3. In the button handler, return animations for none, buttonDown, and buttonUp. In theory, the new buttonUp should replace the old and end it, and the none should begin playing immediately. But it doesn't, in my experience. The previous buttonUp continues until it is done.

0 Likes 0 ·