Merge branch 'master' of https://github.com/Microsoft/pxt-microbit
This commit is contained in:
commit
214ff25995
|
@ -32,6 +32,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-io-pin-service
|
//% help=bluetooth/start-io-pin-service
|
||||||
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
|
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void startIOPinService() {
|
void startIOPinService() {
|
||||||
new MicroBitIOPinService(*uBit.ble, uBit.io);
|
new MicroBitIOPinService(*uBit.ble, uBit.io);
|
||||||
}
|
}
|
||||||
|
@ -41,6 +42,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-led-service
|
//% help=bluetooth/start-led-service
|
||||||
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
|
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void startLEDService() {
|
void startLEDService() {
|
||||||
new MicroBitLEDService(*uBit.ble, uBit.display);
|
new MicroBitLEDService(*uBit.ble, uBit.display);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +52,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-temperature-service
|
//% help=bluetooth/start-temperature-service
|
||||||
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
|
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void startTemperatureService() {
|
void startTemperatureService() {
|
||||||
new MicroBitTemperatureService(*uBit.ble, uBit.thermometer);
|
new MicroBitTemperatureService(*uBit.ble, uBit.thermometer);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +62,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-magnetometer-service
|
//% help=bluetooth/start-magnetometer-service
|
||||||
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
|
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void startMagnetometerService() {
|
void startMagnetometerService() {
|
||||||
new MicroBitMagnetometerService(*uBit.ble, uBit.compass);
|
new MicroBitMagnetometerService(*uBit.ble, uBit.compass);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +72,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-accelerometer-service
|
//% help=bluetooth/start-accelerometer-service
|
||||||
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
|
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void startAccelerometerService() {
|
void startAccelerometerService() {
|
||||||
new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
|
new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
|
||||||
}
|
}
|
||||||
|
@ -77,6 +82,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-button-service
|
//% help=bluetooth/start-button-service
|
||||||
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
|
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void startButtonService() {
|
void startButtonService() {
|
||||||
new MicroBitButtonService(*uBit.ble);
|
new MicroBitButtonService(*uBit.ble);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +92,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-uart-service
|
//% help=bluetooth/start-uart-service
|
||||||
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8
|
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void startUartService() {
|
void startUartService() {
|
||||||
if (uart) return;
|
if (uart) return;
|
||||||
// 61 octet buffer size is 3 x (MTU - 3) + 1
|
// 61 octet buffer size is 3 x (MTU - 3) + 1
|
||||||
|
@ -99,6 +106,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/uart-write
|
//% help=bluetooth/uart-write
|
||||||
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8
|
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void uartWrite(StringData *data) {
|
void uartWrite(StringData *data) {
|
||||||
startUartService();
|
startUartService();
|
||||||
uart->send(ManagedString(data));
|
uart->send(ManagedString(data));
|
||||||
|
@ -109,6 +117,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/uart-read
|
//% help=bluetooth/uart-read
|
||||||
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8
|
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
StringData* uartRead(StringData *del) {
|
StringData* uartRead(StringData *del) {
|
||||||
startUartService();
|
startUartService();
|
||||||
return uart->readUntil(ManagedString(del)).leakData();
|
return uart->readUntil(ManagedString(del)).leakData();
|
||||||
|
@ -119,6 +128,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% blockId="bluetooth_uart_delimiter_conv" block="%del"
|
//% blockId="bluetooth_uart_delimiter_conv" block="%del"
|
||||||
//% weight=1
|
//% weight=1
|
||||||
|
//% parts="bluetooth"
|
||||||
StringData* delimiters(Delimiters del) {
|
StringData* delimiters(Delimiters del) {
|
||||||
ManagedString c("\n\n,$:.#"[max(0, min(6, (int)del))]);
|
ManagedString c("\n\n,$:.#"[max(0, min(6, (int)del))]);
|
||||||
return c.leakData();
|
return c.leakData();
|
||||||
|
@ -129,6 +139,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/on-bluetooth-connected weight=20
|
//% help=bluetooth/on-bluetooth-connected weight=20
|
||||||
//% blockId=bluetooth_on_connected block="on bluetooth connected" blockGap=8
|
//% blockId=bluetooth_on_connected block="on bluetooth connected" blockGap=8
|
||||||
|
//% parts="bluetooth"
|
||||||
void onBluetoothConnected(Action body) {
|
void onBluetoothConnected(Action body) {
|
||||||
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, body);
|
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, body);
|
||||||
}
|
}
|
||||||
|
@ -139,6 +150,7 @@ namespace bluetooth {
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/on-bluetooth-disconnected weight=19
|
//% help=bluetooth/on-bluetooth-disconnected weight=19
|
||||||
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected"
|
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected"
|
||||||
|
//% parts="bluetooth"
|
||||||
void onBluetoothDisconnected(Action body) {
|
void onBluetoothDisconnected(Action body) {
|
||||||
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body);
|
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body);
|
||||||
}
|
}
|
||||||
|
|
36
libs/microbit-bluetooth/shims.d.ts
vendored
36
libs/microbit-bluetooth/shims.d.ts
vendored
|
@ -11,70 +11,80 @@ declare namespace bluetooth {
|
||||||
* Starts the Bluetooth IO pin service.
|
* Starts the Bluetooth IO pin service.
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-io-pin-service
|
//% help=bluetooth/start-io-pin-service
|
||||||
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8 shim=bluetooth::startIOPinService
|
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::startIOPinService
|
||||||
function startIOPinService(): void;
|
function startIOPinService(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the Bluetooth LED service
|
* Starts the Bluetooth LED service
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-led-service
|
//% help=bluetooth/start-led-service
|
||||||
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8 shim=bluetooth::startLEDService
|
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::startLEDService
|
||||||
function startLEDService(): void;
|
function startLEDService(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the Bluetooth temperature service
|
* Starts the Bluetooth temperature service
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-temperature-service
|
//% help=bluetooth/start-temperature-service
|
||||||
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8 shim=bluetooth::startTemperatureService
|
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::startTemperatureService
|
||||||
function startTemperatureService(): void;
|
function startTemperatureService(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the Bluetooth magnetometer service
|
* Starts the Bluetooth magnetometer service
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-magnetometer-service
|
//% help=bluetooth/start-magnetometer-service
|
||||||
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8 shim=bluetooth::startMagnetometerService
|
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::startMagnetometerService
|
||||||
function startMagnetometerService(): void;
|
function startMagnetometerService(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the Bluetooth accelerometer service
|
* Starts the Bluetooth accelerometer service
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-accelerometer-service
|
//% help=bluetooth/start-accelerometer-service
|
||||||
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8 shim=bluetooth::startAccelerometerService
|
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::startAccelerometerService
|
||||||
function startAccelerometerService(): void;
|
function startAccelerometerService(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the Bluetooth button service
|
* Starts the Bluetooth button service
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-button-service
|
//% help=bluetooth/start-button-service
|
||||||
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8 shim=bluetooth::startButtonService
|
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::startButtonService
|
||||||
function startButtonService(): void;
|
function startButtonService(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the Bluetooth UART service
|
* Starts the Bluetooth UART service
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/start-uart-service
|
//% help=bluetooth/start-uart-service
|
||||||
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8 shim=bluetooth::startUartService
|
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::startUartService
|
||||||
function startUartService(): void;
|
function startUartService(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
|
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/uart-write
|
//% help=bluetooth/uart-write
|
||||||
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8 shim=bluetooth::uartWrite
|
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::uartWrite
|
||||||
function uartWrite(data: string): void;
|
function uartWrite(data: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.
|
* Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/uart-read
|
//% help=bluetooth/uart-read
|
||||||
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8 shim=bluetooth::uartRead
|
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::uartRead
|
||||||
function uartRead(del: string): string;
|
function uartRead(del: string): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the delimiter corresponding string
|
* Returns the delimiter corresponding string
|
||||||
*/
|
*/
|
||||||
//% blockId="bluetooth_uart_delimiter_conv" block="%del"
|
//% blockId="bluetooth_uart_delimiter_conv" block="%del"
|
||||||
//% weight=1 shim=bluetooth::delimiters
|
//% weight=1
|
||||||
|
//% parts="bluetooth" shim=bluetooth::delimiters
|
||||||
function delimiters(del: Delimiters): string;
|
function delimiters(del: Delimiters): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +92,8 @@ declare namespace bluetooth {
|
||||||
* @param body Code to run when a Bluetooth connection is established
|
* @param body Code to run when a Bluetooth connection is established
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/on-bluetooth-connected weight=20
|
//% help=bluetooth/on-bluetooth-connected weight=20
|
||||||
//% blockId=bluetooth_on_connected block="on bluetooth connected" blockGap=8 shim=bluetooth::onBluetoothConnected
|
//% blockId=bluetooth_on_connected block="on bluetooth connected" blockGap=8
|
||||||
|
//% parts="bluetooth" shim=bluetooth::onBluetoothConnected
|
||||||
function onBluetoothConnected(body: () => void): void;
|
function onBluetoothConnected(body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +101,8 @@ declare namespace bluetooth {
|
||||||
* @param body Code to run when a Bluetooth connection is lost
|
* @param body Code to run when a Bluetooth connection is lost
|
||||||
*/
|
*/
|
||||||
//% help=bluetooth/on-bluetooth-disconnected weight=19
|
//% help=bluetooth/on-bluetooth-disconnected weight=19
|
||||||
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected" shim=bluetooth::onBluetoothDisconnected
|
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected"
|
||||||
|
//% parts="bluetooth" shim=bluetooth::onBluetoothDisconnected
|
||||||
function onBluetoothDisconnected(body: () => void): void;
|
function onBluetoothDisconnected(body: () => void): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace basic {
|
||||||
//% weight=96
|
//% weight=96
|
||||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||||
//% async
|
//% async
|
||||||
|
//% parts="ledmatrix"
|
||||||
void showNumber(int value, int interval = 150) {
|
void showNumber(int value, int interval = 150) {
|
||||||
if (interval < 0)
|
if (interval < 0)
|
||||||
return;
|
return;
|
||||||
|
@ -37,6 +38,7 @@ namespace basic {
|
||||||
//% imageLiteral=1 async
|
//% imageLiteral=1 async
|
||||||
//% blockId=device_show_leds
|
//% blockId=device_show_leds
|
||||||
//% block="show leds" icon="\uf00a"
|
//% block="show leds" icon="\uf00a"
|
||||||
|
//% parts="ledmatrix"
|
||||||
void showLeds(ImageLiteral leds, int interval = 400) {
|
void showLeds(ImageLiteral leds, int interval = 400) {
|
||||||
uBit.display.print(MicroBitImage(imageBytes(leds)), 0, 0, 0, interval);
|
uBit.display.print(MicroBitImage(imageBytes(leds)), 0, 0, 0, interval);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +53,7 @@ namespace basic {
|
||||||
//% block="show|string %text" icon="\uf031"
|
//% block="show|string %text" icon="\uf031"
|
||||||
//% async
|
//% async
|
||||||
//% blockId=device_print_message
|
//% blockId=device_print_message
|
||||||
|
//% parts="ledmatrix"
|
||||||
void showString(StringData *text, int interval = 150) {
|
void showString(StringData *text, int interval = 150) {
|
||||||
if (interval < 0)
|
if (interval < 0)
|
||||||
return;
|
return;
|
||||||
|
@ -71,6 +74,7 @@ namespace basic {
|
||||||
*/
|
*/
|
||||||
//% help=basic/clear-screen weight=79
|
//% help=basic/clear-screen weight=79
|
||||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||||
|
//% parts="ledmatrix"
|
||||||
void clearScreen() {
|
void clearScreen() {
|
||||||
uBit.display.image.clear();
|
uBit.display.image.clear();
|
||||||
}
|
}
|
||||||
|
@ -81,6 +85,7 @@ namespace basic {
|
||||||
* @param interval time in milliseconds between each redraw
|
* @param interval time in milliseconds between each redraw
|
||||||
*/
|
*/
|
||||||
//% help=basic/show-animation imageLiteral=1 async
|
//% help=basic/show-animation imageLiteral=1 async
|
||||||
|
//% parts="ledmatrix"
|
||||||
void showAnimation(ImageLiteral leds, int interval = 400) {
|
void showAnimation(ImageLiteral leds, int interval = 400) {
|
||||||
uBit.display.animate(MicroBitImage(imageBytes(leds)), interval, 5, 0);
|
uBit.display.animate(MicroBitImage(imageBytes(leds)), interval, 5, 0);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +95,7 @@ namespace basic {
|
||||||
* @param leds pattern of LEDs to turn on/off
|
* @param leds pattern of LEDs to turn on/off
|
||||||
*/
|
*/
|
||||||
//% help=basic/plot-leds weight=80
|
//% help=basic/plot-leds weight=80
|
||||||
|
//% parts="ledmatrix"
|
||||||
void plotLeds(ImageLiteral leds) {
|
void plotLeds(ImageLiteral leds) {
|
||||||
MicroBitImage i(imageBytes(leds));
|
MicroBitImage i(imageBytes(leds));
|
||||||
uBit.display.print(i, 0, 0, 0, 0);
|
uBit.display.print(i, 0, 0, 0, 0);
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace game {
|
||||||
*/
|
*/
|
||||||
//% weight=60
|
//% weight=60
|
||||||
//% blockId=game_create_sprite block="create sprite at|x: %x|y: %y"
|
//% blockId=game_create_sprite block="create sprite at|x: %x|y: %y"
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function createSprite(x: number, y: number): LedSprite {
|
export function createSprite(x: number, y: number): LedSprite {
|
||||||
init();
|
init();
|
||||||
let p = new LedSprite(x, y);
|
let p = new LedSprite(x, y);
|
||||||
|
@ -64,6 +65,7 @@ namespace game {
|
||||||
*/
|
*/
|
||||||
//% weight=10 help=game/add-score
|
//% weight=10 help=game/add-score
|
||||||
//% blockId=game_add_score block="change score by|%points" blockGap=8
|
//% blockId=game_add_score block="change score by|%points" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function addScore(points: number): void {
|
export function addScore(points: number): void {
|
||||||
setScore(_score + points);
|
setScore(_score + points);
|
||||||
control.inBackground(() => {
|
control.inBackground(() => {
|
||||||
|
@ -82,6 +84,7 @@ namespace game {
|
||||||
*/
|
*/
|
||||||
//% weight=9 help=game/start-countdown
|
//% weight=9 help=game/start-countdown
|
||||||
//% blockId=game_start_countdown block="start countdown|(ms) %duration" blockGap=8
|
//% blockId=game_start_countdown block="start countdown|(ms) %duration" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function startCountdown(ms: number): void {
|
export function startCountdown(ms: number): void {
|
||||||
if (checkStart()) {
|
if (checkStart()) {
|
||||||
basic.showAnimation(`1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0
|
basic.showAnimation(`1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0
|
||||||
|
@ -104,6 +107,7 @@ namespace game {
|
||||||
*/
|
*/
|
||||||
//% weight=8 help=game/game-over
|
//% weight=8 help=game/game-over
|
||||||
//% blockId=game_game_over block="game over"
|
//% blockId=game_game_over block="game over"
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function gameOver(): void {
|
export function gameOver(): void {
|
||||||
if (!_isGameOver) {
|
if (!_isGameOver) {
|
||||||
_isGameOver = true;
|
_isGameOver = true;
|
||||||
|
@ -194,6 +198,7 @@ namespace game {
|
||||||
* @param life TODO
|
* @param life TODO
|
||||||
*/
|
*/
|
||||||
//% weight=10
|
//% weight=10
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function removeLife(life: number): void {
|
export function removeLife(life: number): void {
|
||||||
setLife(_life - life);
|
setLife(_life - life);
|
||||||
control.inBackground(() => {
|
control.inBackground(() => {
|
||||||
|
@ -210,6 +215,7 @@ namespace game {
|
||||||
* Increments the level and display a message.
|
* Increments the level and display a message.
|
||||||
*/
|
*/
|
||||||
//% weight=10
|
//% weight=10
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function levelUp(): void {
|
export function levelUp(): void {
|
||||||
_level = _level + 1;
|
_level = _level + 1;
|
||||||
basic.showString("LEVEL:", 150);
|
basic.showString("LEVEL:", 150);
|
||||||
|
@ -246,6 +252,7 @@ namespace game {
|
||||||
* Displays the score on the screen.
|
* Displays the score on the screen.
|
||||||
*/
|
*/
|
||||||
//% weight=60
|
//% weight=60
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function showScore(): void {
|
export function showScore(): void {
|
||||||
basic.showString(" SCORE ", 100);
|
basic.showString(" SCORE ", 100);
|
||||||
basic.showNumber(_score, 150);
|
basic.showNumber(_score, 150);
|
||||||
|
@ -303,6 +310,7 @@ namespace game {
|
||||||
*/
|
*/
|
||||||
//% weight=50
|
//% weight=50
|
||||||
//% blockId=game_move_sprite block="%sprite|move by %leds" blockGap=8
|
//% blockId=game_move_sprite block="%sprite|move by %leds" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
public move(leds: number): void {
|
public move(leds: number): void {
|
||||||
if (this._dir == 0) {
|
if (this._dir == 0) {
|
||||||
this._y = this._y - leds;
|
this._y = this._y - leds;
|
||||||
|
@ -336,6 +344,7 @@ namespace game {
|
||||||
* @param x TODO
|
* @param x TODO
|
||||||
* @param y TODO
|
* @param y TODO
|
||||||
*/
|
*/
|
||||||
|
//% parts="ledmatrix"
|
||||||
public goTo(x: number, y: number): void {
|
public goTo(x: number, y: number): void {
|
||||||
this._x = x;
|
this._x = x;
|
||||||
this._y = y;
|
this._y = y;
|
||||||
|
@ -350,6 +359,7 @@ namespace game {
|
||||||
*/
|
*/
|
||||||
//% weight=18
|
//% weight=18
|
||||||
//% blockId=game_sprite_bounce block="%sprite|if on edge, bounce"
|
//% blockId=game_sprite_bounce block="%sprite|if on edge, bounce"
|
||||||
|
//% parts="ledmatrix"
|
||||||
public ifOnEdgeBounce(): void {
|
public ifOnEdgeBounce(): void {
|
||||||
if (this._dir == 0 && this._y == 0) {
|
if (this._dir == 0 && this._y == 0) {
|
||||||
this._dir = 180;
|
this._dir = 180;
|
||||||
|
@ -484,6 +494,7 @@ namespace game {
|
||||||
* @param this TODO
|
* @param this TODO
|
||||||
* @param degrees TODO
|
* @param degrees TODO
|
||||||
*/
|
*/
|
||||||
|
//% parts="ledmatrix"
|
||||||
public setDirection(degrees: number): void {
|
public setDirection(degrees: number): void {
|
||||||
this._dir = ((degrees / 45) % 8) * 45;
|
this._dir = ((degrees / 45) % 8) * 45;
|
||||||
if (this._dir <= -180) {
|
if (this._dir <= -180) {
|
||||||
|
@ -596,6 +607,7 @@ namespace game {
|
||||||
* @param this TODO
|
* @param this TODO
|
||||||
* @param brightness TODO
|
* @param brightness TODO
|
||||||
*/
|
*/
|
||||||
|
//% parts="ledmatrix"
|
||||||
public setBrightness(brightness: number): void {
|
public setBrightness(brightness: number): void {
|
||||||
this._brightness = Math.clamp(0, 255, brightness);
|
this._brightness = Math.clamp(0, 255, brightness);
|
||||||
plot();
|
plot();
|
||||||
|
@ -664,6 +676,7 @@ namespace game {
|
||||||
}
|
}
|
||||||
|
|
||||||
//% weight=-1
|
//% weight=-1
|
||||||
|
//% parts="ledmatrix"
|
||||||
public _plot(now: number) {
|
public _plot(now: number) {
|
||||||
let ps = this
|
let ps = this
|
||||||
if (ps._brightness > 0) {
|
if (ps._brightness > 0) {
|
||||||
|
@ -701,6 +714,7 @@ namespace game {
|
||||||
/**
|
/**
|
||||||
* Plots the current sprites on the screen
|
* Plots the current sprites on the screen
|
||||||
*/
|
*/
|
||||||
|
//% parts="ledmatrix"
|
||||||
function plot(): void {
|
function plot(): void {
|
||||||
if (game.isGameOver()) {
|
if (game.isGameOver()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace images {
|
||||||
*/
|
*/
|
||||||
//% weight=75 help=images/create-image
|
//% weight=75 help=images/create-image
|
||||||
//% blockId=device_build_image block="create image"
|
//% blockId=device_build_image block="create image"
|
||||||
|
//% parts="ledmatrix"
|
||||||
Image createImage(ImageLiteral leds) {
|
Image createImage(ImageLiteral leds) {
|
||||||
return MicroBitImage(imageBytes(leds)).clone().leakData();
|
return MicroBitImage(imageBytes(leds)).clone().leakData();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +20,7 @@ namespace images {
|
||||||
*/
|
*/
|
||||||
//% weight=74 help=images/create-big-image
|
//% weight=74 help=images/create-big-image
|
||||||
//% blockId=device_build_big_image block="create big image" imageLiteral=2
|
//% blockId=device_build_big_image block="create big image" imageLiteral=2
|
||||||
|
//% parts="ledmatrix"
|
||||||
Image createBigImage(ImageLiteral leds) {
|
Image createBigImage(ImageLiteral leds) {
|
||||||
return createImage(leds);
|
return createImage(leds);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +31,7 @@ namespace ImageMethods {
|
||||||
* Plots the image at a given column to the screen
|
* Plots the image at a given column to the screen
|
||||||
*/
|
*/
|
||||||
//% help=images/plot-image
|
//% help=images/plot-image
|
||||||
|
//% parts="ledmatrix"
|
||||||
void plotImage(Image i, int xOffset = 0) {
|
void plotImage(Image i, int xOffset = 0) {
|
||||||
uBit.display.print(MicroBitImage(i), -xOffset, 0, 0, 0);
|
uBit.display.print(MicroBitImage(i), -xOffset, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +42,7 @@ namespace ImageMethods {
|
||||||
*/
|
*/
|
||||||
//% help=images/show-image weight=80 blockNamespace=images
|
//% help=images/show-image weight=80 blockNamespace=images
|
||||||
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
void showImage(Image sprite, int xOffset) {
|
void showImage(Image sprite, int xOffset) {
|
||||||
uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0);
|
uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +52,7 @@ namespace ImageMethods {
|
||||||
* @param xOffset column index to start displaying the image
|
* @param xOffset column index to start displaying the image
|
||||||
*/
|
*/
|
||||||
//% help=images/plot-frame weight=80
|
//% help=images/plot-frame weight=80
|
||||||
|
//% parts="ledmatrix"
|
||||||
void plotFrame(Image i, int xOffset) {
|
void plotFrame(Image i, int xOffset) {
|
||||||
// TODO showImage() used in original implementation
|
// TODO showImage() used in original implementation
|
||||||
plotImage(i, xOffset * 5);
|
plotImage(i, xOffset * 5);
|
||||||
|
@ -60,6 +65,7 @@ namespace ImageMethods {
|
||||||
*/
|
*/
|
||||||
//% help=images/show-image weight=79 async blockNamespace=images
|
//% help=images/show-image weight=79 async blockNamespace=images
|
||||||
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
void scrollImage(Image id, int frameOffset, int interval) {
|
void scrollImage(Image id, int frameOffset, int interval) {
|
||||||
MicroBitImage i(id);
|
MicroBitImage i(id);
|
||||||
if (i.getWidth() <= 5)
|
if (i.getWidth() <= 5)
|
||||||
|
@ -73,6 +79,7 @@ namespace ImageMethods {
|
||||||
* Sets all pixels off.
|
* Sets all pixels off.
|
||||||
*/
|
*/
|
||||||
//% help=images/clear
|
//% help=images/clear
|
||||||
|
//% parts="ledmatrix"
|
||||||
void clear(Image i) {
|
void clear(Image i) {
|
||||||
MicroBitImage(i).clear();
|
MicroBitImage(i).clear();
|
||||||
}
|
}
|
||||||
|
@ -81,6 +88,7 @@ namespace ImageMethods {
|
||||||
* Sets a specific pixel brightness at a given position
|
* Sets a specific pixel brightness at a given position
|
||||||
*/
|
*/
|
||||||
//%
|
//%
|
||||||
|
//% parts="ledmatrix"
|
||||||
void setPixelBrightness(Image i, int x, int y, int value) {
|
void setPixelBrightness(Image i, int x, int y, int value) {
|
||||||
MicroBitImage(i).setPixelValue(x, y, value);
|
MicroBitImage(i).setPixelValue(x, y, value);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +98,7 @@ namespace ImageMethods {
|
||||||
* Gets the pixel brightness ([0..255]) at a given position
|
* Gets the pixel brightness ([0..255]) at a given position
|
||||||
*/
|
*/
|
||||||
//%
|
//%
|
||||||
|
//% parts="ledmatrix"
|
||||||
int pixelBrightness(Image i, int x, int y) {
|
int pixelBrightness(Image i, int x, int y) {
|
||||||
int pix = MicroBitImage(i).getPixelValue(x, y);
|
int pix = MicroBitImage(i).getPixelValue(x, y);
|
||||||
if (pix < 0) return 0;
|
if (pix < 0) return 0;
|
||||||
|
@ -120,6 +129,7 @@ namespace ImageMethods {
|
||||||
* @param value TODO
|
* @param value TODO
|
||||||
*/
|
*/
|
||||||
//% help=images/set-pixel
|
//% help=images/set-pixel
|
||||||
|
//% parts="ledmatrix"
|
||||||
void setPixel(Image i, int x, int y, bool value) {
|
void setPixel(Image i, int x, int y, bool value) {
|
||||||
setPixelBrightness(i, x, y, value ? 255 : 0);
|
setPixelBrightness(i, x, y, value ? 255 : 0);
|
||||||
}
|
}
|
||||||
|
@ -130,6 +140,7 @@ namespace ImageMethods {
|
||||||
* @param y TODO
|
* @param y TODO
|
||||||
*/
|
*/
|
||||||
//% help=images/pixel
|
//% help=images/pixel
|
||||||
|
//% parts="ledmatrix"
|
||||||
bool pixel(Image i, int x, int y) {
|
bool pixel(Image i, int x, int y) {
|
||||||
return pixelBrightness(i, x, y) > 0;
|
return pixelBrightness(i, x, y) > 0;
|
||||||
}
|
}
|
||||||
|
@ -140,6 +151,7 @@ namespace ImageMethods {
|
||||||
* @param frame TODO
|
* @param frame TODO
|
||||||
*/
|
*/
|
||||||
//% weight=70 help=images/show-frame
|
//% weight=70 help=images/show-frame
|
||||||
|
//% parts="ledmatrix"
|
||||||
void showFrame(Image i, int frame) {
|
void showFrame(Image i, int frame) {
|
||||||
showImage(i, frame * 5);
|
showImage(i, frame * 5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ namespace input {
|
||||||
*/
|
*/
|
||||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||||
|
//% parts="buttonpair"
|
||||||
void onButtonPressed(Button button, Action body) {
|
void onButtonPressed(Button button, Action body) {
|
||||||
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
|
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
|
||||||
}
|
}
|
||||||
|
@ -126,6 +127,7 @@ namespace input {
|
||||||
*/
|
*/
|
||||||
//% help=input/on-gesture weight=84 blockGap=8
|
//% help=input/on-gesture weight=84 blockGap=8
|
||||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||||
|
//% parts="accelerometer"
|
||||||
void onGesture(Gesture gesture, Action body) {
|
void onGesture(Gesture gesture, Action body) {
|
||||||
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
||||||
uBit.accelerometer.setRange(4);
|
uBit.accelerometer.setRange(4);
|
||||||
|
@ -173,6 +175,7 @@ namespace input {
|
||||||
//% block="button|%NAME|is pressed"
|
//% block="button|%NAME|is pressed"
|
||||||
//% blockId=device_get_button2
|
//% blockId=device_get_button2
|
||||||
//% icon="\uf192" blockGap=8
|
//% icon="\uf192" blockGap=8
|
||||||
|
//% parts="buttonpair"
|
||||||
bool buttonIsPressed(Button button) {
|
bool buttonIsPressed(Button button) {
|
||||||
if (button == Button::A)
|
if (button == Button::A)
|
||||||
return uBit.buttonA.isPressed();
|
return uBit.buttonA.isPressed();
|
||||||
|
@ -201,6 +204,7 @@ namespace input {
|
||||||
//% help=input/compass-heading
|
//% help=input/compass-heading
|
||||||
//% weight=56 icon="\uf14e"
|
//% weight=56 icon="\uf14e"
|
||||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||||
|
//% parts="compass"
|
||||||
int compassHeading() {
|
int compassHeading() {
|
||||||
return uBit.compass.heading();
|
return uBit.compass.heading();
|
||||||
}
|
}
|
||||||
|
@ -212,6 +216,7 @@ namespace input {
|
||||||
//% weight=55 icon="\uf06d"
|
//% weight=55 icon="\uf06d"
|
||||||
//% help=input/temperature
|
//% help=input/temperature
|
||||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||||
|
//% parts="thermometer"
|
||||||
int temperature() {
|
int temperature() {
|
||||||
return uBit.thermometer.getTemperature();
|
return uBit.thermometer.getTemperature();
|
||||||
}
|
}
|
||||||
|
@ -229,6 +234,7 @@ namespace input {
|
||||||
*/
|
*/
|
||||||
//% help=input/acceleration weight=54 icon="\uf135"
|
//% help=input/acceleration weight=54 icon="\uf135"
|
||||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||||
|
//% parts="accelerometer"
|
||||||
int acceleration(Dimension dimension) {
|
int acceleration(Dimension dimension) {
|
||||||
switch (dimension) {
|
switch (dimension) {
|
||||||
case Dimension::X: return uBit.accelerometer.getX();
|
case Dimension::X: return uBit.accelerometer.getX();
|
||||||
|
@ -245,6 +251,7 @@ namespace input {
|
||||||
*/
|
*/
|
||||||
//% help=input/light-level weight=53
|
//% help=input/light-level weight=53
|
||||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||||
|
//% parts="ledmatrix"
|
||||||
int lightLevel() {
|
int lightLevel() {
|
||||||
return uBit.display.readLightLevel();
|
return uBit.display.readLightLevel();
|
||||||
}
|
}
|
||||||
|
@ -255,6 +262,7 @@ namespace input {
|
||||||
*/
|
*/
|
||||||
//% help=input/rotation weight=52
|
//% help=input/rotation weight=52
|
||||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||||
|
//% parts="accelerometer"
|
||||||
int rotation(Rotation kind) {
|
int rotation(Rotation kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case Rotation::Pitch: return uBit.accelerometer.getPitch();
|
case Rotation::Pitch: return uBit.accelerometer.getPitch();
|
||||||
|
@ -269,6 +277,7 @@ namespace input {
|
||||||
*/
|
*/
|
||||||
//% help=input/magnetic-force weight=51
|
//% help=input/magnetic-force weight=51
|
||||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||||
|
//% parts="compass"
|
||||||
int magneticForce(Dimension dimension) {
|
int magneticForce(Dimension dimension) {
|
||||||
if (!uBit.compass.isCalibrated())
|
if (!uBit.compass.isCalibrated())
|
||||||
uBit.compass.calibrate();
|
uBit.compass.calibrate();
|
||||||
|
@ -304,6 +313,7 @@ namespace input {
|
||||||
//% help=input/set-accelerometer-range
|
//% help=input/set-accelerometer-range
|
||||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||||
//% weight=5
|
//% weight=5
|
||||||
|
//% parts="accelerometer"
|
||||||
void setAccelerometerRange(AcceleratorRange range) {
|
void setAccelerometerRange(AcceleratorRange range) {
|
||||||
uBit.accelerometer.setRange((int)range);
|
uBit.accelerometer.setRange((int)range);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace led {
|
||||||
*/
|
*/
|
||||||
//% help=led/plot weight=78
|
//% help=led/plot weight=78
|
||||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
void plot(int x, int y) {
|
void plot(int x, int y) {
|
||||||
uBit.display.image.setPixelValue(x, y, 1);
|
uBit.display.image.setPixelValue(x, y, 1);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +30,7 @@ namespace led {
|
||||||
*/
|
*/
|
||||||
//% help=led/unplot weight=77
|
//% help=led/unplot weight=77
|
||||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
void unplot(int x, int y) {
|
void unplot(int x, int y) {
|
||||||
uBit.display.image.setPixelValue(x, y, 0);
|
uBit.display.image.setPixelValue(x, y, 0);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +42,7 @@ namespace led {
|
||||||
*/
|
*/
|
||||||
//% help=led/point weight=76
|
//% help=led/point weight=76
|
||||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||||
|
//% parts="ledmatrix"
|
||||||
bool point(int x, int y) {
|
bool point(int x, int y) {
|
||||||
int pix = uBit.display.image.getPixelValue(x, y);
|
int pix = uBit.display.image.getPixelValue(x, y);
|
||||||
return pix > 0;
|
return pix > 0;
|
||||||
|
@ -50,6 +53,7 @@ namespace led {
|
||||||
*/
|
*/
|
||||||
//% help=led/brightness weight=60
|
//% help=led/brightness weight=60
|
||||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
int brightness() {
|
int brightness() {
|
||||||
return uBit.display.getBrightness();
|
return uBit.display.getBrightness();
|
||||||
}
|
}
|
||||||
|
@ -60,6 +64,7 @@ namespace led {
|
||||||
*/
|
*/
|
||||||
//% help=led/set-brightness weight=59
|
//% help=led/set-brightness weight=59
|
||||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||||
|
//% parts="ledmatrix"
|
||||||
void setBrightness(int value) {
|
void setBrightness(int value) {
|
||||||
uBit.display.setBrightness(value);
|
uBit.display.setBrightness(value);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +74,7 @@ namespace led {
|
||||||
*/
|
*/
|
||||||
//% weight=50 help=led/stop-animation
|
//% weight=50 help=led/stop-animation
|
||||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||||
|
//% parts="ledmatrix"
|
||||||
void stopAnimation() {
|
void stopAnimation() {
|
||||||
uBit.display.stopAnimation();
|
uBit.display.stopAnimation();
|
||||||
}
|
}
|
||||||
|
@ -78,6 +84,7 @@ namespace led {
|
||||||
* @param mode TODO
|
* @param mode TODO
|
||||||
*/
|
*/
|
||||||
//% weight=1 help=led/set-display-mode
|
//% weight=1 help=led/set-display-mode
|
||||||
|
//% parts="ledmatrix"
|
||||||
void setDisplayMode(DisplayMode_ mode) {
|
void setDisplayMode(DisplayMode_ mode) {
|
||||||
uBit.display.setDisplayMode((DisplayMode)mode);
|
uBit.display.setDisplayMode((DisplayMode)mode);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +93,7 @@ namespace led {
|
||||||
* Takes a screenshot of the LED screen and returns an image.
|
* Takes a screenshot of the LED screen and returns an image.
|
||||||
*/
|
*/
|
||||||
//% help=led/screenshot
|
//% help=led/screenshot
|
||||||
|
//% parts="ledmatrix"
|
||||||
Image screenshot() {
|
Image screenshot() {
|
||||||
return uBit.display.screenShot().leakData();
|
return uBit.display.screenShot().leakData();
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
//% help=led/plot-bar-graph weight=20
|
//% help=led/plot-bar-graph weight=20
|
||||||
//% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true
|
//% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function plotBarGraph(value: number, high: number): void {
|
export function plotBarGraph(value: number, high: number): void {
|
||||||
let now = input.runningTime();
|
let now = input.runningTime();
|
||||||
serial.writeString(value.toString() + "\r\n");
|
serial.writeString(value.toString() + "\r\n");
|
||||||
|
@ -53,6 +54,7 @@
|
||||||
*/
|
*/
|
||||||
//% help=led/toggle weight=77
|
//% help=led/toggle weight=77
|
||||||
//% blockId=device_led_toggle block="toggle|x %x|y %y" icon="\uf204" blockGap=8
|
//% blockId=device_led_toggle block="toggle|x %x|y %y" icon="\uf204" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function toggle(x: number, y: number): void {
|
export function toggle(x: number, y: number): void {
|
||||||
if (led.point(x, y)) {
|
if (led.point(x, y)) {
|
||||||
led.unplot(x, y);
|
led.unplot(x, y);
|
||||||
|
@ -65,6 +67,7 @@
|
||||||
* Turns all LEDS on
|
* Turns all LEDS on
|
||||||
*/
|
*/
|
||||||
//% help=led/plot-all
|
//% help=led/plot-all
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function plotAll(): void {
|
export function plotAll(): void {
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
for (let j = 0; j < 5; j++) {
|
for (let j = 0; j < 5; j++) {
|
||||||
|
@ -77,6 +80,7 @@
|
||||||
* Inverts the current LED display
|
* Inverts the current LED display
|
||||||
*/
|
*/
|
||||||
//% help=led/toggle-all
|
//% help=led/toggle-all
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function toggleAll(): void {
|
export function toggleAll(): void {
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
for (let j = 0; j < 5; j++) {
|
for (let j = 0; j < 5; j++) {
|
||||||
|
@ -90,6 +94,7 @@
|
||||||
* @param ms TODO
|
* @param ms TODO
|
||||||
*/
|
*/
|
||||||
//% help=led/fade-in
|
//% help=led/fade-in
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function fadeIn(ms: number = 700): void {
|
export function fadeIn(ms: number = 700): void {
|
||||||
if (ms < 20) {
|
if (ms < 20) {
|
||||||
led.setBrightness(255);
|
led.setBrightness(255);
|
||||||
|
@ -112,6 +117,7 @@
|
||||||
* @param ms TODO
|
* @param ms TODO
|
||||||
*/
|
*/
|
||||||
//% help=led/fade-out
|
//% help=led/fade-out
|
||||||
|
//% parts="ledmatrix"
|
||||||
export function fadeOut(ms: number = 700): void {
|
export function fadeOut(ms: number = 700): void {
|
||||||
if (ms < 20) {
|
if (ms < 20) {
|
||||||
led.setBrightness(0);
|
led.setBrightness(0);
|
||||||
|
|
108
libs/microbit/shims.d.ts
vendored
108
libs/microbit/shims.d.ts
vendored
|
@ -11,14 +11,16 @@ declare namespace images {
|
||||||
* Creates an image that fits on the LED screen.
|
* Creates an image that fits on the LED screen.
|
||||||
*/
|
*/
|
||||||
//% weight=75 help=images/create-image
|
//% weight=75 help=images/create-image
|
||||||
//% blockId=device_build_image block="create image" imageLiteral=1 shim=images::createImage
|
//% blockId=device_build_image block="create image"
|
||||||
|
//% parts="ledmatrix" imageLiteral=1 shim=images::createImage
|
||||||
function createImage(leds: string): Image;
|
function createImage(leds: string): Image;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an image with 2 frames.
|
* Creates an image with 2 frames.
|
||||||
*/
|
*/
|
||||||
//% weight=74 help=images/create-big-image
|
//% weight=74 help=images/create-big-image
|
||||||
//% blockId=device_build_big_image block="create big image" imageLiteral=2 shim=images::createBigImage
|
//% blockId=device_build_big_image block="create big image" imageLiteral=2
|
||||||
|
//% parts="ledmatrix" shim=images::createBigImage
|
||||||
function createBigImage(leds: string): Image;
|
function createBigImage(leds: string): Image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +29,8 @@ declare interface Image {
|
||||||
/**
|
/**
|
||||||
* Plots the image at a given column to the screen
|
* Plots the image at a given column to the screen
|
||||||
*/
|
*/
|
||||||
//% help=images/plot-image xOffset.defl=0 shim=ImageMethods::plotImage
|
//% help=images/plot-image
|
||||||
|
//% parts="ledmatrix" xOffset.defl=0 shim=ImageMethods::plotImage
|
||||||
plotImage(xOffset?: number): void;
|
plotImage(xOffset?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,14 +38,16 @@ declare interface Image {
|
||||||
* @param xOffset column index to start displaying the image
|
* @param xOffset column index to start displaying the image
|
||||||
*/
|
*/
|
||||||
//% help=images/show-image weight=80 blockNamespace=images
|
//% help=images/show-image weight=80 blockNamespace=images
|
||||||
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8 shim=ImageMethods::showImage
|
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::showImage
|
||||||
showImage(xOffset: number): void;
|
showImage(xOffset: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the ``index``-th frame of the image on the screen.
|
* Draws the ``index``-th frame of the image on the screen.
|
||||||
* @param xOffset column index to start displaying the image
|
* @param xOffset column index to start displaying the image
|
||||||
*/
|
*/
|
||||||
//% help=images/plot-frame weight=80 shim=ImageMethods::plotFrame
|
//% help=images/plot-frame weight=80
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::plotFrame
|
||||||
plotFrame(xOffset: number): void;
|
plotFrame(xOffset: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,25 +56,29 @@ declare interface Image {
|
||||||
* @param interval time between each animation step in milli seconds, eg: 200
|
* @param interval time between each animation step in milli seconds, eg: 200
|
||||||
*/
|
*/
|
||||||
//% help=images/show-image weight=79 async blockNamespace=images
|
//% help=images/show-image weight=79 async blockNamespace=images
|
||||||
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8 shim=ImageMethods::scrollImage
|
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::scrollImage
|
||||||
scrollImage(frameOffset: number, interval: number): void;
|
scrollImage(frameOffset: number, interval: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets all pixels off.
|
* Sets all pixels off.
|
||||||
*/
|
*/
|
||||||
//% help=images/clear shim=ImageMethods::clear
|
//% help=images/clear
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::clear
|
||||||
clear(): void;
|
clear(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a specific pixel brightness at a given position
|
* Sets a specific pixel brightness at a given position
|
||||||
*/
|
*/
|
||||||
//% shim=ImageMethods::setPixelBrightness
|
//%
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::setPixelBrightness
|
||||||
setPixelBrightness(x: number, y: number, value: number): void;
|
setPixelBrightness(x: number, y: number, value: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the pixel brightness ([0..255]) at a given position
|
* Gets the pixel brightness ([0..255]) at a given position
|
||||||
*/
|
*/
|
||||||
//% shim=ImageMethods::pixelBrightness
|
//%
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::pixelBrightness
|
||||||
pixelBrightness(x: number, y: number): number;
|
pixelBrightness(x: number, y: number): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +99,8 @@ declare interface Image {
|
||||||
* @param y TODO
|
* @param y TODO
|
||||||
* @param value TODO
|
* @param value TODO
|
||||||
*/
|
*/
|
||||||
//% help=images/set-pixel shim=ImageMethods::setPixel
|
//% help=images/set-pixel
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::setPixel
|
||||||
setPixel(x: number, y: number, value: boolean): void;
|
setPixel(x: number, y: number, value: boolean): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,14 +108,16 @@ declare interface Image {
|
||||||
* @param x TODO
|
* @param x TODO
|
||||||
* @param y TODO
|
* @param y TODO
|
||||||
*/
|
*/
|
||||||
//% help=images/pixel shim=ImageMethods::pixel
|
//% help=images/pixel
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::pixel
|
||||||
pixel(x: number, y: number): boolean;
|
pixel(x: number, y: number): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a particular frame of the image strip.
|
* Shows a particular frame of the image strip.
|
||||||
* @param frame TODO
|
* @param frame TODO
|
||||||
*/
|
*/
|
||||||
//% weight=70 help=images/show-frame shim=ImageMethods::showFrame
|
//% weight=70 help=images/show-frame
|
||||||
|
//% parts="ledmatrix" shim=ImageMethods::showFrame
|
||||||
showFrame(frame: number): void;
|
showFrame(frame: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +135,8 @@ declare namespace basic {
|
||||||
//% help=basic/show-number
|
//% help=basic/show-number
|
||||||
//% weight=96
|
//% weight=96
|
||||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||||
//% async interval.defl=150 shim=basic::showNumber
|
//% async
|
||||||
|
//% parts="ledmatrix" interval.defl=150 shim=basic::showNumber
|
||||||
function showNumber(value: number, interval?: number): void;
|
function showNumber(value: number, interval?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +148,8 @@ declare namespace basic {
|
||||||
//% weight=95 blockGap=8
|
//% weight=95 blockGap=8
|
||||||
//% imageLiteral=1 async
|
//% imageLiteral=1 async
|
||||||
//% blockId=device_show_leds
|
//% blockId=device_show_leds
|
||||||
//% block="show leds" icon="\uf00a" interval.defl=400 shim=basic::showLeds
|
//% block="show leds" icon="\uf00a"
|
||||||
|
//% parts="ledmatrix" interval.defl=400 shim=basic::showLeds
|
||||||
function showLeds(leds: string, interval?: number): void;
|
function showLeds(leds: string, interval?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,14 +161,16 @@ declare namespace basic {
|
||||||
//% weight=87 blockGap=8
|
//% weight=87 blockGap=8
|
||||||
//% block="show|string %text" icon="\uf031"
|
//% block="show|string %text" icon="\uf031"
|
||||||
//% async
|
//% async
|
||||||
//% blockId=device_print_message interval.defl=150 shim=basic::showString
|
//% blockId=device_print_message
|
||||||
|
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
|
||||||
function showString(text: string, interval?: number): void;
|
function showString(text: string, interval?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn off all LEDs
|
* Turn off all LEDs
|
||||||
*/
|
*/
|
||||||
//% help=basic/clear-screen weight=79
|
//% help=basic/clear-screen weight=79
|
||||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d" shim=basic::clearScreen
|
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||||
|
//% parts="ledmatrix" shim=basic::clearScreen
|
||||||
function clearScreen(): void;
|
function clearScreen(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,14 +178,16 @@ declare namespace basic {
|
||||||
* @param leds pattern of LEDs to turn on/off
|
* @param leds pattern of LEDs to turn on/off
|
||||||
* @param interval time in milliseconds between each redraw
|
* @param interval time in milliseconds between each redraw
|
||||||
*/
|
*/
|
||||||
//% help=basic/show-animation imageLiteral=1 async interval.defl=400 shim=basic::showAnimation
|
//% help=basic/show-animation imageLiteral=1 async
|
||||||
|
//% parts="ledmatrix" interval.defl=400 shim=basic::showAnimation
|
||||||
function showAnimation(leds: string, interval?: number): void;
|
function showAnimation(leds: string, interval?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws an image on the LED screen.
|
* Draws an image on the LED screen.
|
||||||
* @param leds pattern of LEDs to turn on/off
|
* @param leds pattern of LEDs to turn on/off
|
||||||
*/
|
*/
|
||||||
//% help=basic/plot-leds weight=80 imageLiteral=1 shim=basic::plotLeds
|
//% help=basic/plot-leds weight=80
|
||||||
|
//% parts="ledmatrix" imageLiteral=1 shim=basic::plotLeds
|
||||||
function plotLeds(leds: string): void;
|
function plotLeds(leds: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +219,8 @@ declare namespace input {
|
||||||
* @param body TODO
|
* @param body TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192" shim=input::onButtonPressed
|
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||||
|
//% parts="buttonpair" shim=input::onButtonPressed
|
||||||
function onButtonPressed(button: Button, body: () => void): void;
|
function onButtonPressed(button: Button, body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,7 +228,8 @@ declare namespace input {
|
||||||
* @param body TODO
|
* @param body TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/on-gesture weight=84 blockGap=8
|
//% help=input/on-gesture weight=84 blockGap=8
|
||||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135" shim=input::onGesture
|
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||||
|
//% parts="accelerometer" shim=input::onGesture
|
||||||
function onGesture(gesture: Gesture, body: () => void): void;
|
function onGesture(gesture: Gesture, body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,7 +256,8 @@ declare namespace input {
|
||||||
//% help=input/button-is-pressed weight=57
|
//% help=input/button-is-pressed weight=57
|
||||||
//% block="button|%NAME|is pressed"
|
//% block="button|%NAME|is pressed"
|
||||||
//% blockId=device_get_button2
|
//% blockId=device_get_button2
|
||||||
//% icon="\uf192" blockGap=8 shim=input::buttonIsPressed
|
//% icon="\uf192" blockGap=8
|
||||||
|
//% parts="buttonpair" shim=input::buttonIsPressed
|
||||||
function buttonIsPressed(button: Button): boolean;
|
function buttonIsPressed(button: Button): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -253,7 +274,8 @@ declare namespace input {
|
||||||
*/
|
*/
|
||||||
//% help=input/compass-heading
|
//% help=input/compass-heading
|
||||||
//% weight=56 icon="\uf14e"
|
//% weight=56 icon="\uf14e"
|
||||||
//% blockId=device_heading block="compass heading (°)" blockGap=8 shim=input::compassHeading
|
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||||
|
//% parts="compass" shim=input::compassHeading
|
||||||
function compassHeading(): number;
|
function compassHeading(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,7 +283,8 @@ declare namespace input {
|
||||||
*/
|
*/
|
||||||
//% weight=55 icon="\uf06d"
|
//% weight=55 icon="\uf06d"
|
||||||
//% help=input/temperature
|
//% help=input/temperature
|
||||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8 shim=input::temperature
|
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||||
|
//% parts="thermometer" shim=input::temperature
|
||||||
function temperature(): number;
|
function temperature(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -269,14 +292,16 @@ declare namespace input {
|
||||||
* @param dimension TODO
|
* @param dimension TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/acceleration weight=54 icon="\uf135"
|
//% help=input/acceleration weight=54 icon="\uf135"
|
||||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 shim=input::acceleration
|
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||||
|
//% parts="accelerometer" shim=input::acceleration
|
||||||
function acceleration(dimension: Dimension): number;
|
function acceleration(dimension: Dimension): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||||
*/
|
*/
|
||||||
//% help=input/light-level weight=53
|
//% help=input/light-level weight=53
|
||||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185" shim=input::lightLevel
|
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||||
|
//% parts="ledmatrix" shim=input::lightLevel
|
||||||
function lightLevel(): number;
|
function lightLevel(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -284,7 +309,8 @@ declare namespace input {
|
||||||
* @param kind TODO
|
* @param kind TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/rotation weight=52
|
//% help=input/rotation weight=52
|
||||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197" shim=input::rotation
|
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||||
|
//% parts="accelerometer" shim=input::rotation
|
||||||
function rotation(kind: Rotation): number;
|
function rotation(kind: Rotation): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -292,7 +318,8 @@ declare namespace input {
|
||||||
* @param dimension TODO
|
* @param dimension TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/magnetic-force weight=51
|
//% help=input/magnetic-force weight=51
|
||||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076" shim=input::magneticForce
|
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||||
|
//% parts="compass" shim=input::magneticForce
|
||||||
function magneticForce(dimension: Dimension): number;
|
function magneticForce(dimension: Dimension): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,7 +341,8 @@ declare namespace input {
|
||||||
*/
|
*/
|
||||||
//% help=input/set-accelerometer-range
|
//% help=input/set-accelerometer-range
|
||||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||||
//% weight=5 shim=input::setAccelerometerRange
|
//% weight=5
|
||||||
|
//% parts="accelerometer" shim=input::setAccelerometerRange
|
||||||
function setAccelerometerRange(range: AcceleratorRange): void;
|
function setAccelerometerRange(range: AcceleratorRange): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +428,8 @@ declare namespace led {
|
||||||
* @param y TODO
|
* @param y TODO
|
||||||
*/
|
*/
|
||||||
//% help=led/plot weight=78
|
//% help=led/plot weight=78
|
||||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8 shim=led::plot
|
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||||
|
//% parts="ledmatrix" shim=led::plot
|
||||||
function plot(x: number, y: number): void;
|
function plot(x: number, y: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -409,7 +438,8 @@ declare namespace led {
|
||||||
* @param y TODO
|
* @param y TODO
|
||||||
*/
|
*/
|
||||||
//% help=led/unplot weight=77
|
//% help=led/unplot weight=77
|
||||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8 shim=led::unplot
|
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||||
|
//% parts="ledmatrix" shim=led::unplot
|
||||||
function unplot(x: number, y: number): void;
|
function unplot(x: number, y: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -418,14 +448,16 @@ declare namespace led {
|
||||||
* @param y TODO
|
* @param y TODO
|
||||||
*/
|
*/
|
||||||
//% help=led/point weight=76
|
//% help=led/point weight=76
|
||||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c" shim=led::point
|
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||||
|
//% parts="ledmatrix" shim=led::point
|
||||||
function point(x: number, y: number): boolean;
|
function point(x: number, y: number): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the screen brightness from 0 (off) to 255 (full bright).
|
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||||
*/
|
*/
|
||||||
//% help=led/brightness weight=60
|
//% help=led/brightness weight=60
|
||||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8 shim=led::brightness
|
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||||
|
//% parts="ledmatrix" shim=led::brightness
|
||||||
function brightness(): number;
|
function brightness(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -433,27 +465,31 @@ declare namespace led {
|
||||||
* @param value the brightness value, eg:255, 127, 0
|
* @param value the brightness value, eg:255, 127, 0
|
||||||
*/
|
*/
|
||||||
//% help=led/set-brightness weight=59
|
//% help=led/set-brightness weight=59
|
||||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042" shim=led::setBrightness
|
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||||
|
//% parts="ledmatrix" shim=led::setBrightness
|
||||||
function setBrightness(value: number): void;
|
function setBrightness(value: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels the current animation and clears other pending animations.
|
* Cancels the current animation and clears other pending animations.
|
||||||
*/
|
*/
|
||||||
//% weight=50 help=led/stop-animation
|
//% weight=50 help=led/stop-animation
|
||||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d" shim=led::stopAnimation
|
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||||
|
//% parts="ledmatrix" shim=led::stopAnimation
|
||||||
function stopAnimation(): void;
|
function stopAnimation(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the display mode between black and white and greyscale for rendering LEDs.
|
* Sets the display mode between black and white and greyscale for rendering LEDs.
|
||||||
* @param mode TODO
|
* @param mode TODO
|
||||||
*/
|
*/
|
||||||
//% weight=1 help=led/set-display-mode shim=led::setDisplayMode
|
//% weight=1 help=led/set-display-mode
|
||||||
|
//% parts="ledmatrix" shim=led::setDisplayMode
|
||||||
function setDisplayMode(mode: DisplayMode): void;
|
function setDisplayMode(mode: DisplayMode): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes a screenshot of the LED screen and returns an image.
|
* Takes a screenshot of the LED screen and returns an image.
|
||||||
*/
|
*/
|
||||||
//% help=led/screenshot shim=led::screenshot
|
//% help=led/screenshot
|
||||||
|
//% parts="ledmatrix" shim=led::screenshot
|
||||||
function screenshot(): Image;
|
function screenshot(): Image;
|
||||||
}
|
}
|
||||||
declare namespace pins {
|
declare namespace pins {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user