microbit: patch for animation/scroll behaviour for images
See bbc/microbit-extras/issues/#1100 or lancaster-university/microbit-dal/issues/5 for full details. Summary: A stride of 0 would lock the calling fiber indefinitely, which was not the expected behaviour for many people. This update fixes this issue in both animate and scroll, returning immediately when there is a stride of zero.
This commit is contained in:
parent
32faae520d
commit
b2484dcc97
1 changed files with 9 additions and 3 deletions
|
@ -294,7 +294,7 @@ void MicroBitDisplay::updateScrollImage()
|
|||
{
|
||||
image.clear();
|
||||
|
||||
if ((image.paste(scrollingImage, scrollingImagePosition, 0, 0) == 0) && scrollingImageRendered)
|
||||
if (((image.paste(scrollingImage, scrollingImagePosition, 0, 0) == 0) && scrollingImageRendered) || scrollingImageStride == 0)
|
||||
{
|
||||
animationMode = ANIMATION_MODE_NONE;
|
||||
this->sendAnimationCompleteEvent();
|
||||
|
@ -326,6 +326,12 @@ void MicroBitDisplay::updateAnimateImage()
|
|||
|
||||
image.paste(scrollingImage, scrollingImagePosition, 0, 0);
|
||||
|
||||
if(scrollingImageStride == 0)
|
||||
{
|
||||
animationMode = ANIMATION_MODE_NONE;
|
||||
this->sendAnimationCompleteEvent();
|
||||
}
|
||||
|
||||
scrollingImageRendered = true;
|
||||
|
||||
scrollingImagePosition += scrollingImageStride;
|
||||
|
@ -662,7 +668,7 @@ int MicroBitDisplay::scrollAsync(MicroBitImage image, int delay, int stride)
|
|||
scrollingImage = image;
|
||||
scrollingImageRendered = false;
|
||||
|
||||
animationDelay = delay;
|
||||
animationDelay = stride == 0 ? 0 : delay;
|
||||
animationTick = 0;
|
||||
animationMode = ANIMATION_MODE_SCROLL_IMAGE;
|
||||
}
|
||||
|
@ -794,7 +800,7 @@ int MicroBitDisplay::animateAsync(MicroBitImage image, int delay, int stride, in
|
|||
scrollingImage = image;
|
||||
scrollingImageRendered = false;
|
||||
|
||||
animationDelay = delay;
|
||||
animationDelay = stride == 0 ? 0 : delay;
|
||||
animationTick = delay-1;
|
||||
animationMode = ANIMATION_MODE_ANIMATE_IMAGE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue