Move showNumber to TS and call showString (#829)
This commit is contained in:
parent
65286f710c
commit
cabda63108
@ -7,26 +7,6 @@
|
||||
//% color=#0078D7 weight=100 icon="\uf00a"
|
||||
namespace basic {
|
||||
|
||||
/**
|
||||
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
|
||||
* @param interval speed of scroll; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8
|
||||
//% async
|
||||
//% parts="ledmatrix"
|
||||
void showNumber(int value, int interval = 150) {
|
||||
if (interval <= 0)
|
||||
interval = 1;
|
||||
ManagedString t(value);
|
||||
if (value < 0 || value >= 10) {
|
||||
uBit.display.scroll(t, interval);
|
||||
} else {
|
||||
uBit.display.printChar(t.charAt(0), interval * 5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds the pattern of LED to turn on/off
|
||||
|
15
libs/core/basic.ts
Normal file
15
libs/core/basic.ts
Normal file
@ -0,0 +1,15 @@
|
||||
namespace basic {
|
||||
|
||||
/**
|
||||
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
|
||||
* @param interval speed of scroll; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8
|
||||
//% async
|
||||
//% parts="ledmatrix" interval.defl=150
|
||||
export function showNumber(value: number, interval?: number) {
|
||||
showString(value.toString(), interval);
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
"codal.cpp",
|
||||
"images.cpp",
|
||||
"basic.cpp",
|
||||
"basic.ts",
|
||||
"icons.ts",
|
||||
"icons.jres",
|
||||
"input.cpp",
|
||||
|
11
libs/core/shims.d.ts
vendored
11
libs/core/shims.d.ts
vendored
@ -130,17 +130,6 @@ declare interface Image {
|
||||
//% color=#0078D7 weight=100 icon="\uf00a"
|
||||
declare namespace basic {
|
||||
|
||||
/**
|
||||
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
|
||||
* @param interval speed of scroll; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8
|
||||
//% async
|
||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showNumber
|
||||
function showNumber(value: int32, interval?: int32): void;
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds the pattern of LED to turn on/off
|
||||
|
Loading…
Reference in New Issue
Block a user