pxt-adafruit icon indicating copy to clipboard operation
pxt-adafruit copied to clipboard

showRing and setAll are incompatible

Open samelhusseini opened this issue 7 years ago • 3 comments

Describe the bug It appears showRing and setAll are incompatible.

Try the following code:

input.buttonA.onEvent(ButtonEvent.Click, function () {
    light.setAll(0x0000ff)
    pause(1000)
})
forever(function () {
    light.showRing(
    "red red red red red red red red red red"
    )
})

It doesn't work as expected which is show blue on button pressed, and red all the other times. I think it has something to do with autoShow and how it determines what the buffer is.

@pelikhan

samelhusseini avatar Nov 21 '18 19:11 samelhusseini

this is expected because setAll is not an animation. It does not get queued. As soon as it hits pause, the forever handler runs.

pelikhan avatar Nov 21 '18 19:11 pelikhan

Not sure that's expected from a user perspective.. Thoughts on how we can make it better?

samelhusseini avatar Nov 21 '18 19:11 samelhusseini

This is a general issue between immediate rendering and the animation queue. In general, all apis starting with "show" are queued, while "set" is immidate. We should hide "setAll" and add a "showAll" instead that follows animation semantics. Making a change in here is a runtime change, so should be treated as a potential breaking change.

pelikhan avatar Nov 21 '18 20:11 pelikhan