Showimage (#351)

* support for interval in showImage, showFrame

* added default arg to showFrame
This commit is contained in:
Peli de Halleux 2017-02-03 20:39:18 -08:00 committed by GitHub
parent 638e1d3c53
commit 49ecac6332
4 changed files with 14 additions and 13 deletions

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.7.55",
"version": "0.8.0",
"description": "micro:bit target for PXT",
"keywords": [
"JavaScript",

View File

@ -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 {