2016-04-02 02:45:18 +02:00
|
|
|
// Auto-generated. Do not edit.
|
|
|
|
|
|
|
|
|
2016-04-06 00:59:25 +02:00
|
|
|
/**
|
|
|
|
* Creation, manipulation and display of LED images.
|
|
|
|
*/
|
2019-12-02 05:58:26 +01:00
|
|
|
//% color=#7600A8 weight=31 icon="\uf03e"
|
2016-10-11 22:48:25 +02:00
|
|
|
//% advanced=true
|
2016-04-02 04:55:51 +02:00
|
|
|
declare namespace images {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an image that fits on the LED screen.
|
|
|
|
*/
|
|
|
|
//% weight=75 help=images/create-image
|
2016-08-22 17:48:48 +02:00
|
|
|
//% blockId=device_build_image block="create image"
|
|
|
|
//% parts="ledmatrix" imageLiteral=1 shim=images::createImage
|
2016-04-02 04:55:51 +02:00
|
|
|
function createImage(leds: string): Image;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an image with 2 frames.
|
|
|
|
*/
|
|
|
|
//% weight=74 help=images/create-big-image
|
2016-08-22 17:48:48 +02:00
|
|
|
//% blockId=device_build_big_image block="create big image" imageLiteral=2
|
|
|
|
//% parts="ledmatrix" shim=images::createBigImage
|
2016-04-02 04:55:51 +02:00
|
|
|
function createBigImage(leds: string): Image;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
declare interface Image {
|
2016-04-13 02:10:37 +02:00
|
|
|
/**
|
|
|
|
* Plots the image at a given column to the screen
|
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=images/plot-image
|
|
|
|
//% parts="ledmatrix" xOffset.defl=0 shim=ImageMethods::plotImage
|
2019-12-02 05:58:26 +01:00
|
|
|
plotImage(xOffset?: int32): void;
|
2016-04-13 02:10:37 +02:00
|
|
|
|
2016-04-02 04:55:51 +02:00
|
|
|
/**
|
|
|
|
* Shows an frame from the image at offset ``x offset``.
|
2016-05-27 05:42:15 +02:00
|
|
|
* @param xOffset column index to start displaying the image
|
2022-03-22 17:36:19 +01:00
|
|
|
* @param interval time in milliseconds to pause after drawing
|
2016-04-02 04:55:51 +02:00
|
|
|
*/
|
2016-05-27 05:42:15 +02:00
|
|
|
//% help=images/show-image weight=80 blockNamespace=images
|
2022-03-22 17:36:19 +01:00
|
|
|
//% blockId=device_show_image_offset block="show image %sprite(myImage)|at offset %offset ||and interval (ms) %interval"
|
|
|
|
//%
|
2019-12-02 05:58:26 +01:00
|
|
|
//% blockGap=8 parts="ledmatrix" async interval.defl=400 shim=ImageMethods::showImage
|
|
|
|
showImage(xOffset: int32, interval?: int32): void;
|
2016-04-02 04:55:51 +02:00
|
|
|
|
2016-04-13 02:10:37 +02:00
|
|
|
/**
|
|
|
|
* Draws the ``index``-th frame of the image on the screen.
|
2016-05-27 05:42:15 +02:00
|
|
|
* @param xOffset column index to start displaying the image
|
2016-04-13 02:10:37 +02:00
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=images/plot-frame weight=80
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::plotFrame
|
2019-12-02 05:58:26 +01:00
|
|
|
plotFrame(xOffset: int32): void;
|
2016-04-13 02:10:37 +02:00
|
|
|
|
2016-04-02 04:55:51 +02:00
|
|
|
/**
|
|
|
|
* Scrolls an image .
|
2016-11-17 19:14:12 +01:00
|
|
|
* @param frameOffset x offset moved on each animation step, eg: 1, 2, 5
|
2016-04-02 04:55:51 +02:00
|
|
|
* @param interval time between each animation step in milli seconds, eg: 200
|
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=images/scroll-image weight=79 async blockNamespace=images
|
2019-12-02 05:58:26 +01:00
|
|
|
//% blockId=device_scroll_image
|
2022-03-23 21:23:00 +01:00
|
|
|
//% block="scroll image %sprite(myImage)|with offset %frameoffset|and interval (ms) %delay"
|
2019-12-02 05:58:26 +01:00
|
|
|
//% blockGap=8 parts="ledmatrix" shim=ImageMethods::scrollImage
|
|
|
|
scrollImage(frameOffset: int32, interval: int32): void;
|
2016-04-02 04:55:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets all pixels off.
|
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=images/clear
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::clear
|
2016-04-02 04:55:51 +02:00
|
|
|
clear(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a specific pixel brightness at a given position
|
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//%
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::setPixelBrightness
|
2019-12-02 05:58:26 +01:00
|
|
|
setPixelBrightness(x: int32, y: int32, value: int32): void;
|
2016-04-02 04:55:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the pixel brightness ([0..255]) at a given position
|
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//%
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::pixelBrightness
|
2019-12-02 05:58:26 +01:00
|
|
|
pixelBrightness(x: int32, y: int32): int32;
|
2016-04-13 02:10:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the width in columns
|
|
|
|
*/
|
|
|
|
//% help=functions/width shim=ImageMethods::width
|
2019-12-02 05:58:26 +01:00
|
|
|
width(): int32;
|
2016-04-13 02:10:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the height in rows (always 5)
|
|
|
|
*/
|
2016-05-27 05:42:15 +02:00
|
|
|
//% shim=ImageMethods::height
|
2019-12-02 05:58:26 +01:00
|
|
|
height(): int32;
|
2016-04-13 02:10:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a pixel state at position ``(x,y)``
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param x pixel column
|
|
|
|
* @param y pixel row
|
|
|
|
* @param value pixel state
|
2016-04-13 02:10:37 +02:00
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=images/set-pixel
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::setPixel
|
2019-12-02 05:58:26 +01:00
|
|
|
setPixel(x: int32, y: int32, value: boolean): void;
|
2016-04-13 02:10:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the pixel state at position ``(x,y)``
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param x pixel column
|
|
|
|
* @param y pixel row
|
2016-04-13 02:10:37 +02:00
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=images/pixel
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::pixel
|
2019-12-02 05:58:26 +01:00
|
|
|
pixel(x: int32, y: int32): boolean;
|
2016-04-13 02:10:37 +02:00
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Show a particular frame of the image strip.
|
|
|
|
* @param frame image frame to show
|
2016-04-13 02:10:37 +02:00
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% weight=70 help=images/show-frame
|
2017-02-04 05:39:18 +01:00
|
|
|
//% parts="ledmatrix" interval.defl=400 shim=ImageMethods::showFrame
|
2019-12-02 05:58:26 +01:00
|
|
|
showFrame(frame: int32, interval?: int32): void;
|
2016-04-02 04:55:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
/**
|
|
|
|
* Provides access to basic micro:bit functionality.
|
|
|
|
*/
|
2016-10-11 20:41:51 +02:00
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
declare namespace basic {
|
2016-04-02 02:45:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws an image on the LED screen.
|
2016-06-14 15:30:07 +02:00
|
|
|
* @param leds the pattern of LED to turn on/off
|
|
|
|
* @param interval time in milliseconds to pause after drawing
|
2016-04-02 02:45:18 +02:00
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=basic/show-leds
|
2022-03-22 17:36:19 +01:00
|
|
|
//% weight=85 blockGap=8
|
2016-04-02 02:45:18 +02:00
|
|
|
//% imageLiteral=1 async
|
|
|
|
//% blockId=device_show_leds
|
2017-12-14 20:00:47 +01:00
|
|
|
//% block="show leds" icon="\uf00a"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% group="LED matrix" interval.defl=400 shim=basic::showLeds
|
2019-12-02 05:58:26 +01:00
|
|
|
function showLeds(leds: string, interval?: int32): void;
|
2016-04-02 02:45:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param text the text to scroll on the screen, eg: "hi!"
|
2022-03-22 17:36:19 +01:00
|
|
|
* @param interval how fast to shift characters; eg: 50, 100, 150, 200
|
2016-04-02 02:45:18 +02:00
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=basic/show-string
|
2022-03-22 17:36:19 +01:00
|
|
|
//% weight=100 blockGap=16
|
|
|
|
//% block="show|string %text || in an interval of %interval ms"
|
2016-04-02 02:45:18 +02:00
|
|
|
//% async
|
2016-08-22 17:48:48 +02:00
|
|
|
//% blockId=device_print_message
|
2019-12-02 05:58:26 +01:00
|
|
|
//% parts="ledmatrix"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% text.shadowOptions.toString=true
|
|
|
|
//% expandableArgumentMode="toggle"
|
|
|
|
//%
|
2022-06-30 19:01:19 +02:00
|
|
|
//% group="LED matrix" interval.defl=150 shim=basic::showString
|
2019-12-02 05:58:26 +01:00
|
|
|
function showString(text: string, interval?: int32): void;
|
2016-04-02 02:45:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a sequence of LED screens as an animation.
|
2016-06-14 15:30:07 +02:00
|
|
|
* @param leds pattern of LEDs to turn on/off
|
|
|
|
* @param interval time in milliseconds between each redraw
|
2016-04-02 02:45:18 +02:00
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=basic/show-animation weight=83 imageLiteral=1 async
|
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% group="LED matrix" interval.defl=400 shim=basic::showAnimation
|
2019-12-02 05:58:26 +01:00
|
|
|
function showAnimation(leds: string, interval?: int32): void;
|
2016-04-02 02:45:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws an image on the LED screen.
|
2016-06-14 15:30:07 +02:00
|
|
|
* @param leds pattern of LEDs to turn on/off
|
2016-04-02 02:45:18 +02:00
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=basic/plot-leds weight=80
|
2022-03-22 17:36:19 +01:00
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% group="LED matrix" imageLiteral=1 shim=basic::plotLeds
|
2016-04-02 02:45:18 +02:00
|
|
|
function plotLeds(leds: string): void;
|
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
/**
|
|
|
|
* Turn off all LEDs
|
|
|
|
*/
|
|
|
|
//% help=basic/clear-screen weight=75
|
|
|
|
//% blockId=device_clear_display block="clear screen"
|
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% group="LED matrix"
|
|
|
|
//% advanced=true shim=basic::clearScreen
|
|
|
|
function clearScreen(): void;
|
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
/**
|
|
|
|
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
2016-06-14 15:30:07 +02:00
|
|
|
* @param body code to execute
|
2016-04-02 02:45:18 +02:00
|
|
|
*/
|
2019-12-02 05:58:26 +01:00
|
|
|
//% help=basic/forever weight=55 blockGap=16 blockAllowMultiple=1 afterOnStart=true
|
2022-03-22 17:36:19 +01:00
|
|
|
//% blockId=device_forever block="forever" icon="\uf01e"
|
|
|
|
//% group="Control" shim=basic::forever
|
2016-04-02 02:45:18 +02:00
|
|
|
function forever(a: () => void): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause for the specified time in milliseconds
|
|
|
|
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
|
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=basic/pause weight=50
|
2019-12-02 05:58:26 +01:00
|
|
|
//% async block="pause (ms) %pause" blockGap=16
|
|
|
|
//% blockId=device_pause icon="\uf110"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% pause.shadow=timePicker
|
|
|
|
//% group="Control" shim=basic::pause
|
2019-12-02 05:58:26 +01:00
|
|
|
function pause(ms: int32): void;
|
2022-03-22 17:36:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the color on the build-in LED. Set to 0 to turn off.
|
|
|
|
*/
|
|
|
|
//% blockId=device_set_led_color
|
|
|
|
//% block="set led to %color=colorNumberPicker"
|
2022-04-26 19:28:42 +02:00
|
|
|
//%
|
2022-03-22 17:36:19 +01:00
|
|
|
//% weight=10
|
2022-04-26 19:28:42 +02:00
|
|
|
//% group="RGB LED" color.defl=0xff0000 shim=basic::setLedColor
|
|
|
|
function setLedColor(color?: int32): void;
|
2022-03-22 17:36:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the color on the build-in LED. Set to 0 to turn off.
|
|
|
|
*/
|
|
|
|
//% blockId=device_turn_rgb_led_off block="turn build-in LED off"
|
|
|
|
//% weight=10
|
|
|
|
//% group="RGB LED"
|
|
|
|
//% advanced=true shim=basic::turnRgbLedOff
|
|
|
|
function turnRgbLedOff(): void;
|
2016-04-02 02:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-12-14 20:00:47 +01:00
|
|
|
//% color=#B4009E weight=99 icon="\uf192"
|
2016-04-02 06:26:06 +02:00
|
|
|
declare namespace input {
|
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
/**
|
|
|
|
* Do something when a button (A, B or both A+B) receives an event.
|
|
|
|
* @param button the button
|
|
|
|
* @param body code to run when event is raised
|
|
|
|
* @param eventType event Type
|
|
|
|
*/
|
|
|
|
//% help=input/on-button-event weight=100 blockGap=16
|
|
|
|
//% blockId=device_button_selected_event block="on button %NAME| %eventType=control_button_event_value_id"
|
|
|
|
//% parts="buttonpair"
|
|
|
|
//% group="Events" shim=input::onButtonEvent
|
|
|
|
function onButtonEvent(button: Button, eventType: int32, body: () => void): void;
|
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
/**
|
2016-09-26 18:59:52 +02:00
|
|
|
* Do something when when a gesture is done (like shaking the micro:bit).
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param gesture the type of gesture to track, eg: Gesture.Shake
|
|
|
|
* @param body code to run when gesture is raised
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=input/on-gesture weight=98 blockGap=16
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_gesture_event block="on |%NAME"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% parts="accelerometer"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% NAME.fieldEditor="gestures" NAME.fieldOptions.columns=4
|
|
|
|
//% group="Events" shim=input::onGesture
|
2016-04-02 06:52:25 +02:00
|
|
|
function onGesture(gesture: Gesture, body: () => void): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
/**
|
|
|
|
* Tests if a gesture is currently detected.
|
|
|
|
* @param gesture the type of gesture to detect, eg: Gesture.Shake
|
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=input/is-gesture weight=86 blockGap=8
|
2019-12-02 05:58:26 +01:00
|
|
|
//% blockId=deviceisgesture block="is %gesture gesture"
|
|
|
|
//% parts="accelerometer"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% gesture.fieldEditor="gestures" gesture.fieldOptions.columns=4
|
|
|
|
//% group="States" shim=input::isGesture
|
2019-12-02 05:58:26 +01:00
|
|
|
function isGesture(gesture: Gesture): boolean;
|
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
/**
|
|
|
|
* Do something when a pin receives an touch event (while also touching the GND pin).
|
|
|
|
* @param name the pin, eg: TouchPin.P0
|
|
|
|
* @param body the code to run when event is fired on pin
|
|
|
|
*/
|
2022-05-09 19:10:17 +02:00
|
|
|
//% help=input/on-pin-event weight=99 blockGap=16
|
2022-03-22 17:36:19 +01:00
|
|
|
//% blockId=device_pin_custom_event block="on pin %name| %eventType=control_button_event_value_id"
|
|
|
|
//% group="Events" shim=input::onPinTouchEvent
|
|
|
|
function onPinTouchEvent(name: TouchPin, eventType: int32, body: () => void): void;
|
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
/**
|
|
|
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param button the button to query the request, eg: Button.A
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=input/button-is-pressed weight=89
|
2016-04-02 06:26:06 +02:00
|
|
|
//% block="button|%NAME|is pressed"
|
|
|
|
//% blockId=device_get_button2
|
2019-12-02 05:58:26 +01:00
|
|
|
//% icon="\uf192" blockGap=8
|
2022-03-22 17:36:19 +01:00
|
|
|
//% parts="buttonpair"
|
|
|
|
//% group="States" shim=input::buttonIsPressed
|
2016-04-02 06:52:25 +02:00
|
|
|
function buttonIsPressed(button: Button): boolean;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
2022-06-30 19:01:19 +02:00
|
|
|
/**
|
|
|
|
* Do something when a button (A, B or both A+B) is pushed down and released again.
|
|
|
|
* @param button the button that needs to be pressed
|
|
|
|
* @param body code to run when event is raised
|
|
|
|
*/
|
|
|
|
//% help=input/on-button-pressed weight=85 blockGap=16
|
|
|
|
//% blockId=device_button_event block="on button|%NAME|pressed"
|
|
|
|
//% parts="buttonpair"
|
|
|
|
//% deprecated=true
|
|
|
|
//% group="Events" shim=input::onButtonPressed
|
|
|
|
function onButtonPressed(button: Button, body: () => void): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do something when a pin is touched and released again (while also touching the GND pin).
|
|
|
|
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
|
|
|
* @param body the code to run when the pin is pressed
|
|
|
|
*/
|
|
|
|
//% help=input/on-pin-pressed weight=83 blockGap=16
|
|
|
|
//% blockId=device_pin_event block="on pin %name|pressed"
|
|
|
|
//% group="Events"
|
|
|
|
//% deprecated=true shim=input::onPinPressed
|
|
|
|
function onPinPressed(name: TouchPin, body: () => void): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do something when a pin is released.
|
|
|
|
* @param name the pin that needs to be released, eg: TouchPin.P0
|
|
|
|
* @param body the code to run when the pin is released
|
|
|
|
*/
|
|
|
|
//% help=input/on-pin-released weight=6 blockGap=16
|
|
|
|
//% blockId=device_pin_released block="on pin %NAME|released"
|
|
|
|
//% advanced=true
|
|
|
|
//% group="Events"
|
|
|
|
//% deprecated=true shim=input::onPinReleased
|
|
|
|
function onPinReleased(name: TouchPin, body: () => void): void;
|
|
|
|
|
2016-07-27 01:17:54 +02:00
|
|
|
/**
|
|
|
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param name pin used to detect the touch, eg: TouchPin.P0
|
2016-07-27 01:17:54 +02:00
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=input/pin-is-pressed weight=87
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% blockGap=8
|
|
|
|
//% group="States" shim=input::pinIsPressed
|
2016-07-27 01:17:54 +02:00
|
|
|
function pinIsPressed(name: TouchPin): boolean;
|
|
|
|
|
2016-10-12 04:36:00 +02:00
|
|
|
/**
|
|
|
|
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param dimension x, y, or z dimension, eg: Dimension.X
|
2016-10-12 04:36:00 +02:00
|
|
|
*/
|
2017-01-20 05:55:31 +01:00
|
|
|
//% help=input/acceleration weight=58
|
2016-10-12 04:36:00 +02:00
|
|
|
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
2022-03-22 17:36:19 +01:00
|
|
|
//% parts="accelerometer"
|
|
|
|
//% group="Sensors" shim=input::acceleration
|
2019-12-02 05:58:26 +01:00
|
|
|
function acceleration(dimension: Dimension): int32;
|
2016-10-12 04:36:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=input/light-level weight=59
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_get_light_level block="light level" blockGap=8
|
2022-03-22 17:36:19 +01:00
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% group="Sensors" shim=input::lightLevel
|
2019-12-02 05:58:26 +01:00
|
|
|
function lightLevel(): int32;
|
2016-10-12 04:36:00 +02:00
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
/**
|
|
|
|
* gets the level of loudness from 0 (silent) to 255 (loud)
|
|
|
|
*/
|
|
|
|
//% blockId="soundLevel" weight=58
|
|
|
|
//% block="soundLevel" blockGap=8
|
|
|
|
//% group="Sensors" shim=input::soundLevel
|
|
|
|
function soundLevel(): int32;
|
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
/**
|
2016-09-26 18:59:52 +02:00
|
|
|
* Get the current compass heading in degrees.
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2016-10-11 22:48:25 +02:00
|
|
|
//% help=input/compass-heading
|
2017-01-20 05:55:31 +01:00
|
|
|
//% weight=56
|
2016-08-22 17:48:48 +02:00
|
|
|
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
2022-03-22 17:36:19 +01:00
|
|
|
//% parts="compass"
|
|
|
|
//% group="Sensors" shim=input::compassHeading
|
2019-12-02 05:58:26 +01:00
|
|
|
function compassHeading(): int32;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the temperature in Celsius degrees (°C).
|
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% weight=57
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=input/temperature
|
2016-08-22 17:48:48 +02:00
|
|
|
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
2022-03-22 17:36:19 +01:00
|
|
|
//% parts="thermometer"
|
|
|
|
//% group="Sensors" shim=input::temperature
|
2019-12-02 05:58:26 +01:00
|
|
|
function temperature(): int32;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
2016-09-26 18:59:52 +02:00
|
|
|
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param kind pitch or roll
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2016-08-10 22:10:40 +02:00
|
|
|
//% help=input/rotation weight=52
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
|
2022-03-22 17:36:19 +01:00
|
|
|
//% parts="accelerometer" advanced=true
|
|
|
|
//% group="Sensors" shim=input::rotation
|
2019-12-02 05:58:26 +01:00
|
|
|
function rotation(kind: Rotation): int32;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param dimension the x, y, or z dimension, eg: Dimension.X
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=input/magnetic-force weight=49
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
|
2016-10-11 22:48:25 +02:00
|
|
|
//% parts="compass"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% advanced=true
|
|
|
|
//% group="Sensors" shim=input::magneticForce
|
2020-09-08 11:04:25 +02:00
|
|
|
function magneticForce(dimension: Dimension): number;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Obsolete, compass calibration is automatic.
|
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=input/calibrate-compass advanced=true
|
2019-12-02 05:58:26 +01:00
|
|
|
//% blockId="input_compass_calibrate" block="calibrate compass"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% weight=20 gap=8
|
|
|
|
//% group="Configuration" shim=input::calibrateCompass
|
2017-12-14 20:00:47 +01:00
|
|
|
function calibrateCompass(): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
/**
|
|
|
|
* Returns 'true' when the compass is calibrated. Otherwise returns 'false'.
|
|
|
|
*/
|
|
|
|
//% help=input/calibrate-compass advanced=true
|
|
|
|
//% blockId="input_compass_is_calibrated" block="is compass calibrated"
|
|
|
|
//% weight=19
|
|
|
|
//% group="System" shim=input::isCalibratedCompass
|
|
|
|
function isCalibratedCompass(): boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obsolete, compass calibration is automatic.
|
|
|
|
*/
|
|
|
|
//% help=input/calibrate-compass advanced=true
|
|
|
|
//% blockId="input_compass_clear_calibration" block="clear calibration compass"
|
|
|
|
//% weight=17
|
|
|
|
//% group="Configuration"
|
|
|
|
//% blockHidden=true shim=input::clearCalibrationCompass
|
|
|
|
function clearCalibrationCompass(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obsolete, compass calibration is automatic.
|
|
|
|
*/
|
|
|
|
//% help=input/calibrate-compass advanced=true
|
|
|
|
//% blockId="input_compass_assume_calibration" block="assume calibration compass"
|
|
|
|
//% weight=16
|
|
|
|
//% group="Configuration"
|
|
|
|
//% blockHidden=true shim=input::assumeCalibrationCompass
|
|
|
|
function assumeCalibrationCompass(): void;
|
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
/**
|
|
|
|
* Sets the accelerometer sample range in gravities.
|
|
|
|
* @param range a value describe the maximum strengh of acceleration measured
|
|
|
|
*/
|
2016-07-21 22:46:22 +02:00
|
|
|
//% help=input/set-accelerometer-range
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% weight=22 gap=8
|
2016-10-11 22:48:25 +02:00
|
|
|
//% parts="accelerometer"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% advanced=true
|
|
|
|
//% group="Configuration" shim=input::setAccelerometerRange
|
2016-04-02 06:52:25 +02:00
|
|
|
function setAccelerometerRange(range: AcceleratorRange): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-06 01:54:09 +02:00
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
//% weight=1 color="#333333"
|
2016-10-11 22:48:25 +02:00
|
|
|
//% advanced=true
|
2016-04-02 02:45:18 +02:00
|
|
|
declare namespace control {
|
|
|
|
|
2020-05-08 18:35:38 +02:00
|
|
|
/**
|
|
|
|
* Gets the number of milliseconds elapsed since power on.
|
|
|
|
*/
|
|
|
|
//% help=control/millis weight=50
|
|
|
|
//% blockId=control_running_time block="millis (ms)" shim=control::millis
|
|
|
|
function millis(): int32;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets current time in microseconds. Overflows every ~18 minutes.
|
|
|
|
*/
|
|
|
|
//% shim=control::micros
|
|
|
|
function micros(): int32;
|
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
/**
|
|
|
|
* Schedules code that run in the background.
|
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=control/in-background blockAllowMultiple=1 afterOnStart=true
|
2016-04-02 02:45:18 +02:00
|
|
|
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
|
|
|
|
function inBackground(a: () => void): void;
|
|
|
|
|
2020-05-08 18:35:38 +02:00
|
|
|
/**
|
|
|
|
* Blocks the calling thread until the specified event is raised.
|
|
|
|
*/
|
|
|
|
//% help=control/wait-for-event async
|
|
|
|
//% blockId=control_wait_for_event block="wait for event|from %src|with value %value" shim=control::waitForEvent
|
|
|
|
function waitForEvent(src: int32, value: int32): void;
|
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
/**
|
|
|
|
* Resets the BBC micro:bit.
|
|
|
|
*/
|
2016-08-17 02:04:21 +02:00
|
|
|
//% weight=30 async help=control/reset blockGap=8
|
2016-04-02 02:45:18 +02:00
|
|
|
//% blockId="control_reset" block="reset" shim=control::reset
|
|
|
|
function reset(): void;
|
|
|
|
|
2016-08-17 02:04:21 +02:00
|
|
|
/**
|
|
|
|
* Blocks the current fiber for the given microseconds
|
|
|
|
* @param micros number of micro-seconds to wait. eg: 4
|
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=control/wait-micros weight=29 async
|
|
|
|
//% blockId="control_wait_us" block="wait (µs)%micros"
|
|
|
|
//% micros.min=0 micros.max=6000 shim=control::waitMicros
|
2019-12-02 05:58:26 +01:00
|
|
|
function waitMicros(micros: int32): void;
|
2016-08-17 02:04:21 +02:00
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
/**
|
|
|
|
* Raises an event in the event bus.
|
|
|
|
* @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.
|
|
|
|
* @param value Component specific code indicating the cause of the event.
|
2016-04-14 23:29:28 +02:00
|
|
|
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
|
2016-04-02 02:45:18 +02:00
|
|
|
*/
|
2016-05-17 01:24:44 +02:00
|
|
|
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=control/raise-event
|
2016-04-15 02:58:10 +02:00
|
|
|
//% mode.defl=1 shim=control::raiseEvent
|
2019-12-02 05:58:26 +01:00
|
|
|
function raiseEvent(src: int32, value: int32, mode?: EventCreationMode): void;
|
2016-04-02 02:45:18 +02:00
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Registers an event handler.
|
2016-04-02 02:45:18 +02:00
|
|
|
*/
|
2016-10-11 22:48:25 +02:00
|
|
|
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=control/on-event
|
2019-12-02 05:58:26 +01:00
|
|
|
//% blockExternalInputs=1 flags.defl=0 shim=control::onEvent
|
|
|
|
function onEvent(src: int32, value: int32, handler: () => void, flags?: int32): void;
|
2016-04-26 22:43:02 +02:00
|
|
|
|
2016-05-17 01:24:44 +02:00
|
|
|
/**
|
|
|
|
* Gets the value of the last event executed on the bus
|
|
|
|
*/
|
|
|
|
//% blockId=control_event_value" block="event value"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=control/event-value
|
2016-05-17 01:24:44 +02:00
|
|
|
//% weight=18 shim=control::eventValue
|
2019-12-02 05:58:26 +01:00
|
|
|
function eventValue(): int32;
|
2016-05-17 01:24:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the timestamp of the last event executed on the bus
|
|
|
|
*/
|
|
|
|
//% blockId=control_event_timestamp" block="event timestamp"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=control/event-timestamp
|
2016-05-17 18:36:01 +02:00
|
|
|
//% weight=19 blockGap=8 shim=control::eventTimestamp
|
2019-12-02 05:58:26 +01:00
|
|
|
function eventTimestamp(): int32;
|
2016-05-17 01:24:44 +02:00
|
|
|
|
2016-04-26 22:43:02 +02:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Make a friendly name for the device based on its serial number
|
2016-04-26 22:43:02 +02:00
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId="control_device_name" block="device name" weight=10 blockGap=8
|
2020-09-08 11:04:25 +02:00
|
|
|
//% help=control/device-name
|
2017-12-14 20:00:47 +01:00
|
|
|
//% advanced=true shim=control::deviceName
|
2016-04-26 22:43:02 +02:00
|
|
|
function deviceName(): string;
|
2016-04-27 02:09:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Derive a unique, consistent serial number of this device from internal data.
|
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId="control_device_serial_number" block="device serial number" weight=9
|
2020-09-08 11:04:25 +02:00
|
|
|
//% help=control/device-serial-number
|
2017-12-14 20:00:47 +01:00
|
|
|
//% advanced=true shim=control::deviceSerialNumber
|
2019-12-02 05:58:26 +01:00
|
|
|
function deviceSerialNumber(): int32;
|
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
/**
|
|
|
|
* Derive a unique, consistent 64-bit serial number of this device from internal data.
|
|
|
|
*/
|
|
|
|
//% help=control/device-long-serial-number
|
|
|
|
//% advanced=true shim=control::deviceLongSerialNumber
|
|
|
|
function deviceLongSerialNumber(): Buffer;
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
/**
|
|
|
|
* Informs simulator/runtime of a MIDI message
|
|
|
|
* Internal function to support the simulator.
|
|
|
|
*/
|
|
|
|
//% part=midioutput blockHidden=1 shim=control::__midiSend
|
|
|
|
function __midiSend(buffer: Buffer): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
//% shim=control::__log
|
2022-03-22 17:36:19 +01:00
|
|
|
function __log(priority: int32, text: string): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates the next user notification event
|
|
|
|
*/
|
|
|
|
//% help=control/allocate-notify-event shim=control::allocateNotifyEvent
|
|
|
|
function allocateNotifyEvent(): int32;
|
|
|
|
|
|
|
|
/** Write a message to DMESG debugging buffer. */
|
|
|
|
//% shim=control::dmesg
|
|
|
|
function dmesg(s: string): void;
|
|
|
|
|
|
|
|
/** Write a message and value (pointer) to DMESG debugging buffer. */
|
|
|
|
//% shim=control::dmesgPtr
|
|
|
|
function dmesgPtr(str: string, ptr: Object): void;
|
|
|
|
}
|
|
|
|
declare namespace control {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Force GC and dump basic information about heap.
|
|
|
|
*/
|
|
|
|
//% shim=control::gc
|
|
|
|
function gc(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Force GC and halt waiting for debugger to do a full heap dump.
|
|
|
|
*/
|
|
|
|
//% shim=control::heapDump
|
|
|
|
function heapDump(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set flags used when connecting an external debugger.
|
|
|
|
*/
|
|
|
|
//% shim=control::setDebugFlags
|
|
|
|
function setDebugFlags(flags: int32): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Record a heap snapshot to debug memory leaks.
|
|
|
|
*/
|
|
|
|
//% shim=control::heapSnapshot
|
|
|
|
function heapSnapshot(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if profiling is enabled in the current build.
|
|
|
|
*/
|
|
|
|
//% shim=control::profilingEnabled
|
|
|
|
function profilingEnabled(): boolean;
|
2016-04-02 02:45:18 +02:00
|
|
|
}
|
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
|
2017-01-20 05:55:31 +01:00
|
|
|
//% color=#8169E6 weight=35 icon="\uf205"
|
2016-04-02 06:52:25 +02:00
|
|
|
declare namespace led {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param x the horizontal coordinate of the LED starting at 0
|
|
|
|
* @param y the vertical coordinate of the LED starting at 0
|
2016-04-02 06:52:25 +02:00
|
|
|
*/
|
2016-04-02 06:53:50 +02:00
|
|
|
//% help=led/plot weight=78
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
2017-12-14 20:00:47 +01:00
|
|
|
//% parts="ledmatrix"
|
2019-12-02 05:58:26 +01:00
|
|
|
//% x.min=0 x.max=4 y.min=0 y.max=4
|
|
|
|
//% x.fieldOptions.precision=1 y.fieldOptions.precision=1 shim=led::plot
|
|
|
|
function plot(x: int32, y: int32): void;
|
2016-04-02 06:52:25 +02:00
|
|
|
|
2017-12-14 20:00:47 +01:00
|
|
|
/**
|
|
|
|
* Turn on the specified LED with specific brightness using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
|
|
|
* @param x the horizontal coordinate of the LED starting at 0
|
|
|
|
* @param y the vertical coordinate of the LED starting at 0
|
|
|
|
* @param brightness the brightness from 0 (off) to 255 (bright), eg:255
|
|
|
|
*/
|
|
|
|
//% help=led/plot-brightness weight=78
|
|
|
|
//% blockId=device_plot_brightness block="plot|x %x|y %y|brightness %brightness" blockGap=8
|
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% x.min=0 x.max=4 y.min=0 y.max=4 brightness.min=0 brightness.max=255
|
2019-12-02 05:58:26 +01:00
|
|
|
//% x.fieldOptions.precision=1 y.fieldOptions.precision=1
|
2017-12-14 20:00:47 +01:00
|
|
|
//% advanced=true shim=led::plotBrightness
|
2019-12-02 05:58:26 +01:00
|
|
|
function plotBrightness(x: int32, y: int32, brightness: int32): void;
|
2017-12-14 20:00:47 +01:00
|
|
|
|
2016-04-02 06:52:25 +02:00
|
|
|
/**
|
|
|
|
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param x the horizontal coordinate of the LED
|
|
|
|
* @param y the vertical coordinate of the LED
|
2016-04-02 06:52:25 +02:00
|
|
|
*/
|
2016-04-02 06:53:50 +02:00
|
|
|
//% help=led/unplot weight=77
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
2017-12-14 20:00:47 +01:00
|
|
|
//% parts="ledmatrix"
|
2019-12-02 05:58:26 +01:00
|
|
|
//% x.min=0 x.max=4 y.min=0 y.max=4
|
|
|
|
//% x.fieldOptions.precision=1 y.fieldOptions.precision=1 shim=led::unplot
|
|
|
|
function unplot(x: int32, y: int32): void;
|
2016-04-02 06:52:25 +02:00
|
|
|
|
|
|
|
/**
|
2020-09-08 11:04:25 +02:00
|
|
|
* Get the brightness state of the specified LED using x, y coordinates. (0,0) is upper left.
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param x the horizontal coordinate of the LED
|
|
|
|
* @param y the vertical coordinate of the LED
|
2016-04-02 06:52:25 +02:00
|
|
|
*/
|
2020-09-08 11:04:25 +02:00
|
|
|
//% help=led/point-brightness weight=76
|
|
|
|
//% blockId=device_point_brightness block="point|x %x|y %y brightness"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% parts="ledmatrix"
|
2019-12-02 05:58:26 +01:00
|
|
|
//% x.min=0 x.max=4 y.min=0 y.max=4
|
2020-09-08 11:04:25 +02:00
|
|
|
//% x.fieldOptions.precision=1 y.fieldOptions.precision=1
|
|
|
|
//% advanced=true shim=led::pointBrightness
|
|
|
|
function pointBrightness(x: int32, y: int32): int32;
|
2016-04-02 06:52:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the screen brightness from 0 (off) to 255 (full bright).
|
|
|
|
*/
|
2016-04-02 06:53:50 +02:00
|
|
|
//% help=led/brightness weight=60
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_get_brightness block="brightness" blockGap=8
|
2016-10-11 22:48:25 +02:00
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% advanced=true shim=led::brightness
|
2019-12-02 05:58:26 +01:00
|
|
|
function brightness(): int32;
|
2016-04-02 06:52:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the screen brightness from 0 (off) to 255 (full bright).
|
|
|
|
* @param value the brightness value, eg:255, 127, 0
|
|
|
|
*/
|
2016-04-02 06:53:50 +02:00
|
|
|
//% help=led/set-brightness weight=59
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_set_brightness block="set brightness %value"
|
2016-10-11 22:48:25 +02:00
|
|
|
//% parts="ledmatrix"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% advanced=true
|
|
|
|
//% value.min=0 value.max=255 shim=led::setBrightness
|
2019-12-02 05:58:26 +01:00
|
|
|
function setBrightness(value: int32): void;
|
2016-04-02 06:52:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancels the current animation and clears other pending animations.
|
|
|
|
*/
|
2016-04-02 06:53:50 +02:00
|
|
|
//% weight=50 help=led/stop-animation
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_stop_animation block="stop animation"
|
2016-10-11 22:48:25 +02:00
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% advanced=true shim=led::stopAnimation
|
2016-04-02 06:52:25 +02:00
|
|
|
function stopAnimation(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the display mode between black and white and greyscale for rendering LEDs.
|
2016-10-28 17:34:04 +02:00
|
|
|
* @param mode mode the display mode in which the screen operates
|
2016-04-02 06:52:25 +02:00
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% weight=1 help=led/set-display-mode
|
2019-12-02 05:58:26 +01:00
|
|
|
//% parts="ledmatrix" advanced=true weight=1
|
|
|
|
//% blockId="led_set_display_mode" block="set display mode $mode" shim=led::setDisplayMode
|
2016-04-02 06:52:25 +02:00
|
|
|
function setDisplayMode(mode: DisplayMode): void;
|
|
|
|
|
2017-12-14 20:00:47 +01:00
|
|
|
/**
|
|
|
|
* Gets the current display mode
|
|
|
|
*/
|
|
|
|
//% weight=1 parts="ledmatrix" advanced=true shim=led::displayMode
|
|
|
|
function displayMode(): DisplayMode;
|
|
|
|
|
2016-10-28 17:34:04 +02:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Turns on or off the display
|
2016-10-28 17:34:04 +02:00
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
2016-10-28 17:34:04 +02:00
|
|
|
//% advanced=true parts="ledmatrix" shim=led::enable
|
|
|
|
function enable(on: boolean): void;
|
|
|
|
|
2016-04-02 06:52:25 +02:00
|
|
|
/**
|
|
|
|
* Takes a screenshot of the LED screen and returns an image.
|
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=led/screenshot
|
|
|
|
//% parts="ledmatrix" shim=led::screenshot
|
2016-04-02 06:52:25 +02:00
|
|
|
function screenshot(): Image;
|
|
|
|
}
|
2016-10-12 07:58:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Blocks to control the onboard motors
|
|
|
|
*/
|
2017-01-20 05:55:31 +01:00
|
|
|
//% color=#008272 weight=30 icon="\uf1b9"
|
2016-10-12 07:58:53 +02:00
|
|
|
declare namespace motors {
|
|
|
|
|
|
|
|
/**
|
2016-11-10 13:48:20 +01:00
|
|
|
* Turns on the motor at a certain percent of power. Switches to single motor mode!
|
2016-10-12 07:58:53 +02:00
|
|
|
* @param power %percent of power sent to the motor. Negative power goes backward. eg: 50
|
|
|
|
*/
|
2020-04-21 04:10:27 +02:00
|
|
|
//% blockId=motor_on block="motor on at %percent \\%"
|
Fix Image the second (#72)
* 2.0.1
* Pointing beta-ref to v2
* Bumping pxt-core to 5.15.10
* 2.0.2
* this repo is empty (#2201)
* Update radio event parm usage descriptions (#2165)
* add browser db prefix for v2 (#2208)
* 2.0.3
* Releasing 2.0.3 to live (#2209)
* dynamically sniff offline app version (#2059)
* Revert "dynamically sniff offline app version (#2059)" (#2211)
This reverts commit b480b34f7e8828794297613a12534f54573a3011.
* Updating electron to 2.0.3 (#2210)
* Updating offline reference to 2.0.3 (#2212)
* Bumping version to 2.1.0
* 2.1.1
* Spelling (#2214)
* Update write-received-packet-to-serial.md (#2217)
A support ticket pointed out issues that they'd encountered when trying to follow this document:
- `sendValue` only supports an 8 character string. This is documented in the `sendValue` docs but a longer string had been used here
- Only `radio.onReceivedNumber` is used so the sample output is not consistent with the users experience. I've changed it so that all packets are handled
* Use gcPreAllocateBlock() to fix #2177, #2215 (#2216)
* Use gcPreAllocateBlock() to fix #2177, #2215
* bump pcp 6.9.4
* 2.1.2
* Correct dice example (#2262)
Changed random(6) to random(5) so the number reflect real dice.
* add 4tronix minibit (#2249)
* Update targetconfig.json (#2258)
remove mock-iot-extension as it is just an experimental development by The Foundation
* Update calibrate-compass.md (#2265)
Based on user feedback in Slack https://microbit-community.slack.com/archives/C1ZMKRFHD/p1563274019078400?thread_ts=1563268925.077500&cid=C1ZMKRFHD
* add wukong (#2239)
* Decrease size of GC heap to allow more DAL allocs (#2246)
* 2.1.3
* add Kitronik view text (#2125)
* Release 2.0.6 to live (#2308)
* Update nexus:bit entry (#2315)
* update nexus:bit entry
* update nexus:bit entry
* Logic Lab mini-course (#2307)
* Logic Lab mini-course
* example syntax
* Updating Readme with branch information.
* bump pxt for ios <=9 fix (#2311)
* Update pxt/common-packages and fix build (#2323)
* fix build off of pxt/ and pxt-common-packages master
* check in generated files
* add-pxt-bmp280 (#2325)
* Bumping pxt-core to 5.19.8 & common-packages to 6.14.9
* 2.1.4
* Error codes page update (#2327)
* Start adding new codes
* few tiny edits
* Add more errors and rearrange
* Update docs/device/error-codes.md
Co-Authored-By: Michał Moskal <michal@moskal.me>
* juggle category
* set error range in hint
Co-Authored-By: Michał Moskal <michal@moskal.me>
* Update docs/device/error-codes.md
Co-Authored-By: Mark <mark@microbit.org>
* fix build (#2360)
* fix broken build
* just try the more 'official' fix if possible
* back to the way that actually works..
* bump pxt to include accessibility changes (#2404)
* 2.1.5
* make hc mode sim color have higher contrast (#2409)
* Show project settings (#2401)
* markdown link fix (#2400)
* add HTS221 (#2384)
* Editor controllers fixes (#2412)
* updated strings
* bump pxt
* anotehr attempt
* 2.1.6
* turn on samples when reading accelerometer (#2413)
* 2.1.7
* hide pin p19/p20 (#2268)
* Fix remove life animation causing microbit stuck (#2314)
On the real microbit board, if the program execute other game blocks while
the remove life animation is playing, it would cause strange behavior or
even make the game stuck.
* Port of Programmable Logic lesson for Logic Lab course (#2359)
* port of programmable logic lesson
* trigger rebuild
* express as logical equation in snippet
* go logical for snippet inputs
* emit enum as bitmask (#2414)
* 2.1.8
* add alt attributes to download screens (#2415)
* add alt attributes to download screens, fixes microsoft/pxt-microbit#2291
* better descriptions
* fixing links in translate page
* Modify the LED coordinates to be between 0 and 4. (#2416)
Without this change, there is a 11/36 chance no LED lights as [`Math.random(a,b)`](https://docs.python.org/2/library/random.html#random.uniform) (thus the `pick random` block) chooses a number in the (inclusive, closed) interval `[a, b]`.
* Set LED plot row/column ranges for 'Reaction Time' (#2420)
* add LIS2MDL (#2385)
* add LIS2DW12 (#2386)
* add LPS22 (#2387)
* add LSM6DSO (#2388)
* add gator environment (#2326)
* add STTS751 (#2389)
* add inventura extension (#2421)
* add new sparkfun extensions (#2238)
* add new sparkfun extensions
* remove gator environment pending fixes
* add dfplayer mini extension (#2417)
* Update 'servo calibrator' link (#2424)
* I2C Addressing Note (#2428)
* I2C on-board sensor address note
* note for 7bit to 8bit shift
* Add nested summaries for newer courses (#2425)
* bump pxt (#2432)
* bump pxt
* bump
* bump
* fix version
* 2.1.9
* bump package.json (#2433)
* 2.1.10
* bump pxt (#2434)
* 2.1.11
* bump for diff3 (#2435)
* enable experiment
* bump pxt
* 2.1.12
* Add the Stu Lowe coding cards (#2438)
* Add the Stu Lowe coding cards
* Move 'Coding Cards' below 'Hardware'
* Add isDeleted (#2445)
* add xinabox OD01 and breakout display section (#2397)
* add xinabox OD01 and breakout display section
* Update targetconfig.json
* Update extensions.md
* Link to power supply limitations (#2443)
Fixes: #2442
* Pxt v5.23.17 (#2446)
* bump pxt
* regen docs
* fix version syntax
* restore extension
* removed dup
* 2.1.13
* add-sw01 (#2393)
* Locking old issues
* add Keyestudio robot car (#2452)
* Allow globals in reclaimed bluetooth memory (#2455)
* isTouchingEdge() should not return true for deleted sprite (#2449)
* add query variant to hide toolbar (#2458)
* Adding link to stable refs (#2460)
* Update extensions.md (#2456)
Move the :VIEW Text32 from other to Display now there is a display sections
* 2.1.14
* fixing radio stack (#2461)
* fixing radio stack
* updated shims
* 2.1.15
* Stable points to latest 2.0.9 (#2469)
* Releasing 2.0.9 to live (#2470)
* Fixing signal strength (#2474)
* Pointing to 2.0.10
* Releasing 2.0.10 (#2476)
With radio strength signal fix for hot or cold
* Removing old bitbot as we have a new bitbot package (#2479)
* updated pxt (#2465)
* updated pxt
* bump pxt
* updated react
* updated ptx
* Remove empty variable element from XML
* Bump pxt-core to 5.25.15
* bump pxt
* Bump pxt to 5.25.17
* Add precision to music slider
* 2.1.16
* add drive:bit (#2484)
* micro:bit RSSI fix (#2480)
* read rssi from packet
* updated shims
* fix build
* fix help
* move deprecated function to ts
* some formatting
* restore rssi block
* restory notations
* actually copy bytes
* removing logging code
* simpler wake up code
* comment
* fix build
* bump pxt
* go back to safety
* bump microbit
* restor package.json
* revert jquery v
* use macro
* check length
* bump pxt (#2490)
* 2.1.17
* Use default resize function for microbit gesture dropdown (#2491)
* Name Badge project page (#2477)
* Name Bagde project page
* gotta please the summary check
* link typo, ugh
* Revert "Name Badge project page (#2477)"
This reverts commit 2e2860632b399485e6b32a2806de34a59c4af9d8.
* add freenove starter kit (#2493)
* radio.setFrequencyBand support (#2495)
* setfrequencyband support
* revert line change
* add bounds check
* Name Badge project page (#2496)
* Name Bagde project page
* gotta please the summary check
* link typo, ugh
* get rid of the pptx
* Simplify the Fahrenheit from Celsius computation. (#2497)
As the micro:bit introduces floating point arithmetic for both the existing `f = 18 * c / 10 + 32` computation and the new `f = 1.8 * c + 32` computation, there isn't any benefit for the former.
* Enable Polish localization (#2499)
* bump package
* 2.1.18
* shrink maintenance gif
* 2.1.19
* Rotary phone dial (#2502)
* some write up
* adding images
* text
* more text
* adding vids
* adding escape room
* remove newer lesson
* remove .mp4
* Card page edits
* adding image
* adding to toys
* rotary edits
* fix typo
* bump pxt 5.28.7 (#2503)
* bump pxt
* bump to pxt 5.28.8
* 2.1.20
* bump pxt 5.28.9 (#2504)
* 2.1.21
* bump pxt 5.28.10
* 2.1.22
* bump pxt 5.28.11
* 2.1.23
* bump pxt 5.28.12
* 2.1.24
* Update README.md
* robot unicorn (#2512)
* robot unicorn
* Edits to the unicorn
* fix missing radio and boardname
* bump pxt 5.28.18 (#2517)
* bump pxt 5.28.18
* updated summary
* 2.1.25
* bump pxt 5.28.21
* 2.1.26
* bump to pxt5.28.23
* 2.1.27
* Add redirect to pins info to serial heading (#2520)
* Add redirect to pins info to serial heading
* adding links
* vump to pxt 5.28.24
* 2.1.28
* bump to pxt 5.28.26
* 2.1.29
* add build instructions
* updated build notes
* bump pxt 5.28.27
* 2.1.30
* missing svg
* remove crowdin project to disable upload from master branch
* reeanble crowdin, no upload
* 2.1.31
* bump pxt common to 6.16.25
* missing radio package
* Fix GC heap reclamation (#2528)
* bump to pxt 5.28.31
* bump pxt 5.28.32
* 2.1.32
* 2.1.33
* fix typo
* pxt-microbit-next? (#2543)
Since the repo https://github.com/microsoft/pxt-microbit-next doesn't exist, I am assuming that the word `next` is not meant to be here.
* Extensions: Add Inksmith Climate Action Kit (#2535)
* Fixes for typos found in Crowdin - 11252019 (#2538)
* Extension: add Kitronik Halo HD (#2541)
* Extension: Add EBOTICS MIBO (#2542)
* add Bright Wearables Brightboard (#2537)
* Docs: Change default value in Javascript. (#2540)
* Change default value in Javascript.
Per @microbit-mark 's suggestion, add an example of how to change the default interval value by switching to Javascript.
* edits to new example
* bump pxt 5.30.6
* 2.1.34
* update git and vscode settings
* revert changes to 2.1.28
* package-lock
* v2.1.34
* Change Hero Image
* add RVR (#2516)
* Extension: add minicruise (#2545)
* Fix minutes display for 'Digital Watch' project (#2547)
* Fix minutes display for 'Digital Watch' project
* minutes less than 10
* bump pxt
* 2.1.35
* updated pxt
* 2.1.36
* package lock
* Tutorial Typo Fix
* staging Servo library support
* bumppxt
* 2.1.37
* update error guide link (#2554)
* adding radio firefly (#2549)
* Update 'Metal Detector' example (#2559)
* bump pxt
* 2.1.38
* typoFix
* package lock
* Update Pins
* Update Pins
* Add C7, C8 and C9 Serial Pins
* Add C7, C8 and C9 Serial Pins
* Pins update
* Add maqueen (#2560)
* Extensions: Add DFRobot Maqueen
* fix
* revert pin C7, C8 and C9
* Update README.md
* add extension doc file
* revert pxt bump
* Docs: Extensions remove headliner
* Remove outdated #ifdef (#2564)
* Extensions: add servobit (#2557)
Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>
* bump to pxt 5.31.8, common 6.18.2
* 2.1.39
* enable github editor experiment (#2568)
* Fix missing sim function
* bump to pxt 5.31.10
* 2.1.40
* Modify snippets/examples relying of fp div (#2571)
* Extensions: add DFRobot natural science board (#2574)
* Extensions: add Kitronik clip dtector (#2576)
Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>
* missing image
* Fix lesson images
* fix images 2
* Add SpeedPicker to Motor Blocks
* add sixth motor pin (M_GND3)
Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>
Co-authored-by: Peli de Halleux <pelikhan@users.noreply.github.com>
Co-authored-by: Galen Nickel <v-gani@microsoft.com>
Co-authored-by: Joey Wunderlich <jwunderl@users.noreply.github.com>
Co-authored-by: Danny Yates <danny@codeaholics.org>
Co-authored-by: Sam Kent <32453267+microbit-sam@users.noreply.github.com>
Co-authored-by: Michał Moskal <michal@moskal.me>
Co-authored-by: Daryl Zuniga <Daryl.Zuniga@gmail.com>
Co-authored-by: Eric Kimsey <ekimsey@users.noreply.github.com>
Co-authored-by: Mark <mark@microbit.org>
Co-authored-by: Richard Knoll <riknoll@users.noreply.github.com>
Co-authored-by: Peter Brodersen <peter@ter.dk>
Co-authored-by: Leo <leo881003@gmail.com>
Co-authored-by: Asher Kach <asher.kach@gmail.com>
Co-authored-by: Franklin Tse <FranklinWhale@users.noreply.github.com>
Co-authored-by: Neal McBurnett <nealmcb@gmail.com>
Co-authored-by: Kitronik Ltd <design@kitronik.co.uk>
Co-authored-by: shakao <34112083+shakao@users.noreply.github.com>
Co-authored-by: Helen Leigh <48659173+helenleigh@users.noreply.github.com>
Co-authored-by: Gerard Braad <me@gbraad.nl>
Co-authored-by: Nicole Parrot <cleoqc1124@gmail.com>
2020-01-21 19:38:36 +01:00
|
|
|
//% parts=dcmotor weight=90 blockGap=8
|
2022-03-22 17:36:19 +01:00
|
|
|
//% percent.shadow="speedPicker"
|
|
|
|
//% power.defl=100 shim=motors::motorPower
|
|
|
|
function motorPower(power?: int32): void;
|
2016-11-03 06:35:00 +01:00
|
|
|
|
|
|
|
/**
|
2016-11-10 13:48:20 +01:00
|
|
|
* Send break, coast or sleep commands to the motor. Has no effect in dual-motor mode.
|
2016-11-03 06:35:00 +01:00
|
|
|
*/
|
|
|
|
//% blockId=motor_command block="motor %command"
|
|
|
|
//% parts=dcmotor weight=85 shim=motors::motorCommand
|
|
|
|
function motorCommand(command: MotorCommand): void;
|
|
|
|
|
|
|
|
/**
|
2016-11-10 13:48:20 +01:00
|
|
|
* Controls two motors attached to the board. Switches to dual-motor mode!
|
2016-11-03 06:35:00 +01:00
|
|
|
*/
|
2020-04-21 04:10:27 +02:00
|
|
|
//% blockId=block_dual_motor block="motor %motor|at %percent \\%"
|
Fix Image the second (#72)
* 2.0.1
* Pointing beta-ref to v2
* Bumping pxt-core to 5.15.10
* 2.0.2
* this repo is empty (#2201)
* Update radio event parm usage descriptions (#2165)
* add browser db prefix for v2 (#2208)
* 2.0.3
* Releasing 2.0.3 to live (#2209)
* dynamically sniff offline app version (#2059)
* Revert "dynamically sniff offline app version (#2059)" (#2211)
This reverts commit b480b34f7e8828794297613a12534f54573a3011.
* Updating electron to 2.0.3 (#2210)
* Updating offline reference to 2.0.3 (#2212)
* Bumping version to 2.1.0
* 2.1.1
* Spelling (#2214)
* Update write-received-packet-to-serial.md (#2217)
A support ticket pointed out issues that they'd encountered when trying to follow this document:
- `sendValue` only supports an 8 character string. This is documented in the `sendValue` docs but a longer string had been used here
- Only `radio.onReceivedNumber` is used so the sample output is not consistent with the users experience. I've changed it so that all packets are handled
* Use gcPreAllocateBlock() to fix #2177, #2215 (#2216)
* Use gcPreAllocateBlock() to fix #2177, #2215
* bump pcp 6.9.4
* 2.1.2
* Correct dice example (#2262)
Changed random(6) to random(5) so the number reflect real dice.
* add 4tronix minibit (#2249)
* Update targetconfig.json (#2258)
remove mock-iot-extension as it is just an experimental development by The Foundation
* Update calibrate-compass.md (#2265)
Based on user feedback in Slack https://microbit-community.slack.com/archives/C1ZMKRFHD/p1563274019078400?thread_ts=1563268925.077500&cid=C1ZMKRFHD
* add wukong (#2239)
* Decrease size of GC heap to allow more DAL allocs (#2246)
* 2.1.3
* add Kitronik view text (#2125)
* Release 2.0.6 to live (#2308)
* Update nexus:bit entry (#2315)
* update nexus:bit entry
* update nexus:bit entry
* Logic Lab mini-course (#2307)
* Logic Lab mini-course
* example syntax
* Updating Readme with branch information.
* bump pxt for ios <=9 fix (#2311)
* Update pxt/common-packages and fix build (#2323)
* fix build off of pxt/ and pxt-common-packages master
* check in generated files
* add-pxt-bmp280 (#2325)
* Bumping pxt-core to 5.19.8 & common-packages to 6.14.9
* 2.1.4
* Error codes page update (#2327)
* Start adding new codes
* few tiny edits
* Add more errors and rearrange
* Update docs/device/error-codes.md
Co-Authored-By: Michał Moskal <michal@moskal.me>
* juggle category
* set error range in hint
Co-Authored-By: Michał Moskal <michal@moskal.me>
* Update docs/device/error-codes.md
Co-Authored-By: Mark <mark@microbit.org>
* fix build (#2360)
* fix broken build
* just try the more 'official' fix if possible
* back to the way that actually works..
* bump pxt to include accessibility changes (#2404)
* 2.1.5
* make hc mode sim color have higher contrast (#2409)
* Show project settings (#2401)
* markdown link fix (#2400)
* add HTS221 (#2384)
* Editor controllers fixes (#2412)
* updated strings
* bump pxt
* anotehr attempt
* 2.1.6
* turn on samples when reading accelerometer (#2413)
* 2.1.7
* hide pin p19/p20 (#2268)
* Fix remove life animation causing microbit stuck (#2314)
On the real microbit board, if the program execute other game blocks while
the remove life animation is playing, it would cause strange behavior or
even make the game stuck.
* Port of Programmable Logic lesson for Logic Lab course (#2359)
* port of programmable logic lesson
* trigger rebuild
* express as logical equation in snippet
* go logical for snippet inputs
* emit enum as bitmask (#2414)
* 2.1.8
* add alt attributes to download screens (#2415)
* add alt attributes to download screens, fixes microsoft/pxt-microbit#2291
* better descriptions
* fixing links in translate page
* Modify the LED coordinates to be between 0 and 4. (#2416)
Without this change, there is a 11/36 chance no LED lights as [`Math.random(a,b)`](https://docs.python.org/2/library/random.html#random.uniform) (thus the `pick random` block) chooses a number in the (inclusive, closed) interval `[a, b]`.
* Set LED plot row/column ranges for 'Reaction Time' (#2420)
* add LIS2MDL (#2385)
* add LIS2DW12 (#2386)
* add LPS22 (#2387)
* add LSM6DSO (#2388)
* add gator environment (#2326)
* add STTS751 (#2389)
* add inventura extension (#2421)
* add new sparkfun extensions (#2238)
* add new sparkfun extensions
* remove gator environment pending fixes
* add dfplayer mini extension (#2417)
* Update 'servo calibrator' link (#2424)
* I2C Addressing Note (#2428)
* I2C on-board sensor address note
* note for 7bit to 8bit shift
* Add nested summaries for newer courses (#2425)
* bump pxt (#2432)
* bump pxt
* bump
* bump
* fix version
* 2.1.9
* bump package.json (#2433)
* 2.1.10
* bump pxt (#2434)
* 2.1.11
* bump for diff3 (#2435)
* enable experiment
* bump pxt
* 2.1.12
* Add the Stu Lowe coding cards (#2438)
* Add the Stu Lowe coding cards
* Move 'Coding Cards' below 'Hardware'
* Add isDeleted (#2445)
* add xinabox OD01 and breakout display section (#2397)
* add xinabox OD01 and breakout display section
* Update targetconfig.json
* Update extensions.md
* Link to power supply limitations (#2443)
Fixes: #2442
* Pxt v5.23.17 (#2446)
* bump pxt
* regen docs
* fix version syntax
* restore extension
* removed dup
* 2.1.13
* add-sw01 (#2393)
* Locking old issues
* add Keyestudio robot car (#2452)
* Allow globals in reclaimed bluetooth memory (#2455)
* isTouchingEdge() should not return true for deleted sprite (#2449)
* add query variant to hide toolbar (#2458)
* Adding link to stable refs (#2460)
* Update extensions.md (#2456)
Move the :VIEW Text32 from other to Display now there is a display sections
* 2.1.14
* fixing radio stack (#2461)
* fixing radio stack
* updated shims
* 2.1.15
* Stable points to latest 2.0.9 (#2469)
* Releasing 2.0.9 to live (#2470)
* Fixing signal strength (#2474)
* Pointing to 2.0.10
* Releasing 2.0.10 (#2476)
With radio strength signal fix for hot or cold
* Removing old bitbot as we have a new bitbot package (#2479)
* updated pxt (#2465)
* updated pxt
* bump pxt
* updated react
* updated ptx
* Remove empty variable element from XML
* Bump pxt-core to 5.25.15
* bump pxt
* Bump pxt to 5.25.17
* Add precision to music slider
* 2.1.16
* add drive:bit (#2484)
* micro:bit RSSI fix (#2480)
* read rssi from packet
* updated shims
* fix build
* fix help
* move deprecated function to ts
* some formatting
* restore rssi block
* restory notations
* actually copy bytes
* removing logging code
* simpler wake up code
* comment
* fix build
* bump pxt
* go back to safety
* bump microbit
* restor package.json
* revert jquery v
* use macro
* check length
* bump pxt (#2490)
* 2.1.17
* Use default resize function for microbit gesture dropdown (#2491)
* Name Badge project page (#2477)
* Name Bagde project page
* gotta please the summary check
* link typo, ugh
* Revert "Name Badge project page (#2477)"
This reverts commit 2e2860632b399485e6b32a2806de34a59c4af9d8.
* add freenove starter kit (#2493)
* radio.setFrequencyBand support (#2495)
* setfrequencyband support
* revert line change
* add bounds check
* Name Badge project page (#2496)
* Name Bagde project page
* gotta please the summary check
* link typo, ugh
* get rid of the pptx
* Simplify the Fahrenheit from Celsius computation. (#2497)
As the micro:bit introduces floating point arithmetic for both the existing `f = 18 * c / 10 + 32` computation and the new `f = 1.8 * c + 32` computation, there isn't any benefit for the former.
* Enable Polish localization (#2499)
* bump package
* 2.1.18
* shrink maintenance gif
* 2.1.19
* Rotary phone dial (#2502)
* some write up
* adding images
* text
* more text
* adding vids
* adding escape room
* remove newer lesson
* remove .mp4
* Card page edits
* adding image
* adding to toys
* rotary edits
* fix typo
* bump pxt 5.28.7 (#2503)
* bump pxt
* bump to pxt 5.28.8
* 2.1.20
* bump pxt 5.28.9 (#2504)
* 2.1.21
* bump pxt 5.28.10
* 2.1.22
* bump pxt 5.28.11
* 2.1.23
* bump pxt 5.28.12
* 2.1.24
* Update README.md
* robot unicorn (#2512)
* robot unicorn
* Edits to the unicorn
* fix missing radio and boardname
* bump pxt 5.28.18 (#2517)
* bump pxt 5.28.18
* updated summary
* 2.1.25
* bump pxt 5.28.21
* 2.1.26
* bump to pxt5.28.23
* 2.1.27
* Add redirect to pins info to serial heading (#2520)
* Add redirect to pins info to serial heading
* adding links
* vump to pxt 5.28.24
* 2.1.28
* bump to pxt 5.28.26
* 2.1.29
* add build instructions
* updated build notes
* bump pxt 5.28.27
* 2.1.30
* missing svg
* remove crowdin project to disable upload from master branch
* reeanble crowdin, no upload
* 2.1.31
* bump pxt common to 6.16.25
* missing radio package
* Fix GC heap reclamation (#2528)
* bump to pxt 5.28.31
* bump pxt 5.28.32
* 2.1.32
* 2.1.33
* fix typo
* pxt-microbit-next? (#2543)
Since the repo https://github.com/microsoft/pxt-microbit-next doesn't exist, I am assuming that the word `next` is not meant to be here.
* Extensions: Add Inksmith Climate Action Kit (#2535)
* Fixes for typos found in Crowdin - 11252019 (#2538)
* Extension: add Kitronik Halo HD (#2541)
* Extension: Add EBOTICS MIBO (#2542)
* add Bright Wearables Brightboard (#2537)
* Docs: Change default value in Javascript. (#2540)
* Change default value in Javascript.
Per @microbit-mark 's suggestion, add an example of how to change the default interval value by switching to Javascript.
* edits to new example
* bump pxt 5.30.6
* 2.1.34
* update git and vscode settings
* revert changes to 2.1.28
* package-lock
* v2.1.34
* Change Hero Image
* add RVR (#2516)
* Extension: add minicruise (#2545)
* Fix minutes display for 'Digital Watch' project (#2547)
* Fix minutes display for 'Digital Watch' project
* minutes less than 10
* bump pxt
* 2.1.35
* updated pxt
* 2.1.36
* package lock
* Tutorial Typo Fix
* staging Servo library support
* bumppxt
* 2.1.37
* update error guide link (#2554)
* adding radio firefly (#2549)
* Update 'Metal Detector' example (#2559)
* bump pxt
* 2.1.38
* typoFix
* package lock
* Update Pins
* Update Pins
* Add C7, C8 and C9 Serial Pins
* Add C7, C8 and C9 Serial Pins
* Pins update
* Add maqueen (#2560)
* Extensions: Add DFRobot Maqueen
* fix
* revert pin C7, C8 and C9
* Update README.md
* add extension doc file
* revert pxt bump
* Docs: Extensions remove headliner
* Remove outdated #ifdef (#2564)
* Extensions: add servobit (#2557)
Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>
* bump to pxt 5.31.8, common 6.18.2
* 2.1.39
* enable github editor experiment (#2568)
* Fix missing sim function
* bump to pxt 5.31.10
* 2.1.40
* Modify snippets/examples relying of fp div (#2571)
* Extensions: add DFRobot natural science board (#2574)
* Extensions: add Kitronik clip dtector (#2576)
Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>
* missing image
* Fix lesson images
* fix images 2
* Add SpeedPicker to Motor Blocks
* add sixth motor pin (M_GND3)
Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>
Co-authored-by: Peli de Halleux <pelikhan@users.noreply.github.com>
Co-authored-by: Galen Nickel <v-gani@microsoft.com>
Co-authored-by: Joey Wunderlich <jwunderl@users.noreply.github.com>
Co-authored-by: Danny Yates <danny@codeaholics.org>
Co-authored-by: Sam Kent <32453267+microbit-sam@users.noreply.github.com>
Co-authored-by: Michał Moskal <michal@moskal.me>
Co-authored-by: Daryl Zuniga <Daryl.Zuniga@gmail.com>
Co-authored-by: Eric Kimsey <ekimsey@users.noreply.github.com>
Co-authored-by: Mark <mark@microbit.org>
Co-authored-by: Richard Knoll <riknoll@users.noreply.github.com>
Co-authored-by: Peter Brodersen <peter@ter.dk>
Co-authored-by: Leo <leo881003@gmail.com>
Co-authored-by: Asher Kach <asher.kach@gmail.com>
Co-authored-by: Franklin Tse <FranklinWhale@users.noreply.github.com>
Co-authored-by: Neal McBurnett <nealmcb@gmail.com>
Co-authored-by: Kitronik Ltd <design@kitronik.co.uk>
Co-authored-by: shakao <34112083+shakao@users.noreply.github.com>
Co-authored-by: Helen Leigh <48659173+helenleigh@users.noreply.github.com>
Co-authored-by: Gerard Braad <me@gbraad.nl>
Co-authored-by: Nicole Parrot <cleoqc1124@gmail.com>
2020-01-21 19:38:36 +01:00
|
|
|
//% percent.shadow="speedPicker"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% weight=80
|
|
|
|
//% duty_percent.defl=100 shim=motors::dualMotorPower
|
|
|
|
function dualMotorPower(motor: Motor, duty_percent?: int32): void;
|
2016-10-12 07:58:53 +02:00
|
|
|
}
|
2016-10-27 19:48:42 +02:00
|
|
|
declare namespace music {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays a tone through ``speaker`` for the given duration.
|
|
|
|
* @param frequency pitch of the tone to play in Hertz (Hz)
|
|
|
|
* @param ms tone duration in milliseconds (ms)
|
|
|
|
*/
|
2017-12-14 19:34:04 +01:00
|
|
|
//%
|
|
|
|
//% parts="speaker" async useEnumVal=1 shim=music::speakerPlayTone
|
2019-12-02 05:58:26 +01:00
|
|
|
function speakerPlayTone(frequency: int32, ms: int32): void;
|
2022-03-22 17:36:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the default output volume of the sound synthesizer.
|
|
|
|
* @param volume the volume 0...255
|
|
|
|
*/
|
|
|
|
//% blockId=synth_set_volume block="set volume %volume"
|
|
|
|
//% volume.min=0 volume.max=255
|
|
|
|
//%
|
|
|
|
//% help=music/set-volume
|
|
|
|
//% weight=70
|
|
|
|
//% group="Volume"
|
|
|
|
//% blockGap=8
|
|
|
|
//% blockHidden=true volume.defl=127 shim=music::setVolume
|
|
|
|
function setVolume(volume?: int32): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current output volume of the sound synthesizer.
|
|
|
|
*/
|
|
|
|
//% blockId=synth_get_volume block="volume"
|
|
|
|
//% help=music/volume
|
|
|
|
//% weight=69
|
|
|
|
//% group="Volume"
|
|
|
|
//% blockGap=8
|
|
|
|
//% blockHidden=true shim=music::volume
|
|
|
|
function volume(): int32;
|
2016-10-27 19:48:42 +02:00
|
|
|
}
|
2016-04-02 06:26:06 +02:00
|
|
|
declare namespace pins {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read the specified pin or connector as either 0 or 1
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param name pin to read from, eg: DigitalPin.P0
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=pins/digital-read-pin weight=30
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
|
|
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
|
|
|
|
//% group="Digital" shim=pins::digitalReadPin
|
2019-12-02 05:58:26 +01:00
|
|
|
function digitalReadPin(name: DigitalPin): int32;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a pin or connector value to either 0 or 1.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param name pin to write to, eg: DigitalPin.P0
|
2016-04-02 06:26:06 +02:00
|
|
|
* @param value value to set on the pin, 1 eg,0
|
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=pins/digital-write-pin weight=29
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value"
|
|
|
|
//% value.min=0 value.max=1
|
|
|
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
|
|
|
|
//% group="Digital" shim=pins::digitalWritePin
|
2019-12-02 05:58:26 +01:00
|
|
|
function digitalWritePin(name: DigitalPin, value: int32): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
2020-09-11 11:19:33 +02:00
|
|
|
* @param name pin to write to, eg: AnalogPin.P1
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=pins/analog-read-pin weight=25
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
|
|
|
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
|
|
|
|
//% group="Analog" shim=pins::analogReadPin
|
2019-12-02 05:58:26 +01:00
|
|
|
function analogReadPin(name: AnalogPin): int32;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
2020-09-11 11:19:33 +02:00
|
|
|
* @param name pin name to write to, eg: AnalogPin.P1
|
2016-04-02 06:26:06 +02:00
|
|
|
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=pins/analog-write-pin weight=24
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8
|
|
|
|
//% value.min=0 value.max=1023
|
|
|
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
|
|
|
|
//% group="Analog" shim=pins::analogWritePin
|
2019-12-02 05:58:26 +01:00
|
|
|
function analogWritePin(name: AnalogPin, value: int32): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Configure the pulse-width modulation (PWM) period of the analog output in microseconds.
|
2016-04-02 06:26:06 +02:00
|
|
|
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
2020-09-11 11:19:33 +02:00
|
|
|
* @param name analog pin to set period to, eg: AnalogPin.P1
|
2016-04-02 06:26:06 +02:00
|
|
|
* @param micros period in micro seconds. eg:20000
|
|
|
|
*/
|
2016-05-25 06:39:57 +02:00
|
|
|
//% help=pins/analog-set-period weight=23 blockGap=8
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros"
|
|
|
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% pin.fieldOptions.tooltips="false"
|
|
|
|
//% group="Analog" shim=pins::analogSetPeriod
|
2019-12-02 05:58:26 +01:00
|
|
|
function analogSetPeriod(name: AnalogPin, micros: int32): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
2016-05-17 01:24:44 +02:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Configure the pin as a digital input and generate an event when the pin is pulsed either high or low.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param name digital pin to register to, eg: DigitalPin.P0
|
|
|
|
* @param pulse the value of the pulse, eg: PulseValue.High
|
2016-05-17 01:24:44 +02:00
|
|
|
*/
|
2019-12-02 05:58:26 +01:00
|
|
|
//% help=pins/on-pulsed weight=22 blockGap=16 advanced=true
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
|
|
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
|
|
|
|
//% group="Pulse" shim=pins::onPulsed
|
2016-05-17 01:24:44 +02:00
|
|
|
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
|
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Get the duration of the last pulse in microseconds. This function should be called from a ``onPulsed`` handler.
|
2016-05-17 01:24:44 +02:00
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=pins/pulse-duration advanced=true
|
2016-05-25 06:39:57 +02:00
|
|
|
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
2022-06-30 19:01:19 +02:00
|
|
|
//% weight=21 blockGap=8
|
|
|
|
//% group="Pulse" shim=pins::pulseDuration
|
2019-12-02 05:58:26 +01:00
|
|
|
function pulseDuration(): int32;
|
2016-05-17 01:24:44 +02:00
|
|
|
|
2016-08-17 20:18:15 +02:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Return the duration of a pulse at a pin in microseconds.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param name the pin which measures the pulse, eg: DigitalPin.P0
|
|
|
|
* @param value the value of the pulse, eg: PulseValue.High
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param maximum duration in microseconds
|
2016-08-17 20:18:15 +02:00
|
|
|
*/
|
2016-08-17 20:35:54 +02:00
|
|
|
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% weight=20 advanced=true
|
|
|
|
//% help=pins/pulse-in
|
|
|
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
|
|
|
|
//% group="Pulse" maxDuration.defl=2000000 shim=pins::pulseIn
|
2019-12-02 05:58:26 +01:00
|
|
|
function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: int32): int32;
|
2016-08-17 20:18:15 +02:00
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Write a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
2020-09-11 11:19:33 +02:00
|
|
|
* @param name pin to write to, eg: AnalogPin.P1
|
2016-04-02 06:26:06 +02:00
|
|
|
* @param value angle or rotation speed, eg:180,90,0
|
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=pins/servo-write-pin weight=20
|
2016-11-01 16:16:03 +01:00
|
|
|
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
|
2017-12-14 20:00:47 +01:00
|
|
|
//% parts=microservo trackArgs=0
|
|
|
|
//% value.min=0 value.max=180
|
|
|
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
|
|
|
|
//% group="Servo" shim=pins::servoWritePin
|
2019-12-02 05:58:26 +01:00
|
|
|
function servoWritePin(name: AnalogPin, value: int32): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
2020-02-15 22:16:34 +01:00
|
|
|
/**
|
|
|
|
* Specifies that a continuous servo is connected.
|
|
|
|
*/
|
2022-06-30 19:01:19 +02:00
|
|
|
//%
|
|
|
|
//% group="Servo" shim=pins::servoSetContinuous
|
2020-02-15 22:16:34 +01:00
|
|
|
function servoSetContinuous(name: AnalogPin, value: boolean): void;
|
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Configure the IO pin as an analog/pwm output and set a pulse width. The period is 20 ms period and the pulse width is set based on the value given in **microseconds** or `1/1000` milliseconds.
|
2016-04-02 06:26:06 +02:00
|
|
|
* @param name pin name
|
|
|
|
* @param micros pulse duration in micro seconds, eg:1500
|
|
|
|
*/
|
2016-08-10 22:10:40 +02:00
|
|
|
//% help=pins/servo-set-pulse weight=19
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros"
|
|
|
|
//% value.fieldEditor="gridpicker" value.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% value.fieldOptions.tooltips="false" value.fieldOptions.width="250"
|
|
|
|
//% group="Servo" shim=pins::servoSetPulse
|
2019-12-02 05:58:26 +01:00
|
|
|
function servoSetPulse(name: AnalogPin, micros: int32): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Set the pin used when using analog pitch or music.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param name pin to modulate pitch from
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2017-01-30 20:19:54 +01:00
|
|
|
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=pins/analog-set-pitch-pin weight=3 advanced=true
|
|
|
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
2022-03-22 17:36:19 +01:00
|
|
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
|
2022-06-30 19:01:19 +02:00
|
|
|
//% blockHidden=true
|
|
|
|
//% group="Pitch" shim=pins::analogSetPitchPin
|
2016-04-02 06:52:25 +02:00
|
|
|
function analogSetPitchPin(name: AnalogPin): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
2020-09-08 11:04:25 +02:00
|
|
|
* Sets the volume on the pitch pin
|
|
|
|
* @param volume the intensity of the sound from 0..255
|
|
|
|
*/
|
|
|
|
//% blockId=device_analog_set_pitch_volume block="analog set pitch volume $volume"
|
|
|
|
//% help=pins/analog-set-pitch-volume weight=3 advanced=true
|
2022-03-22 17:36:19 +01:00
|
|
|
//% volume.min=0 volume.max=255
|
2022-06-30 19:01:19 +02:00
|
|
|
//% blockHidden=true
|
|
|
|
//% group="Pitch" shim=pins::analogSetPitchVolume
|
2020-09-08 11:04:25 +02:00
|
|
|
function analogSetPitchVolume(volume: int32): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the volume the pitch pin from 0..255
|
|
|
|
*/
|
|
|
|
//% blockId=device_analog_pitch_volume block="analog pitch volume"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=pins/analog-pitch-volume weight=3 advanced=true
|
2022-06-30 19:01:19 +02:00
|
|
|
//% blockHidden=true
|
|
|
|
//% group="Pitch" shim=pins::analogPitchVolume
|
2020-09-08 11:04:25 +02:00
|
|
|
function analogPitchVolume(): int32;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Emit a plse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param frequency frequency to modulate in Hz.
|
|
|
|
* @param ms duration of the pitch in milli seconds.
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2017-01-30 20:19:54 +01:00
|
|
|
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8
|
2022-06-30 19:01:19 +02:00
|
|
|
//% blockHidden=true
|
|
|
|
//% group="Pitch" shim=pins::analogPitch
|
2019-12-02 05:58:26 +01:00
|
|
|
function analogPitch(frequency: int32, ms: int32): void;
|
2016-04-04 01:52:57 +02:00
|
|
|
|
2016-06-04 08:15:51 +02:00
|
|
|
/**
|
2020-09-08 11:04:25 +02:00
|
|
|
* Configure the pull directiion of of a pin.
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param name pin to set the pull mode on, eg: DigitalPin.P0
|
|
|
|
* @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp
|
2016-06-04 08:15:51 +02:00
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=pins/set-pull weight=3 advanced=true
|
|
|
|
//% blockId=device_set_pull block="set pull|pin %pin|to %pull"
|
|
|
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
|
|
|
|
//% group="Digital" shim=pins::setPull
|
2016-06-04 08:15:51 +02:00
|
|
|
function setPull(name: DigitalPin, pull: PinPullMode): void;
|
|
|
|
|
2017-01-30 20:19:54 +01:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Configure the events emitted by this pin. Events can be subscribed to
|
2017-01-30 20:19:54 +01:00
|
|
|
* using ``control.onEvent()``.
|
|
|
|
* @param name pin to set the event mode on, eg: DigitalPin.P0
|
|
|
|
* @param type the type of events for this pin to emit, eg: PinEventType.Edge
|
|
|
|
*/
|
|
|
|
//% help=pins/set-events weight=4 advanced=true
|
2017-12-14 20:00:47 +01:00
|
|
|
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events"
|
|
|
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
|
|
|
|
//% group="Digital" shim=pins::setEvents
|
2017-01-30 20:19:54 +01:00
|
|
|
function setEvents(name: DigitalPin, type: PinEventType): void;
|
|
|
|
|
2016-04-04 01:52:57 +02:00
|
|
|
/**
|
|
|
|
* Create a new zero-initialized buffer.
|
|
|
|
* @param size number of bytes in the buffer
|
|
|
|
*/
|
|
|
|
//% shim=pins::createBuffer
|
2019-12-02 05:58:26 +01:00
|
|
|
function createBuffer(size: int32): Buffer;
|
2016-04-05 04:02:40 +02:00
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
/**
|
|
|
|
* Set the matrix width for Neopixel strip (already assigned to a pin).
|
|
|
|
* Should be used in conjunction with `set matrix width` from Neopixel package.
|
|
|
|
* @param name pin of Neopixel strip, eg: DigitalPin.P1
|
|
|
|
* @param value width of matrix (at least ``2``)
|
|
|
|
*/
|
|
|
|
//% help=pins/neopixel-matrix-width weight=3 advanced=true
|
|
|
|
//% blockId=pin_neopixel_matrix_width block="neopixel matrix width|pin %pin %width" blockGap=8
|
|
|
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
|
|
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
|
|
|
|
//% width.min=2
|
|
|
|
//% blockHidden=true width.defl=5 shim=pins::setMatrixWidth
|
|
|
|
function setMatrixWidth(pin: DigitalPin, width?: int32): void;
|
|
|
|
|
2016-04-05 04:02:40 +02:00
|
|
|
/**
|
|
|
|
* Read `size` bytes from a 7-bit I2C `address`.
|
|
|
|
*/
|
2022-06-30 19:01:19 +02:00
|
|
|
//%
|
|
|
|
//% group="i2c" repeat.defl=0 shim=pins::i2cReadBuffer
|
2019-12-02 05:58:26 +01:00
|
|
|
function i2cReadBuffer(address: int32, size: int32, repeat?: boolean): Buffer;
|
2016-04-05 04:02:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write bytes to a 7-bit I2C `address`.
|
|
|
|
*/
|
2022-06-30 19:01:19 +02:00
|
|
|
//%
|
|
|
|
//% group="i2c" repeat.defl=0 shim=pins::i2cWriteBuffer
|
2019-12-02 05:58:26 +01:00
|
|
|
function i2cWriteBuffer(address: int32, buf: Buffer, repeat?: boolean): int32;
|
2016-08-11 08:26:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write to the SPI slave and return the response
|
|
|
|
* @param value Data to be sent to the SPI slave
|
|
|
|
*/
|
2017-12-14 20:00:47 +01:00
|
|
|
//% help=pins/spi-write weight=5 advanced=true
|
2022-06-30 19:01:19 +02:00
|
|
|
//% blockId=spi_write block="spi write %value"
|
|
|
|
//% group="spi" shim=pins::spiWrite
|
2019-12-02 05:58:26 +01:00
|
|
|
function spiWrite(value: int32): int32;
|
2017-12-14 20:00:47 +01:00
|
|
|
|
2020-09-08 11:04:25 +02:00
|
|
|
/**
|
|
|
|
* Write to and read from the SPI slave at the same time
|
|
|
|
* @param command Data to be sent to the SPI slave (can be null)
|
|
|
|
* @param response Data received from the SPI slave (can be null)
|
|
|
|
*/
|
2022-06-30 19:01:19 +02:00
|
|
|
//% help=pins/spi-transfer argsNullable
|
|
|
|
//% group="spi" shim=pins::spiTransfer
|
2020-09-08 11:04:25 +02:00
|
|
|
function spiTransfer(command: Buffer, response: Buffer): void;
|
|
|
|
|
2017-12-14 20:00:47 +01:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Set the SPI frequency
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param frequency the clock frequency, eg: 1000000
|
|
|
|
*/
|
|
|
|
//% help=pins/spi-frequency weight=4 advanced=true
|
2022-06-30 19:01:19 +02:00
|
|
|
//% blockId=spi_frequency block="spi frequency %frequency"
|
|
|
|
//% group="spi" shim=pins::spiFrequency
|
2019-12-02 05:58:26 +01:00
|
|
|
function spiFrequency(frequency: int32): void;
|
2017-12-14 20:00:47 +01:00
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Set the SPI bits and mode
|
2017-12-14 20:00:47 +01:00
|
|
|
* @param bits the number of bits, eg: 8
|
|
|
|
* @param mode the mode, eg: 3
|
|
|
|
*/
|
|
|
|
//% help=pins/spi-format weight=3 advanced=true
|
2022-06-30 19:01:19 +02:00
|
|
|
//% blockId=spi_format block="spi format|bits %bits|mode %mode"
|
|
|
|
//% group="spi" shim=pins::spiFormat
|
2019-12-02 05:58:26 +01:00
|
|
|
function spiFormat(bits: int32, mode: int32): void;
|
2017-12-14 20:00:47 +01:00
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Set the MOSI, MISO, SCK pins used by the SPI connection
|
2017-12-14 20:00:47 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
//% help=pins/spi-pins weight=2 advanced=true
|
|
|
|
//% blockId=spi_pins block="spi set pins|MOSI %mosi|MISO %miso|SCK %sck"
|
|
|
|
//% mosi.fieldEditor="gridpicker" mosi.fieldOptions.columns=4
|
2019-12-02 05:58:26 +01:00
|
|
|
//% mosi.fieldOptions.tooltips="false" mosi.fieldOptions.width="250"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% miso.fieldEditor="gridpicker" miso.fieldOptions.columns=4
|
2019-12-02 05:58:26 +01:00
|
|
|
//% miso.fieldOptions.tooltips="false" miso.fieldOptions.width="250"
|
2017-12-14 20:00:47 +01:00
|
|
|
//% sck.fieldEditor="gridpicker" sck.fieldOptions.columns=4
|
2022-06-30 19:01:19 +02:00
|
|
|
//% sck.fieldOptions.tooltips="false" sck.fieldOptions.width="250"
|
|
|
|
//% group="spi" shim=pins::spiPins
|
2017-12-14 20:00:47 +01:00
|
|
|
function spiPins(mosi: DigitalPin, miso: DigitalPin, sck: DigitalPin): void;
|
2020-09-08 11:04:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mounts a push button on the given pin
|
|
|
|
*/
|
2022-06-30 19:01:19 +02:00
|
|
|
//% help=pins/push-button advanced=true
|
|
|
|
//% group="Digital" shim=pins::pushButton
|
2020-09-08 11:04:25 +02:00
|
|
|
function pushButton(pin: DigitalPin): void;
|
2022-03-22 17:36:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the pin used when producing sounds and melodies. Default is P0.
|
|
|
|
* @param name pin to modulate pitch from
|
|
|
|
*/
|
|
|
|
//% blockId=pin_set_audio_pin block="set audio pin $name"
|
|
|
|
//% help=pins/set-audio-pin weight=3
|
|
|
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
|
|
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
|
|
|
|
//% weight=1
|
2022-06-30 19:01:19 +02:00
|
|
|
//% blockHidden=true
|
|
|
|
//% group="Pitch" shim=pins::setAudioPin
|
2022-03-22 17:36:19 +01:00
|
|
|
function setAudioPin(name: AnalogPin): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
}
|
|
|
|
|
2016-04-02 07:00:42 +02:00
|
|
|
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
//% weight=2 color=#002050 icon="\uf287"
|
2016-10-11 22:48:25 +02:00
|
|
|
//% advanced=true
|
2016-04-02 07:00:42 +02:00
|
|
|
declare namespace serial {
|
|
|
|
|
2016-10-19 06:36:42 +02:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Read a line of text from the serial port and return the buffer when the delimiter is met.
|
2016-10-19 06:36:42 +02:00
|
|
|
* @param delimiter text delimiter that separates each text chunk
|
|
|
|
*/
|
|
|
|
//% help=serial/read-until
|
|
|
|
//% blockId=serial_read_until block="serial|read until %delimiter=serial_delimiter_conv"
|
|
|
|
//% weight=19 shim=serial::readUntil
|
|
|
|
function readUntil(delimiter: string): string;
|
|
|
|
|
2016-04-02 07:00:42 +02:00
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Read the buffered received data as a string
|
2016-04-02 07:00:42 +02:00
|
|
|
*/
|
2019-12-02 05:58:26 +01:00
|
|
|
//% help=serial/read-string
|
2017-01-10 19:26:44 +01:00
|
|
|
//% blockId=serial_read_buffer block="serial|read string"
|
|
|
|
//% weight=18 shim=serial::readString
|
|
|
|
function readString(): string;
|
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Register an event to be fired when one of the delimiter is matched.
|
2017-01-10 19:26:44 +01:00
|
|
|
* @param delimiters the characters to match received characters against.
|
|
|
|
*/
|
|
|
|
//% help=serial/on-data-received
|
|
|
|
//% weight=18 blockId=serial_on_data_received block="serial|on data received %delimiters=serial_delimiter_conv" shim=serial::onDataReceived
|
|
|
|
function onDataReceived(delimiters: string, body: () => void): void;
|
2016-04-02 07:00:42 +02:00
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Send a piece of text through the serial connection.
|
2016-04-02 07:00:42 +02:00
|
|
|
*/
|
2016-05-17 18:36:01 +02:00
|
|
|
//% help=serial/write-string
|
2019-12-02 05:58:26 +01:00
|
|
|
//% weight=87 blockGap=8
|
|
|
|
//% blockId=serial_writestring block="serial|write string %text"
|
|
|
|
//% text.shadowOptions.toString=true shim=serial::writeString
|
2016-04-02 07:00:42 +02:00
|
|
|
function writeString(text: string): void;
|
2016-05-26 20:07:09 +02:00
|
|
|
|
|
|
|
/**
|
2019-12-02 05:58:26 +01:00
|
|
|
* Send a buffer through serial connection
|
|
|
|
*/
|
|
|
|
//% blockId=serial_writebuffer block="serial|write buffer %buffer=serial_readbuffer"
|
|
|
|
//% help=serial/write-buffer advanced=true weight=6 shim=serial::writeBuffer
|
|
|
|
function writeBuffer(buffer: Buffer): void;
|
|
|
|
|
|
|
|
/**
|
2022-03-22 17:36:19 +01:00
|
|
|
* Read multiple characters from the receive buffer.
|
|
|
|
* If length is positive, pauses until enough characters are present.
|
|
|
|
* @param length default buffer length
|
2019-12-02 05:58:26 +01:00
|
|
|
*/
|
|
|
|
//% blockId=serial_readbuffer block="serial|read buffer %length"
|
|
|
|
//% help=serial/read-buffer advanced=true weight=5 shim=serial::readBuffer
|
|
|
|
function readBuffer(length: int32): Buffer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the serial input and output to use pins instead of the USB connection.
|
|
|
|
* @param tx the new transmission pin, eg: SerialPin.P0
|
2017-02-13 11:44:00 +01:00
|
|
|
* @param rx the new reception pin, eg: SerialPin.P1
|
|
|
|
* @param rate the new baud rate. eg: 115200
|
2016-05-26 20:07:09 +02:00
|
|
|
*/
|
|
|
|
//% weight=10
|
2019-12-02 05:58:26 +01:00
|
|
|
//% help=serial/redirect
|
2016-10-19 06:36:42 +02:00
|
|
|
//% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
|
2019-12-02 05:58:26 +01:00
|
|
|
//% blockExternalInputs=1
|
|
|
|
//% tx.fieldEditor="gridpicker" tx.fieldOptions.columns=3
|
|
|
|
//% tx.fieldOptions.tooltips="false"
|
|
|
|
//% rx.fieldEditor="gridpicker" rx.fieldOptions.columns=3
|
|
|
|
//% rx.fieldOptions.tooltips="false"
|
|
|
|
//% blockGap=8 shim=serial::redirect
|
2016-05-26 20:07:09 +02:00
|
|
|
function redirect(tx: SerialPin, rx: SerialPin, rate: BaudRate): void;
|
2019-12-02 05:58:26 +01:00
|
|
|
|
2020-09-08 11:04:25 +02:00
|
|
|
/**
|
|
|
|
Set the baud rate of the serial port
|
|
|
|
*/
|
|
|
|
//% weight=10
|
|
|
|
//% blockId=serial_setbaudrate block="serial|set baud rate %rate"
|
|
|
|
//% blockGap=8 inlineInputMode=inline
|
|
|
|
//% help=serial/set-baud-rate
|
|
|
|
//% group="Configuration" advanced=true shim=serial::setBaudRate
|
|
|
|
function setBaudRate(rate: BaudRate): void;
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
/**
|
|
|
|
* Direct the serial input and output to use the USB connection.
|
|
|
|
*/
|
|
|
|
//% weight=9 help=serial/redirect-to-usb
|
|
|
|
//% blockId=serial_redirect_to_usb block="serial|redirect to USB" shim=serial::redirectToUSB
|
|
|
|
function redirectToUSB(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the size of the RX buffer in bytes
|
|
|
|
* @param size length of the rx buffer in bytes, eg: 32
|
|
|
|
*/
|
|
|
|
//% help=serial/set-rx-buffer-size
|
|
|
|
//% blockId=serialSetRxBufferSize block="serial set rx buffer size to $size"
|
|
|
|
//% advanced=true shim=serial::setRxBufferSize
|
|
|
|
function setRxBufferSize(size: uint8): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the size of the TX buffer in bytes
|
|
|
|
* @param size length of the tx buffer in bytes, eg: 32
|
|
|
|
*/
|
|
|
|
//% help=serial/set-tx-buffer-size
|
|
|
|
//% blockId=serialSetTxBufferSize block="serial set tx buffer size to $size"
|
|
|
|
//% advanced=true shim=serial::setTxBufferSize
|
|
|
|
function setTxBufferSize(size: uint8): void;
|
2016-04-02 07:00:42 +02:00
|
|
|
}
|
|
|
|
|
2016-04-04 01:52:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
//% indexerGet=BufferMethods::getByte indexerSet=BufferMethods::setByte
|
|
|
|
declare interface Buffer {
|
2019-12-02 05:58:26 +01:00
|
|
|
/**
|
|
|
|
* Reads an unsigned byte at a particular location
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::getUint8
|
|
|
|
getUint8(off: int32): int32;
|
|
|
|
|
2020-01-06 23:19:55 +01:00
|
|
|
/**
|
|
|
|
* Returns false when the buffer can be written to.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::isReadOnly
|
|
|
|
isReadOnly(): boolean;
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
/**
|
|
|
|
* Writes an unsigned byte at a particular location
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::setUint8
|
|
|
|
setUint8(off: int32, v: int32): void;
|
|
|
|
|
2016-04-05 04:02:40 +02:00
|
|
|
/**
|
|
|
|
* Write a number in specified format in the buffer.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::setNumber
|
2019-12-02 05:58:26 +01:00
|
|
|
setNumber(format: NumberFormat, offset: int32, value: number): void;
|
2016-04-05 04:02:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read a number in specified format from the buffer.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::getNumber
|
2019-12-02 05:58:26 +01:00
|
|
|
getNumber(format: NumberFormat, offset: int32): number;
|
2016-04-05 04:02:40 +02:00
|
|
|
|
2016-04-04 01:52:57 +02:00
|
|
|
/** Returns the length of a Buffer object. */
|
|
|
|
//% property shim=BufferMethods::length
|
2019-12-02 05:58:26 +01:00
|
|
|
length: int32;
|
2016-04-04 01:52:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill (a fragment) of the buffer with given value.
|
|
|
|
*/
|
|
|
|
//% offset.defl=0 length.defl=-1 shim=BufferMethods::fill
|
2019-12-02 05:58:26 +01:00
|
|
|
fill(value: int32, offset?: int32, length?: int32): void;
|
2016-04-04 01:52:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a copy of a fragment of a buffer.
|
|
|
|
*/
|
|
|
|
//% offset.defl=0 length.defl=-1 shim=BufferMethods::slice
|
2019-12-02 05:58:26 +01:00
|
|
|
slice(offset?: int32, length?: int32): Buffer;
|
2016-04-04 01:52:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shift buffer left in place, with zero padding.
|
|
|
|
* @param offset number of bytes to shift; use negative value to shift right
|
2016-08-04 17:42:47 +02:00
|
|
|
* @param start start offset in buffer. Default is 0.
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param length number of elements in buffer. If negative, length is set as the buffer length minus
|
|
|
|
* start. eg: -1
|
2016-04-04 01:52:57 +02:00
|
|
|
*/
|
2016-08-04 17:42:47 +02:00
|
|
|
//% start.defl=0 length.defl=-1 shim=BufferMethods::shift
|
2019-12-02 05:58:26 +01:00
|
|
|
shift(offset: int32, start?: int32, length?: int32): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a buffer to string assuming UTF8 encoding
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::toString
|
|
|
|
toString(): string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a buffer to its hexadecimal representation.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::toHex
|
|
|
|
toHex(): string;
|
2016-04-04 01:52:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotate buffer left in place.
|
|
|
|
* @param offset number of bytes to shift; use negative value to shift right
|
2016-08-04 17:42:47 +02:00
|
|
|
* @param start start offset in buffer. Default is 0.
|
2019-12-02 05:58:26 +01:00
|
|
|
* @param length number of elements in buffer. If negative, length is set as the buffer length minus
|
|
|
|
* start. eg: -1
|
2016-04-04 01:52:57 +02:00
|
|
|
*/
|
2016-08-04 17:42:47 +02:00
|
|
|
//% start.defl=0 length.defl=-1 shim=BufferMethods::rotate
|
2019-12-02 05:58:26 +01:00
|
|
|
rotate(offset: int32, start?: int32, length?: int32): void;
|
2016-04-04 01:52:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write contents of `src` at `dstOffset` in current buffer.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::write
|
2019-12-02 05:58:26 +01:00
|
|
|
write(dstOffset: int32, src: Buffer): void;
|
2020-09-08 11:04:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute k-bit FNV-1 non-cryptographic hash of the buffer.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::hash
|
|
|
|
hash(bits: int32): uint32;
|
2019-12-02 05:58:26 +01:00
|
|
|
}
|
|
|
|
declare namespace control {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new zero-initialized buffer.
|
|
|
|
* @param size number of bytes in the buffer
|
|
|
|
*/
|
2020-03-05 07:33:11 +01:00
|
|
|
//% deprecated=1 shim=control::createBuffer
|
2019-12-02 05:58:26 +01:00
|
|
|
function createBuffer(size: int32): Buffer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new buffer with UTF8-encoded string
|
|
|
|
* @param str the string to put in the buffer
|
|
|
|
*/
|
2020-03-05 07:33:11 +01:00
|
|
|
//% deprecated=1 shim=control::createBufferFromUTF8
|
2019-12-02 05:58:26 +01:00
|
|
|
function createBufferFromUTF8(str: string): Buffer;
|
2016-04-04 01:52:57 +02:00
|
|
|
}
|
2022-03-22 17:36:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides access to persistent storage functionality.
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare namespace storage {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves a key value pair in the non volatile storage
|
|
|
|
* @param key the key for accesing the value
|
|
|
|
* @param value value to store
|
|
|
|
*/
|
|
|
|
//% weight=100 blockGap=16
|
|
|
|
//% block="Put into %key a value of %value as Int"
|
|
|
|
//% blockId=storage_put_value_int
|
|
|
|
//%
|
|
|
|
//% group="Put"
|
|
|
|
//% blockHidden=true value.defl=0 shim=storage::putValueInt
|
|
|
|
function putValueInt(key: string, value?: int32): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads a key value pair from the non volatile storage
|
|
|
|
* @param key the key for accesing the value
|
|
|
|
*/
|
|
|
|
//% weight=100 blockGap=16
|
|
|
|
//% block="get number from %key"
|
|
|
|
//% blockId=storage_get_value_int
|
|
|
|
//% group="Get"
|
|
|
|
//% blockHidden=true shim=storage::getValueInt
|
|
|
|
function getValueInt(key: string): int32;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a key value pair from the non volatile storage
|
|
|
|
* @param key the key for accesing the value
|
|
|
|
*/
|
|
|
|
//% weight=100 blockGap=16
|
|
|
|
//% block="remove %key"
|
|
|
|
//% blockId=storage_remove
|
|
|
|
//% group="Remove"
|
|
|
|
//% blockHidden=true shim=storage::remove
|
|
|
|
function remove(key: string): void;
|
|
|
|
}
|
2020-09-08 11:04:25 +02:00
|
|
|
declare namespace light {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends a color buffer to a light strip
|
|
|
|
**/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% advanced=true shim=light::sendWS2812Buffer
|
2020-09-08 11:04:25 +02:00
|
|
|
function sendWS2812Buffer(buf: Buffer, pin: int32): void;
|
|
|
|
|
2022-03-22 17:36:19 +01:00
|
|
|
/**
|
|
|
|
* Sends a color buffer to a light strip
|
|
|
|
**/
|
|
|
|
//% advanced=true shim=light::sendWS2812BufferWithBrightness
|
|
|
|
function sendWS2812BufferWithBrightness(buf: Buffer, pin: int32, brightness: int32): void;
|
|
|
|
|
2020-09-08 11:04:25 +02:00
|
|
|
/**
|
|
|
|
* Sets the light mode of a pin
|
|
|
|
**/
|
|
|
|
//% advanced=true
|
|
|
|
//% shim=light::setMode
|
|
|
|
function setMode(pin: int32, mode: int32): void;
|
|
|
|
}
|
2016-04-04 01:52:57 +02:00
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
// Auto-generated. Do not edit. Really.
|