microbit: BUGFIX - post merge fixes
- MicroBitDisplay::scroll() timing bug - MicroBitDisplay::print() timing bug - MicroBitFiber wait/notify bug
This commit is contained in:
parent
424b825185
commit
72e5a9a6a6
|
@ -314,6 +314,7 @@ void MicroBitDisplay::updateAnimateImage()
|
||||||
if (scrollingImagePosition <= -scrollingImage.getWidth() + (MICROBIT_DISPLAY_WIDTH + scrollingImageStride) && scrollingImageRendered)
|
if (scrollingImagePosition <= -scrollingImage.getWidth() + (MICROBIT_DISPLAY_WIDTH + scrollingImageStride) && scrollingImageRendered)
|
||||||
{
|
{
|
||||||
animationMode = ANIMATION_MODE_NONE;
|
animationMode = ANIMATION_MODE_NONE;
|
||||||
|
this->clear();
|
||||||
this->sendAnimationCompleteEvent();
|
this->sendAnimationCompleteEvent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -566,6 +567,8 @@ void MicroBitDisplay::scrollAsync(ManagedString s, int delay)
|
||||||
scrollingChar = 0;
|
scrollingChar = 0;
|
||||||
scrollingText = s;
|
scrollingText = s;
|
||||||
|
|
||||||
|
animationDelay = delay;
|
||||||
|
animationTick = 0;
|
||||||
animationMode = ANIMATION_MODE_SCROLL_TEXT;
|
animationMode = ANIMATION_MODE_SCROLL_TEXT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,11 +595,13 @@ void MicroBitDisplay::scrollAsync(MicroBitImage image, int delay, int stride)
|
||||||
if(delay <= 0 )
|
if(delay <= 0 )
|
||||||
delay = MICROBIT_DEFAULT_SCROLL_SPEED;
|
delay = MICROBIT_DEFAULT_SCROLL_SPEED;
|
||||||
|
|
||||||
this->scrollingImagePosition = stride < 0 ? width : -image.getWidth();
|
scrollingImagePosition = stride < 0 ? width : -image.getWidth();
|
||||||
this->scrollingImageStride = stride;
|
scrollingImageStride = stride;
|
||||||
this->scrollingImage = image;
|
scrollingImage = image;
|
||||||
this->scrollingImageRendered = false;
|
scrollingImageRendered = false;
|
||||||
|
|
||||||
|
animationDelay = delay;
|
||||||
|
animationTick = 0;
|
||||||
animationMode = ANIMATION_MODE_SCROLL_IMAGE;
|
animationMode = ANIMATION_MODE_SCROLL_IMAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -692,15 +697,14 @@ void MicroBitDisplay::animateAsync(MicroBitImage image, int delay, int stride, i
|
||||||
if(delay <= 0 )
|
if(delay <= 0 )
|
||||||
delay = MICROBIT_DEFAULT_SCROLL_SPEED;
|
delay = MICROBIT_DEFAULT_SCROLL_SPEED;
|
||||||
|
|
||||||
animationDelay = delay;
|
|
||||||
animationTick = delay-1;
|
|
||||||
|
|
||||||
//calculate starting position which is offset by the stride
|
//calculate starting position which is offset by the stride
|
||||||
scrollingImagePosition = (startingPosition == MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS) ? MICROBIT_DISPLAY_WIDTH + stride : startingPosition;
|
scrollingImagePosition = (startingPosition == MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS) ? MICROBIT_DISPLAY_WIDTH + stride : startingPosition;
|
||||||
scrollingImageStride = stride;
|
scrollingImageStride = stride;
|
||||||
scrollingImage = image;
|
scrollingImage = image;
|
||||||
scrollingImageRendered = false;
|
scrollingImageRendered = false;
|
||||||
|
|
||||||
|
animationDelay = delay;
|
||||||
|
animationTick = delay-1;
|
||||||
animationMode = ANIMATION_MODE_ANIMATE_IMAGE;
|
animationMode = ANIMATION_MODE_ANIMATE_IMAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,6 +163,10 @@ void scheduler_init()
|
||||||
idleFiber->tcb.SP = CORTEX_M0_STACK_BASE - 0x04;
|
idleFiber->tcb.SP = CORTEX_M0_STACK_BASE - 0x04;
|
||||||
idleFiber->tcb.LR = (uint32_t) &idle_task;
|
idleFiber->tcb.LR = (uint32_t) &idle_task;
|
||||||
|
|
||||||
|
// Register to receive events in the NOTIFY channel - this is used to implement wait-notify semantics
|
||||||
|
uBit.MessageBus.listen(MICROBIT_ID_NOTIFY, MICROBIT_EVT_ANY, scheduler_event, MESSAGE_BUS_LISTENER_IMMEDIATE);
|
||||||
|
uBit.MessageBus.listen(MICROBIT_ID_NOTIFY_ONE, MICROBIT_EVT_ANY, scheduler_event, MESSAGE_BUS_LISTENER_IMMEDIATE);
|
||||||
|
|
||||||
// Flag that we now have a scheduler running
|
// Flag that we now have a scheduler running
|
||||||
uBit.flags |= MICROBIT_FLAG_SCHEDULER_RUNNING;
|
uBit.flags |= MICROBIT_FLAG_SCHEDULER_RUNNING;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +240,8 @@ void scheduler_event(MicroBitEvent evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unregister this event, as we've woken up all the fibers with this match.
|
// Unregister this event, as we've woken up all the fibers with this match.
|
||||||
uBit.MessageBus.ignore(evt.source, evt.value, scheduler_event);
|
if (evt.source != MICROBIT_ID_NOTIFY && evt.source != MICROBIT_ID_NOTIFY_ONE)
|
||||||
|
uBit.MessageBus.ignore(evt.source, evt.value, scheduler_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,7 +325,9 @@ void fiber_wait_for_event(uint16_t id, uint16_t value)
|
||||||
queue_fiber(f, &waitQueue);
|
queue_fiber(f, &waitQueue);
|
||||||
|
|
||||||
// Register to receive this event, so we can wake up the fiber when it happens.
|
// Register to receive this event, so we can wake up the fiber when it happens.
|
||||||
uBit.MessageBus.listen(id, value, scheduler_event, MESSAGE_BUS_LISTENER_IMMEDIATE);
|
// Special case for teh notify channel, as we always stay registered for that.
|
||||||
|
if (id != MICROBIT_ID_NOTIFY && id != MICROBIT_ID_NOTIFY_ONE)
|
||||||
|
uBit.MessageBus.listen(id, value, scheduler_event, MESSAGE_BUS_LISTENER_IMMEDIATE);
|
||||||
|
|
||||||
// Finally, enter the scheduler.
|
// Finally, enter the scheduler.
|
||||||
schedule();
|
schedule();
|
||||||
|
|
Loading…
Reference in New Issue