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.
|
|
|
|
*/
|
2017-01-20 05:55:31 +01:00
|
|
|
//% color=#5C2D91 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
|
2016-04-13 02:10:37 +02:00
|
|
|
plotImage(xOffset?: number): void;
|
|
|
|
|
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
|
2016-04-02 04:55:51 +02:00
|
|
|
*/
|
2016-05-27 05:42:15 +02:00
|
|
|
//% help=images/show-image weight=80 blockNamespace=images
|
2016-08-22 17:48:48 +02:00
|
|
|
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
2017-02-04 05:39:18 +01:00
|
|
|
//% parts="ledmatrix" async interval.defl=400 shim=ImageMethods::showImage
|
|
|
|
showImage(xOffset: number, interval?: number): 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
|
2016-04-13 02:10:37 +02:00
|
|
|
plotFrame(xOffset: number): void;
|
|
|
|
|
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
|
|
|
|
*/
|
2016-05-27 05:42:15 +02:00
|
|
|
//% help=images/show-image weight=79 async blockNamespace=images
|
2016-08-22 17:48:48 +02:00
|
|
|
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::scrollImage
|
2016-05-27 05:42:15 +02:00
|
|
|
scrollImage(frameOffset: number, interval: number): 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
|
2016-04-02 04:55:51 +02:00
|
|
|
setPixelBrightness(x: number, y: number, value: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the pixel brightness ([0..255]) at a given position
|
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//%
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::pixelBrightness
|
2016-04-02 04:55:51 +02:00
|
|
|
pixelBrightness(x: number, y: number): number;
|
2016-04-13 02:10:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the width in columns
|
|
|
|
*/
|
|
|
|
//% help=functions/width shim=ImageMethods::width
|
|
|
|
width(): number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the height in rows (always 5)
|
|
|
|
*/
|
2016-05-27 05:42:15 +02:00
|
|
|
//% shim=ImageMethods::height
|
2016-04-13 02:10:37 +02:00
|
|
|
height(): number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a pixel state at position ``(x,y)``
|
|
|
|
* @param x TODO
|
|
|
|
* @param y TODO
|
|
|
|
* @param value TODO
|
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=images/set-pixel
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::setPixel
|
2016-04-13 02:10:37 +02:00
|
|
|
setPixel(x: number, y: number, value: boolean): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the pixel state at position ``(x,y)``
|
|
|
|
* @param x TODO
|
|
|
|
* @param y TODO
|
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=images/pixel
|
|
|
|
//% parts="ledmatrix" shim=ImageMethods::pixel
|
2016-04-13 02:10:37 +02:00
|
|
|
pixel(x: number, y: number): boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a particular frame of the image strip.
|
|
|
|
* @param frame TODO
|
|
|
|
*/
|
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
|
|
|
|
showFrame(frame: number, interval?: number): void;
|
2016-04-02 04:55:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
/**
|
|
|
|
* Provides access to basic micro:bit functionality.
|
|
|
|
*/
|
2017-01-20 05:55:31 +01:00
|
|
|
//% color=#54C9C9 weight=100 icon="\uf00a"
|
2016-04-02 02:45:18 +02:00
|
|
|
declare namespace basic {
|
|
|
|
|
2016-10-11 20:41:51 +02:00
|
|
|
/**
|
|
|
|
* Sets the color on the build-in LED. Set to 0 to turn off.
|
|
|
|
*/
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_set_led_color block="set led to %color=color_id"
|
2016-10-11 20:41:51 +02:00
|
|
|
//% weight=50 shim=basic::setLedColor
|
|
|
|
function setLedColor(color: number): void;
|
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
/**
|
|
|
|
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
|
|
|
|
* @param interval speed of scroll; eg: 150, 100, 200, -100
|
|
|
|
*/
|
|
|
|
//% help=basic/show-number
|
|
|
|
//% weight=96
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_show_number block="show|number %number" blockGap=8
|
2016-08-22 17:48:48 +02:00
|
|
|
//% async
|
|
|
|
//% parts="ledmatrix" interval.defl=150 shim=basic::showNumber
|
2016-04-02 02:45:18 +02:00
|
|
|
function showNumber(value: number, interval?: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
//% help=basic/show-leds
|
|
|
|
//% weight=95 blockGap=8
|
|
|
|
//% imageLiteral=1 async
|
|
|
|
//% blockId=device_show_leds
|
2017-01-20 05:55:31 +01:00
|
|
|
//% block="show leds"
|
2016-08-22 17:48:48 +02:00
|
|
|
//% parts="ledmatrix" interval.defl=400 shim=basic::showLeds
|
2016-04-02 02:45:18 +02:00
|
|
|
function showLeds(leds: string, interval?: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
|
|
|
|
* @param text the text to scroll on the screen, eg: "Hello!"
|
|
|
|
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
|
|
|
*/
|
|
|
|
//% help=basic/show-string
|
|
|
|
//% weight=87 blockGap=8
|
2017-01-20 05:55:31 +01:00
|
|
|
//% block="show|string %text"
|
2016-04-02 02:45:18 +02:00
|
|
|
//% async
|
2016-08-22 17:48:48 +02:00
|
|
|
//% blockId=device_print_message
|
|
|
|
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
|
2016-04-02 02:45:18 +02:00
|
|
|
function showString(text: string, interval?: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Turn off all LEDs
|
|
|
|
*/
|
|
|
|
//% help=basic/clear-screen weight=79
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_clear_display block="clear screen"
|
2016-08-22 17:48:48 +02:00
|
|
|
//% parts="ledmatrix" shim=basic::clearScreen
|
2016-04-02 02:45:18 +02:00
|
|
|
function clearScreen(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
2016-08-22 17:48:48 +02:00
|
|
|
//% help=basic/show-animation imageLiteral=1 async
|
|
|
|
//% parts="ledmatrix" interval.defl=400 shim=basic::showAnimation
|
2016-04-02 02:45:18 +02:00
|
|
|
function showAnimation(leds: string, interval?: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
//% parts="ledmatrix" imageLiteral=1 shim=basic::plotLeds
|
2016-04-02 02:45:18 +02:00
|
|
|
function plotLeds(leds: string): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
//% help=basic/forever weight=55 blockGap=8
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_forever block="forever" 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
|
|
|
|
*/
|
|
|
|
//% help=basic/pause weight=54
|
|
|
|
//% async block="pause (ms) %pause"
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_pause shim=basic::pause
|
2016-04-02 02:45:18 +02:00
|
|
|
function pause(ms: number): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-20 05:55:31 +01:00
|
|
|
//% color=#C90072 weight=99 icon="\uf192"
|
2016-04-02 06:26:06 +02:00
|
|
|
declare namespace input {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
|
|
|
* @param button TODO
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-05-17 01:24:44 +02:00
|
|
|
//% help=input/on-button-pressed weight=85 blockGap=8
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_button_event block="on button|%NAME|pressed"
|
2016-08-22 17:48:48 +02:00
|
|
|
//% parts="buttonpair" shim=input::onButtonPressed
|
2016-04-02 06:52:25 +02:00
|
|
|
function onButtonPressed(button: Button, 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).
|
2016-04-02 06:26:06 +02:00
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-05-17 01:24:44 +02:00
|
|
|
//% help=input/on-gesture weight=84 blockGap=8
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_gesture_event block="on |%NAME"
|
2016-08-22 17:48:48 +02:00
|
|
|
//% parts="accelerometer" 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
|
|
|
|
|
|
|
/**
|
2016-08-09 00:23:18 +02:00
|
|
|
* Do something when a pin is pressed.
|
|
|
|
* @param name the pin that needs to be pressed
|
|
|
|
* @param body the code to run when the pin is pressed
|
2016-04-02 06:26:06 +02:00
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=input/on-pin-pressed weight=83
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_pin_event block="on pin %NAME|pressed" shim=input::onPinPressed
|
2016-04-02 06:52:25 +02:00
|
|
|
function onPinPressed(name: TouchPin, body: () => void): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
2016-08-09 00:23:18 +02:00
|
|
|
/**
|
|
|
|
* Do something when a pin is released.
|
|
|
|
* @param name the pin that needs to be released
|
|
|
|
* @param body the code to run when the pin is released
|
|
|
|
*/
|
|
|
|
//% help=input/on-pin-released weight=6 blockGap=8
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_pin_released block="on pin %NAME|released"
|
2016-10-11 22:48:25 +02:00
|
|
|
//% advanced=true shim=input::onPinReleased
|
2016-08-09 00:23:18 +02:00
|
|
|
function onPinReleased(name: TouchPin, body: () => void): void;
|
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
/**
|
|
|
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
|
|
|
*/
|
2016-10-12 04:36:00 +02:00
|
|
|
//% help=input/button-is-pressed weight=60
|
2016-04-02 06:26:06 +02:00
|
|
|
//% block="button|%NAME|is pressed"
|
|
|
|
//% blockId=device_get_button2
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockGap=8
|
2016-08-22 17:48:48 +02:00
|
|
|
//% parts="buttonpair" shim=input::buttonIsPressed
|
2016-04-02 06:52:25 +02:00
|
|
|
function buttonIsPressed(button: Button): boolean;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
2016-07-27 01:17:54 +02:00
|
|
|
/**
|
|
|
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
|
|
|
* @param name pin used to detect the touch
|
|
|
|
*/
|
2016-10-12 04:36:00 +02:00
|
|
|
//% help=input/pin-is-pressed weight=58
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
2016-07-27 01:17:54 +02:00
|
|
|
//% blockGap=8 shim=input::pinIsPressed
|
|
|
|
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)
|
|
|
|
* @param dimension TODO
|
|
|
|
*/
|
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
|
|
|
|
//% parts="accelerometer" shim=input::acceleration
|
|
|
|
function acceleration(dimension: Dimension): number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
|
|
|
*/
|
|
|
|
//% help=input/light-level weight=57
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_get_light_level block="light level" blockGap=8
|
2016-10-12 04:36:00 +02:00
|
|
|
//% parts="ledmatrix" shim=input::lightLevel
|
|
|
|
function lightLevel(): number;
|
|
|
|
|
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
|
|
|
|
//% parts="compass" shim=input::compassHeading
|
2016-04-02 06:26:06 +02:00
|
|
|
function compassHeading(): number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the temperature in Celsius degrees (°C).
|
|
|
|
*/
|
2017-01-20 05:55:31 +01:00
|
|
|
//% weight=55
|
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
|
|
|
|
//% parts="thermometer" shim=input::temperature
|
2016-04-02 06:26:06 +02:00
|
|
|
function temperature(): number;
|
|
|
|
|
|
|
|
/**
|
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.
|
2016-04-02 06:26:06 +02:00
|
|
|
* @param kind TODO
|
|
|
|
*/
|
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
|
2016-10-12 04:36:00 +02:00
|
|
|
//% parts="accelerometer" advanced=true shim=input::rotation
|
2016-04-02 06:52:25 +02:00
|
|
|
function rotation(kind: Rotation): number;
|
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.
|
|
|
|
* @param dimension TODO
|
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=input/magnetic-force weight=51
|
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"
|
|
|
|
//% advanced=true shim=input::magneticForce
|
2016-04-02 06:52:25 +02:00
|
|
|
function magneticForce(dimension: Dimension): number;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the number of milliseconds elapsed since power on.
|
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=input/running-time weight=50
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_get_running_time block="running time (ms)"
|
2016-10-11 22:48:25 +02:00
|
|
|
//% advanced=true shim=input::runningTime
|
2016-04-02 06:26:06 +02:00
|
|
|
function runningTime(): number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obsolete, compass calibration is automatic.
|
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=input/calibrate weight=0 shim=input::calibrate
|
2016-04-02 06:26:06 +02:00
|
|
|
function calibrate(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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"
|
2016-08-22 17:48:48 +02:00
|
|
|
//% weight=5
|
2016-10-11 22:48:25 +02:00
|
|
|
//% parts="accelerometer"
|
|
|
|
//% advanced=true 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 {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedules code that run in the background.
|
|
|
|
*/
|
|
|
|
//% help=control/in-background
|
|
|
|
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
|
|
|
|
function inBackground(a: () => void): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
//% help=control/wait-micros weight=29
|
|
|
|
//% blockId="control_wait_us" block="wait (µs)%micros" shim=control::waitMicros
|
|
|
|
function waitMicros(micros: number): void;
|
|
|
|
|
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
|
2016-04-15 02:58:10 +02:00
|
|
|
//% mode.defl=1 shim=control::raiseEvent
|
2016-04-05 04:11:33 +02:00
|
|
|
function raiseEvent(src: number, value: number, mode?: EventCreationMode): void;
|
2016-04-02 02:45:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Raises an event in the event bus.
|
|
|
|
*/
|
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"
|
2016-04-18 22:31:05 +02:00
|
|
|
//% blockExternalInputs=1 shim=control::onEvent
|
2016-04-02 02:45:18 +02:00
|
|
|
function onEvent(src: number, value: number, handler: () => void): 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"
|
|
|
|
//% weight=18 shim=control::eventValue
|
|
|
|
function eventValue(): number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the timestamp of the last event executed on the bus
|
|
|
|
*/
|
|
|
|
//% blockId=control_event_timestamp" block="event timestamp"
|
2016-05-17 18:36:01 +02:00
|
|
|
//% weight=19 blockGap=8 shim=control::eventTimestamp
|
2016-05-17 01:24:44 +02:00
|
|
|
function eventTimestamp(): number;
|
|
|
|
|
2016-04-26 22:43:02 +02:00
|
|
|
/**
|
|
|
|
* Gets a friendly name for the device derived from the its serial number
|
|
|
|
*/
|
2016-04-28 19:46:03 +02:00
|
|
|
//% blockId="control_device_name" block="device name" weight=10 blockGap=8 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.
|
|
|
|
*/
|
2016-04-28 19:46:03 +02:00
|
|
|
//% blockId="control_device_serial_number" block="device serial number" weight=9 shim=control::deviceSerialNumber
|
2016-04-27 02:09:27 +02:00
|
|
|
function deviceSerialNumber(): number;
|
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.
|
|
|
|
* @param x TODO
|
|
|
|
* @param y TODO
|
|
|
|
*/
|
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
|
2016-08-22 17:48:48 +02:00
|
|
|
//% parts="ledmatrix" shim=led::plot
|
2016-04-02 06:52:25 +02:00
|
|
|
function plot(x: number, y: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
|
|
|
* @param x TODO
|
|
|
|
* @param y TODO
|
|
|
|
*/
|
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
|
2016-08-22 17:48:48 +02:00
|
|
|
//% parts="ledmatrix" shim=led::unplot
|
2016-04-02 06:52:25 +02:00
|
|
|
function unplot(x: number, y: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.
|
|
|
|
* @param x TODO
|
|
|
|
* @param y TODO
|
|
|
|
*/
|
2016-04-02 06:53:50 +02:00
|
|
|
//% help=led/point weight=76
|
2017-01-20 05:55:31 +01:00
|
|
|
//% blockId=device_point block="point|x %x|y %y"
|
2016-08-22 17:48:48 +02:00
|
|
|
//% parts="ledmatrix" shim=led::point
|
2016-04-02 06:52:25 +02:00
|
|
|
function point(x: number, y: number): boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2016-04-02 06:52:25 +02:00
|
|
|
function brightness(): number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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"
|
|
|
|
//% advanced=true shim=led::setBrightness
|
2016-04-02 06:52:25 +02:00
|
|
|
function setBrightness(value: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2016-10-28 17:34:04 +02:00
|
|
|
//% parts="ledmatrix" advanced=true shim=led::setDisplayMode
|
2016-04-02 06:52:25 +02:00
|
|
|
function setDisplayMode(mode: DisplayMode): void;
|
|
|
|
|
2016-10-28 17:34:04 +02:00
|
|
|
/**
|
|
|
|
* Turns on or off the display
|
|
|
|
*/
|
2017-01-20 05:55:31 +01:00
|
|
|
//% help=led/enable blockId=device_led_enable
|
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
|
|
|
|
*/
|
2016-11-03 06:35:00 +01:00
|
|
|
//% blockId=motor_on block="motor on at %percent"
|
|
|
|
//% parts=dcmotor weight=90 blockGap=8 shim=motors::motorPower
|
|
|
|
function motorPower(power: number): void;
|
|
|
|
|
|
|
|
/**
|
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
|
|
|
*/
|
|
|
|
//% blockId=block_dual_motor block="motor %motor|at %percent"
|
|
|
|
//% weight=80 shim=motors::dualMotorPower
|
|
|
|
function dualMotorPower(motor: Motor, duty_percent: number): 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)
|
|
|
|
*/
|
|
|
|
//% help=music/play-tone weight=90
|
|
|
|
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
|
2016-11-16 07:28:05 +01:00
|
|
|
//% parts="speaker" async shim=music::playTone
|
2017-02-19 11:44:16 +01:00
|
|
|
function playTone(frequency: number, ms: number): void;
|
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
|
|
|
|
* @param name pin to read from
|
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=pins/digital-read-pin weight=30
|
2016-04-02 06:26:06 +02:00
|
|
|
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin
|
2016-04-02 06:52:25 +02:00
|
|
|
function digitalReadPin(name: DigitalPin): number;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a pin or connector value to either 0 or 1.
|
|
|
|
* @param name pin to write to
|
|
|
|
* @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
|
2016-04-02 06:26:06 +02:00
|
|
|
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value" shim=pins::digitalWritePin
|
2016-04-02 06:52:25 +02:00
|
|
|
function digitalWritePin(name: DigitalPin, value: number): 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.
|
|
|
|
* @param name pin to write to
|
|
|
|
*/
|
2016-04-02 06:52:25 +02:00
|
|
|
//% help=pins/analog-read-pin weight=25
|
2016-04-02 06:26:06 +02:00
|
|
|
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin
|
2016-04-02 06:52:25 +02:00
|
|
|
function analogReadPin(name: AnalogPin): number;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
|
|
|
* @param name pin name to write to
|
|
|
|
* @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
|
2016-04-02 06:26:06 +02:00
|
|
|
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8 shim=pins::analogWritePin
|
2016-04-02 06:52:25 +02:00
|
|
|
function analogWritePin(name: AnalogPin, value: number): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
|
|
|
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
|
|
|
* @param name analog pin to set period to
|
|
|
|
* @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
|
2016-04-02 06:26:06 +02:00
|
|
|
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
|
2016-04-02 06:52:25 +02:00
|
|
|
function analogSetPeriod(name: AnalogPin, micros: number): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
2016-05-17 01:24:44 +02:00
|
|
|
/**
|
|
|
|
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
|
|
|
*/
|
|
|
|
//% help=pins/on-pulsed weight=22 blockGap=8
|
|
|
|
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed
|
|
|
|
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
|
|
|
|
|
|
|
|
/**
|
2016-05-25 06:39:57 +02:00
|
|
|
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.
|
2016-05-17 01:24:44 +02:00
|
|
|
*/
|
2016-07-21 22:46:22 +02:00
|
|
|
//% help=pins/pulse-duration
|
2016-05-25 06:39:57 +02:00
|
|
|
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
2016-08-17 20:18:15 +02:00
|
|
|
//% weight=21 blockGap=8 shim=pins::pulseDuration
|
2016-05-17 01:24:44 +02:00
|
|
|
function pulseDuration(): number;
|
|
|
|
|
2016-08-17 20:18:15 +02:00
|
|
|
/**
|
|
|
|
* Returns the duration of a pulse in microseconds
|
|
|
|
* @param name the pin which measures the pulse
|
|
|
|
* @param value the value of the pulse (default high)
|
2016-08-17 20:35:54 +02:00
|
|
|
* @param maximum duration in micro-seconds
|
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"
|
|
|
|
//% weight=20 maxDuration.defl=2000000 shim=pins::pulseIn
|
|
|
|
function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: number): number;
|
2016-08-17 20:18:15 +02:00
|
|
|
|
2016-04-02 06:26:06 +02:00
|
|
|
/**
|
|
|
|
* Writes 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).
|
|
|
|
* @param name pin to write to
|
|
|
|
* @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
|
|
|
|
//% parts=microservo trackArgs=0 shim=pins::servoWritePin
|
2016-04-02 06:52:25 +02:00
|
|
|
function servoWritePin(name: AnalogPin, value: number): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.
|
|
|
|
* @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
|
2016-04-02 06:26:06 +02:00
|
|
|
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros" shim=pins::servoSetPulse
|
2016-04-02 06:52:25 +02:00
|
|
|
function servoSetPulse(name: AnalogPin, micros: number): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the pin used when using `pins->analog pitch`.
|
|
|
|
* @param name TODO
|
|
|
|
*/
|
2017-01-30 20:19:54 +01:00
|
|
|
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
|
|
|
|
//% help=pins/analog-set-pitch weight=3 advanced=true shim=pins::analogSetPitchPin
|
2016-04-02 06:52:25 +02:00
|
|
|
function analogSetPitchPin(name: AnalogPin): void;
|
2016-04-02 06:26:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.
|
|
|
|
* @param frequency TODO
|
|
|
|
* @param ms TODO
|
|
|
|
*/
|
2017-01-30 20:19:54 +01:00
|
|
|
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
|
|
|
|
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8 shim=pins::analogPitch
|
2016-04-02 06:26:06 +02:00
|
|
|
function analogPitch(frequency: number, ms: number): void;
|
2016-04-04 01:52:57 +02:00
|
|
|
|
2016-06-04 08:15:51 +02:00
|
|
|
/**
|
|
|
|
* Configures the pull of this pin.
|
|
|
|
* @param name pin to set the pull mode on
|
|
|
|
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
|
|
|
*/
|
2016-07-21 22:46:22 +02:00
|
|
|
//% help=pins/set-pull weight=3
|
2016-06-04 08:15:51 +02:00
|
|
|
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull
|
|
|
|
function setPull(name: DigitalPin, pull: PinPullMode): void;
|
|
|
|
|
2017-01-30 20:19:54 +01:00
|
|
|
/**
|
|
|
|
* Configures the events emitted by this pin. Events can be subscribed to
|
|
|
|
* 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
|
|
|
|
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events" shim=pins::setEvents
|
|
|
|
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
|
|
|
|
function createBuffer(size: number): Buffer;
|
2016-04-05 04:02:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read `size` bytes from a 7-bit I2C `address`.
|
|
|
|
*/
|
|
|
|
//% repeat.defl=0 shim=pins::i2cReadBuffer
|
2016-04-05 04:11:33 +02:00
|
|
|
function i2cReadBuffer(address: number, size: number, repeat?: boolean): Buffer;
|
2016-04-05 04:02:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write bytes to a 7-bit I2C `address`.
|
|
|
|
*/
|
|
|
|
//% repeat.defl=0 shim=pins::i2cWriteBuffer
|
2016-04-05 04:11:33 +02:00
|
|
|
function i2cWriteBuffer(address: number, buf: Buffer, repeat?: boolean): void;
|
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
|
|
|
|
*/
|
|
|
|
//% help=pins/spi-write weight=5
|
|
|
|
//% blockId=spi_write block="spi write %value" shim=pins::spiWrite
|
|
|
|
function spiWrite(value: number): number;
|
2016-04-02 06:26:06 +02:00
|
|
|
}
|
|
|
|
|
2016-04-02 07:00:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
//% weight=2 color=30
|
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
|
|
|
/**
|
|
|
|
* Reads a line of text from the serial port and returns the buffer when the delimiter is met.
|
|
|
|
* @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
|
|
|
/**
|
2017-01-10 19:26:44 +01:00
|
|
|
* Reads the buffered received data as a string
|
2016-04-02 07:00:42 +02:00
|
|
|
*/
|
2017-01-10 19:26:44 +01:00
|
|
|
//% blockId=serial_read_buffer block="serial|read string"
|
|
|
|
//% weight=18 shim=serial::readString
|
|
|
|
function readString(): string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers an event to be fired when one of the delimiter is matched.
|
|
|
|
* @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
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends a piece of text through Serial connection.
|
|
|
|
*/
|
2016-05-17 18:36:01 +02:00
|
|
|
//% help=serial/write-string
|
|
|
|
//% weight=87
|
2016-10-19 06:36:42 +02:00
|
|
|
//% blockId=serial_writestring block="serial|write string %text" shim=serial::writeString
|
2016-04-02 07:00:42 +02:00
|
|
|
function writeString(text: string): void;
|
2016-05-26 20:07:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
|
2017-02-13 11:44:00 +01:00
|
|
|
* @param tx the new transmission pins, eg: SerialPin.P0
|
|
|
|
* @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
|
2016-07-21 22:46:22 +02:00
|
|
|
//% help=serial/redirect-to
|
2016-10-19 06:36:42 +02:00
|
|
|
//% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
|
2016-05-26 20:07:09 +02:00
|
|
|
//% blockExternalInputs=1 shim=serial::redirect
|
|
|
|
function redirect(tx: SerialPin, rx: SerialPin, rate: BaudRate): 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 {
|
2016-04-05 04:02:40 +02:00
|
|
|
/**
|
|
|
|
* Write a number in specified format in the buffer.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::setNumber
|
|
|
|
setNumber(format: NumberFormat, offset: number, value: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read a number in specified format from the buffer.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::getNumber
|
|
|
|
getNumber(format: NumberFormat, offset: number): number;
|
|
|
|
|
2016-04-04 01:52:57 +02:00
|
|
|
/** Returns the length of a Buffer object. */
|
|
|
|
//% property shim=BufferMethods::length
|
|
|
|
length: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill (a fragment) of the buffer with given value.
|
|
|
|
*/
|
|
|
|
//% offset.defl=0 length.defl=-1 shim=BufferMethods::fill
|
|
|
|
fill(value: number, offset?: number, length?: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a copy of a fragment of a buffer.
|
|
|
|
*/
|
|
|
|
//% offset.defl=0 length.defl=-1 shim=BufferMethods::slice
|
|
|
|
slice(offset?: number, length?: number): Buffer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @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
|
|
|
|
shift(offset: number, start?: number, length?: number): void;
|
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.
|
|
|
|
* @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
|
|
|
|
rotate(offset: number, start?: number, length?: number): void;
|
2016-04-04 01:52:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write contents of `src` at `dstOffset` in current buffer.
|
|
|
|
*/
|
|
|
|
//% shim=BufferMethods::write
|
|
|
|
write(dstOffset: number, src: Buffer): void;
|
|
|
|
}
|
|
|
|
|
2016-04-02 02:45:18 +02:00
|
|
|
// Auto-generated. Do not edit. Really.
|