From b1fd48882c4fa36d739ebe3afc5a59835c6199dd Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 3 Feb 2017 20:39:18 -0800 Subject: [PATCH] merged from microbit --- libs/core/images.cpp | 10 +++++----- libs/core/shims.d.ts | 8 ++++---- sim/state/ledmatrix.ts | 7 ++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/libs/core/images.cpp b/libs/core/images.cpp index 6e6fc286..45c9eb35 100644 --- a/libs/core/images.cpp +++ b/libs/core/images.cpp @@ -43,9 +43,9 @@ namespace ImageMethods { */ //% help=images/show-image weight=80 blockNamespace=images //% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8 - //% parts="ledmatrix" - void showImage(Image sprite, int xOffset) { - uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0); + //% parts="ledmatrix" async + void showImage(Image sprite, int xOffset, int interval = 400) { + uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0, interval); } /** @@ -150,7 +150,7 @@ namespace ImageMethods { */ //% weight=70 help=images/show-frame //% parts="ledmatrix" - void showFrame(Image i, int frame) { - showImage(i, frame * 5); + void showFrame(Image i, int frame, int interval = 400) { + showImage(i, frame * 5, interval); } } diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index dfd6a74d..e2f09c7b 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -40,8 +40,8 @@ declare interface Image { */ //% help=images/show-image weight=80 blockNamespace=images //% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8 - //% parts="ledmatrix" shim=ImageMethods::showImage - showImage(xOffset: number): void; + //% parts="ledmatrix" async interval.defl=400 shim=ImageMethods::showImage + showImage(xOffset: number, interval?: number): void; /** * Draws the ``index``-th frame of the image on the screen. @@ -118,8 +118,8 @@ declare interface Image { * @param frame TODO */ //% weight=70 help=images/show-frame - //% parts="ledmatrix" shim=ImageMethods::showFrame - showFrame(frame: number): void; + //% parts="ledmatrix" interval.defl=400 shim=ImageMethods::showFrame + showFrame(frame: number, interval?: number): void; } diff --git a/sim/state/ledmatrix.ts b/sim/state/ledmatrix.ts index c2e628f9..e105953c 100644 --- a/sim/state/ledmatrix.ts +++ b/sim/state/ledmatrix.ts @@ -129,10 +129,11 @@ namespace pxsim.images { } namespace pxsim.ImageMethods { - export function showImage(leds: Image, offset: number) { + export function showImage(leds: Image, offset: number, interval: number) { pxtrt.nullCheck(leds) leds.copyTo(offset, 5, board().ledMatrixState.image, 0) runtime.queueDisplayUpdate() + basic.pause(interval); } export function plotImage(leds: Image, offset: number): void { @@ -155,8 +156,8 @@ namespace pxsim.ImageMethods { ImageMethods.plotImage(leds, frame * Image.height); } - export function showFrame(leds: Image, frame: number) { - ImageMethods.showImage(leds, frame * Image.height); + export function showFrame(leds: Image, frame: number, interval: number) { + ImageMethods.showImage(leds, frame * Image.height, interval); } export function pixel(leds: Image, x: number, y: number): number {