pxt-calliope/libs/microbit/basic.ts

84 lines
2.9 KiB
TypeScript
Raw Normal View History

2016-03-10 23:01:04 +01:00
/**
* Provides access to basic micro:bit functionality.
*/
//% color=190 weight=100
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
*/
2016-03-22 06:13:39 +01:00
//% help=basic/show-number
2016-03-10 23:01:04 +01:00
//% weight=96
//% shim=micro_bit::scrollNumber
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
//% async
export function showNumber(value: number, interval: number = 150): void { }
/**
* Draws an image on the LED screen.
* @param leds TODO
* @param interval TODO
*/
2016-03-22 06:13:39 +01:00
//% help=basic/show-leds
2016-03-10 23:01:04 +01:00
//% weight=95 blockGap=8
//% shim=micro_bit::showLeds
//% imageLiteral=1 async
//% blockId=device_show_leds
//% block="show leds" icon="\uf00a"
export function showLeds(leds: string, interval: number = 400): void { }
/**
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
* @param text the text to scroll on the screen, eg: "Hello!"
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
*/
2016-03-22 06:13:39 +01:00
//% help=basic/show-string
2016-03-10 23:01:04 +01:00
//% weight=87 blockGap=8
//% shim=micro_bit::scrollString async
//% block="show|string %text" icon="\uf031"
//% async
//% blockId=device_print_message
export function showString(text: string, interval: number = 150): void { }
/**
* Turn off all LEDs
*/
2016-03-22 06:13:39 +01:00
//% help=basic/clear-screen weight=79
2016-03-10 23:01:04 +01:00
//% shim=micro_bit::clearScreen
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
export function clearScreen(): void { }
/**
* Shows a sequence of LED screens as an animation.
* @param leds TODO
* @param interval TODO
*/
2016-03-22 06:13:39 +01:00
//% help=basic/show-animation shim=micro_bit::showAnimation imageLiteral=1 async
2016-03-10 23:01:04 +01:00
export function showAnimation(leds: string, interval: number = 400): void { }
/**
* Draws an image on the LED screen.
* @param leds TODO
*/
2016-03-22 06:13:39 +01:00
//% help=basic/plot-leds weight=80 shim=micro_bit::plotLeds imageLiteral=1
2016-03-10 23:01:04 +01:00
export function plotLeds(leds: string): void { }
/**
* Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body TODO
*/
2016-03-22 06:13:39 +01:00
//% help=basic/forever weight=55 blockGap=8
2016-03-10 23:01:04 +01:00
//% blockId=device_forever block="forever" icon="\uf01e" shim=micro_bit::forever
export function forever(body: () => void): void { }
/**
* Pause for the specified time in milliseconds
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
*/
2016-03-22 06:13:39 +01:00
//% help=basic/pause weight=54
2016-03-10 23:01:04 +01:00
//% shim=micro_bit::pause async block="pause (ms) %pause"
//% blockId=device_pause icon="\uf110"
export function pause(ms: number): void { }
}