Skip to content

Commit 69bf72e

Browse files
committed
Update string print() method to avoid unecessary delays
- First character of string is now printed on next frame update, rather than waiting for an inter-character gap - No unecessary delay after the final character is printed. These changes make the print() semantics align with the image animate() semantics.
1 parent 9dedea4 commit 69bf72e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

source/drivers/MicroBitDisplay.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ void MicroBitDisplay::updateScrollText()
354354
void MicroBitDisplay::updatePrintText()
355355
{
356356
image.print(printingChar < printingText.length() ? printingText.charAt(printingChar) : ' ',0,0);
357-
358-
if (printingChar > printingText.length())
357+
if (printingChar >= printingText.length())
359358
{
360359
animationMode = ANIMATION_MODE_NONE;
361360

@@ -492,7 +491,7 @@ int MicroBitDisplay::printCharAsync(char c, int delay)
492491
if (delay > 0)
493492
{
494493
animationDelay = delay;
495-
animationTick = 0;
494+
animationTick = delay-1;
496495
animationMode = ANIMATION_MODE_PRINT_CHARACTER;
497496
}
498497
}
@@ -533,7 +532,7 @@ int MicroBitDisplay::printAsync(ManagedString s, int delay)
533532
printingChar = 0;
534533
printingText = s;
535534
animationDelay = delay;
536-
animationTick = 0;
535+
animationTick = delay-1;
537536

538537
animationMode = ANIMATION_MODE_PRINT_TEXT;
539538
}
@@ -576,7 +575,7 @@ int MicroBitDisplay::printAsync(MicroBitImage i, int x, int y, int alpha, int de
576575
if(delay > 0)
577576
{
578577
animationDelay = delay;
579-
animationTick = 0;
578+
animationTick = delay-1;
580579
animationMode = ANIMATION_MODE_PRINT_CHARACTER;
581580
}
582581
}

0 commit comments

Comments
 (0)