diff --git a/docs/reference/basic/show-arrow.md b/docs/reference/basic/show-arrow.md index 8c66a12b..07fb8ebd 100644 --- a/docs/reference/basic/show-arrow.md +++ b/docs/reference/basic/show-arrow.md @@ -6,6 +6,12 @@ Shows the selected arrow on the LED screen basic.showArrow(ArrowNames.North) ``` + +### Parameters + +* ``direction``, the identifier of the arrow to display +* ``interval`` (optional), the time to display in milliseconds. default is 400. + ### Example This program shows all eight arrows. diff --git a/docs/reference/basic/show-icon.md b/docs/reference/basic/show-icon.md index 342026a8..fb4bbd25 100644 --- a/docs/reference/basic/show-icon.md +++ b/docs/reference/basic/show-icon.md @@ -6,6 +6,11 @@ Shows the selected icon on the LED screen basic.showIcon(IconNames.Heart) ``` +### Parameters + +* ``icon``, the identifier of the icon to display +* ``interval`` (optional), the time to display in milliseconds. default is 400. + ### Example This program shows a happy face and then a sad face with the ``show icon`` function, with a one second pause in between. diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 09f3897a..5514dd40 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -36,7 +36,12 @@ "basic.showAnimation": "Shows a sequence of LED screens as an animation.", "basic.showAnimation|param|interval": "time in milliseconds between each redraw", "basic.showAnimation|param|leds": "pattern of LEDs to turn on/off", + "basic.showArrow": "Shows an arrow on screent", + "basic.showArrow|param|direction": "the direction of the arrow", + "basic.showArrow|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.", "basic.showIcon": "Draws the selected icon on the LED screen", + "basic.showIcon|param|icon": "the predifined icon id", + "basic.showIcon|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.", "basic.showLeds": "Draws an image on the LED screen.", "basic.showLeds|param|interval": "time in milliseconds to pause after drawing", "basic.showLeds|param|leds": "the pattern of LED to turn on/off", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index bccf6cf7..f60fdbee 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -191,6 +191,7 @@ "basic.clearScreen|block": "clear screen", "basic.forever|block": "forever", "basic.pause|block": "pause (ms) %pause", + "basic.showArrow|block": "show arrow %i=device_arrow", "basic.showIcon|block": "show icon %i", "basic.showLeds|block": "show leds", "basic.showNumber|block": "show|number %number", diff --git a/libs/core/icons.ts b/libs/core/icons.ts index d1bf7137..bd9709b6 100644 --- a/libs/core/icons.ts +++ b/libs/core/icons.ts @@ -171,6 +171,8 @@ namespace basic { /** * Draws the selected icon on the LED screen + * @param icon the predifined icon id + * @param interval the amount of time (milliseconds) to show the icon. Default is 600. */ //% weight=90 blockGap=8 //% blockId=basic_show_icon @@ -180,20 +182,25 @@ namespace basic { //% i.fieldEditor="gridpicker" //% i.fieldOptions.width="400" i.fieldOptions.columns="5" //% i.fieldOptions.itemColour="black" i.fieldOptions.tooltips="true" - export function showIcon(icon: IconNames) { + export function showIcon(icon: IconNames, interval = 600) { let res = images.iconImage(icon) - res.showImage(0) + res.showImage(0, interval) } + /** + * Shows an arrow on screent + * @param direction the direction of the arrow + * @param interval the amount of time (milliseconds) to show the icon. Default is 600. + */ //% weight=50 blockGap=8 - //% blockId=basic_show_arrow + //% blockId=basic_show_arrow //% block="show arrow %i=device_arrow" //% parts="ledmatrix" //% advanced=true //% help=basic/show-arrow - export function showArrow(i: number) { - let res = images.arrowImage(i) - res.showImage(0) + export function showArrow(direction: number, interval = 600) { + let res = images.arrowImage(direction) + res.showImage(0, interval) } } @@ -202,8 +209,8 @@ namespace images { //% weight=50 blockGap=8 //% blockId=builtin_arrow_image block="arrow image %i=device_arrow" - export function arrowImage(i : ArrowNames): Image { - switch(i) { + export function arrowImage(i: ArrowNames): Image { + switch (i) { // compass directions case ArrowNames.North: return images.createImage(` . . # . . @@ -217,7 +224,7 @@ namespace images { . . # . # . # . . . # . . . .`); - case ArrowNames.East: return images.createImage(` + case ArrowNames.East: return images.createImage(` . . # . . . . . # . # # # # # @@ -253,34 +260,34 @@ namespace images { # . # . . . . . # . . . . . #`); - default: return images.createImage(` + default: return images.createImage(` . . . . . . . . . . . . . . . . . . . . . . . . . `); - } + } } - + //% weight=50 blockGap=8 //% blockId=builtin_image block="icon image %i" export function iconImage(i: IconNames): Image { - switch (i) { - case IconNames.Heart : return images.createImage(` + switch (i) { + case IconNames.Heart: return images.createImage(` . # . # . # # # # # # # # # # . # # # . . . # . .`); - case IconNames.SmallHeart : return images.createImage(` + case IconNames.SmallHeart: return images.createImage(` . . . . . . # . # . . # # # . . . # . . . . . . .`); - //faces + //faces case IconNames.Happy: return images.createImage(` . . . . . . # . # . @@ -396,7 +403,7 @@ namespace images { . . # . . # # . # . # # . . #`); - // The following images were designed by Abbie Brooks. + // The following images were designed by Abbie Brooks. case IconNames.TShirt: return images.createImage(` # # . # # # # # # # @@ -475,7 +482,7 @@ namespace images { . # . # . . # # # . . . . . .`); - // animals + // animals case IconNames.Rabbit: return images.createImage(` # . # . . # . # . . @@ -488,7 +495,7 @@ namespace images { # # # # # . # # # . . . # . .`); - // musical notes + // musical notes case IconNames.QuarterNote: return images.createImage(` . . # . . . . # . . @@ -501,7 +508,7 @@ namespace images { . . # . # # # # . . # # # . .`); - // other icons + // other icons case IconNames.Pitchfork: return images.createImage(` # . # . # # . # . # @@ -514,7 +521,7 @@ namespace images { # # . # # . # # # . . . # . .`); - default: return images.createImage(` + default: return images.createImage(` . . . . . . . . . . . . . . .