support for interval in "show icon", "show arrow"
This commit is contained in:
parent
0d4c5e9630
commit
fb5a8cf64d
@ -6,6 +6,12 @@ Shows the selected arrow on the LED screen
|
|||||||
basic.showArrow(ArrowNames.North)
|
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
|
### Example
|
||||||
|
|
||||||
This program shows all eight arrows.
|
This program shows all eight arrows.
|
||||||
|
@ -6,6 +6,11 @@ Shows the selected icon on the LED screen
|
|||||||
basic.showIcon(IconNames.Heart)
|
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
|
### Example
|
||||||
|
|
||||||
This program shows a happy face and then a sad face with the ``show icon`` function, with a one second pause in between.
|
This program shows a happy face and then a sad face with the ``show icon`` function, with a one second pause in between.
|
||||||
|
@ -36,7 +36,12 @@
|
|||||||
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
||||||
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
||||||
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
|
"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": "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": "Draws an image on the LED screen.",
|
||||||
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
||||||
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
||||||
|
@ -191,6 +191,7 @@
|
|||||||
"basic.clearScreen|block": "clear screen",
|
"basic.clearScreen|block": "clear screen",
|
||||||
"basic.forever|block": "forever",
|
"basic.forever|block": "forever",
|
||||||
"basic.pause|block": "pause (ms) %pause",
|
"basic.pause|block": "pause (ms) %pause",
|
||||||
|
"basic.showArrow|block": "show arrow %i=device_arrow",
|
||||||
"basic.showIcon|block": "show icon %i",
|
"basic.showIcon|block": "show icon %i",
|
||||||
"basic.showLeds|block": "show leds",
|
"basic.showLeds|block": "show leds",
|
||||||
"basic.showNumber|block": "show|number %number",
|
"basic.showNumber|block": "show|number %number",
|
||||||
|
@ -171,6 +171,8 @@ namespace basic {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the selected icon on the LED screen
|
* 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
|
//% weight=90 blockGap=8
|
||||||
//% blockId=basic_show_icon
|
//% blockId=basic_show_icon
|
||||||
@ -180,20 +182,25 @@ namespace basic {
|
|||||||
//% i.fieldEditor="gridpicker"
|
//% i.fieldEditor="gridpicker"
|
||||||
//% i.fieldOptions.width="400" i.fieldOptions.columns="5"
|
//% i.fieldOptions.width="400" i.fieldOptions.columns="5"
|
||||||
//% i.fieldOptions.itemColour="black" i.fieldOptions.tooltips="true"
|
//% 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)
|
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
|
//% weight=50 blockGap=8
|
||||||
//% blockId=basic_show_arrow
|
//% blockId=basic_show_arrow
|
||||||
//% block="show arrow %i=device_arrow"
|
//% block="show arrow %i=device_arrow"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
//% advanced=true
|
//% advanced=true
|
||||||
//% help=basic/show-arrow
|
//% help=basic/show-arrow
|
||||||
export function showArrow(i: number) {
|
export function showArrow(direction: number, interval = 600) {
|
||||||
let res = images.arrowImage(i)
|
let res = images.arrowImage(direction)
|
||||||
res.showImage(0)
|
res.showImage(0, interval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,8 +209,8 @@ namespace images {
|
|||||||
|
|
||||||
//% weight=50 blockGap=8
|
//% weight=50 blockGap=8
|
||||||
//% blockId=builtin_arrow_image block="arrow image %i=device_arrow"
|
//% blockId=builtin_arrow_image block="arrow image %i=device_arrow"
|
||||||
export function arrowImage(i : ArrowNames): Image {
|
export function arrowImage(i: ArrowNames): Image {
|
||||||
switch(i) {
|
switch (i) {
|
||||||
// compass directions
|
// compass directions
|
||||||
case ArrowNames.North: return images.createImage(`
|
case ArrowNames.North: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
@ -267,14 +274,14 @@ namespace images {
|
|||||||
//% blockId=builtin_image block="icon image %i"
|
//% blockId=builtin_image block="icon image %i"
|
||||||
export function iconImage(i: IconNames): Image {
|
export function iconImage(i: IconNames): Image {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case IconNames.Heart : return images.createImage(`
|
case IconNames.Heart: return images.createImage(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`);
|
||||||
|
|
||||||
case IconNames.SmallHeart : return images.createImage(`
|
case IconNames.SmallHeart: return images.createImage(`
|
||||||
. . . . .
|
. . . . .
|
||||||
. # . # .
|
. # . # .
|
||||||
. # # # .
|
. # # # .
|
||||||
|
Loading…
Reference in New Issue
Block a user