annotating apis to support toolbox

This commit is contained in:
Peli de Halleux 2016-12-13 12:14:32 -08:00
parent 8ac848c812
commit bbd21a84d6
7 changed files with 74 additions and 61 deletions

View File

@ -97,26 +97,28 @@
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)", "input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
"input.acceleration|param|dimension": "TODO", "input.acceleration|param|dimension": "TODO",
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.", "input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
"input.buttonIsPressed|param|button": "the button to query the request, eg: Button.A",
"input.calibrate": "Obsolete, compass calibration is automatic.", "input.calibrate": "Obsolete, compass calibration is automatic.",
"input.compassHeading": "Get the current compass heading in degrees.", "input.compassHeading": "Get the current compass heading in degrees.",
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.", "input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.", "input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
"input.magneticForce|param|dimension": "TODO", "input.magneticForce|param|dimension": "TODO",
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed", "input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
"input.onButtonPressed|param|body": "TODO", "input.onButtonPressed|param|body": "code to run when event is raised",
"input.onButtonPressed|param|button": "TODO", "input.onButtonPressed|param|button": "the button that needs to be pressed",
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).", "input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
"input.onGesture|param|body": "TODO", "input.onGesture|param|body": "code to run when gesture is raised",
"input.onGesture|param|gesture": "the type of gesture to track, eg: Gesture.Shake",
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.", "input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
"input.onLogoDown|param|body": "TODO", "input.onLogoDown|param|body": "TODO",
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.", "input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
"input.onLogoUp|param|body": "TODO", "input.onLogoUp|param|body": "TODO",
"input.onPinPressed": "Do something when a pin is pressed.", "input.onPinPressed": "Do something when a pin is pressed.",
"input.onPinPressed|param|body": "the code to run when the pin is pressed", "input.onPinPressed|param|body": "the code to run when the pin is pressed",
"input.onPinPressed|param|name": "the pin that needs to be pressed", "input.onPinPressed|param|name": "the pin that needs to be pressed, eg: TouchPin.P0",
"input.onPinReleased": "Do something when a pin is released.", "input.onPinReleased": "Do something when a pin is released.",
"input.onPinReleased|param|body": "the code to run when the pin is released", "input.onPinReleased|param|body": "the code to run when the pin is released",
"input.onPinReleased|param|name": "the pin that needs to be released", "input.onPinReleased|param|name": "the pin that needs to be released, eg: TouchPin.P0",
"input.onScreenDown": "Attaches code to run when the screen is facing down.", "input.onScreenDown": "Attaches code to run when the screen is facing down.",
"input.onScreenDown|param|body": "TODO", "input.onScreenDown|param|body": "TODO",
"input.onScreenUp": "Attaches code to run when the screen is facing up.", "input.onScreenUp": "Attaches code to run when the screen is facing up.",
@ -124,7 +126,7 @@
"input.onShake": "Attaches code to run when the device is shaken.", "input.onShake": "Attaches code to run when the device is shaken.",
"input.onShake|param|body": "TODO", "input.onShake|param|body": "TODO",
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.", "input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
"input.pinIsPressed|param|name": "pin used to detect the touch", "input.pinIsPressed|param|name": "pin used to detect the touch, eg: TouchPin.P0",
"input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.", "input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.",
"input.rotation|param|kind": "TODO", "input.rotation|param|kind": "TODO",
"input.runningTime": "Gets the number of milliseconds elapsed since power on.", "input.runningTime": "Gets the number of milliseconds elapsed since power on.",
@ -166,7 +168,7 @@
"music.changeTempoBy": "Change the tempo by the specified amount", "music.changeTempoBy": "Change the tempo by the specified amount",
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20", "music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
"music.noteFrequency": "Gets the frequency of a note.", "music.noteFrequency": "Gets the frequency of a note.",
"music.noteFrequency|param|name": "the note name", "music.noteFrequency|param|name": "the note name, eg: Note.C",
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.", "music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
"music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)", "music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
"music.playTone|param|ms": "tone duration in milliseconds (ms)", "music.playTone|param|ms": "tone duration in milliseconds (ms)",
@ -182,21 +184,21 @@
"pins.analogPitch|param|frequency": "frequency to modulate in Hz.", "pins.analogPitch|param|frequency": "frequency to modulate in Hz.",
"pins.analogPitch|param|ms": "duration of the pitch in milli seconds.", "pins.analogPitch|param|ms": "duration of the pitch in milli seconds.",
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.", "pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
"pins.analogReadPin|param|name": "pin to write to", "pins.analogReadPin|param|name": "pin to write to, eg: AnalogPin.P0",
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.", "pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
"pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000", "pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000",
"pins.analogSetPeriod|param|name": "analog pin to set period to", "pins.analogSetPeriod|param|name": "analog pin to set period to, eg: AnalogPin.P0",
"pins.analogSetPitchPin": "Sets the pin used when using `analog pitch` or music.", "pins.analogSetPitchPin": "Sets the pin used when using `analog pitch` or music.",
"pins.analogSetPitchPin|param|name": "pin to modulate pitch from", "pins.analogSetPitchPin|param|name": "pin to modulate pitch from",
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.", "pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
"pins.analogWritePin|param|name": "pin name to write to", "pins.analogWritePin|param|name": "pin name to write to, eg: AnalogPin.P0",
"pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0", "pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0",
"pins.createBuffer": "Create a new zero-initialized buffer.", "pins.createBuffer": "Create a new zero-initialized buffer.",
"pins.createBuffer|param|size": "number of bytes in the buffer", "pins.createBuffer|param|size": "number of bytes in the buffer",
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1", "pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
"pins.digitalReadPin|param|name": "pin to read from", "pins.digitalReadPin|param|name": "pin to read from, eg: DigitalPin.P0",
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.", "pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
"pins.digitalWritePin|param|name": "pin to write to", "pins.digitalWritePin|param|name": "pin to write to, eg: DigitalPin.P0",
"pins.digitalWritePin|param|value": "value to set on the pin, 1 eg,0", "pins.digitalWritePin|param|value": "value to set on the pin, 1 eg,0",
"pins.i2cReadBuffer": "Read `size` bytes from a 7-bit I2C `address`.", "pins.i2cReadBuffer": "Read `size` bytes from a 7-bit I2C `address`.",
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.", "pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
@ -209,19 +211,21 @@
"pins.map|param|toLow": "the lower bound of the value's target range", "pins.map|param|toLow": "the lower bound of the value's target range",
"pins.map|param|value": "value to map in ranges", "pins.map|param|value": "value to map in ranges",
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.", "pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
"pins.onPulsed|param|name": "digital pin to register to, eg: DigitalPin.P0",
"pins.onPulsed|param|pulse": "the value of the pulse, eg: PulseValue.High",
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.", "pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.",
"pins.pulseIn": "Returns the duration of a pulse in microseconds", "pins.pulseIn": "Returns the duration of a pulse in microseconds",
"pins.pulseIn|param|name": "the pin which measures the pulse", "pins.pulseIn|param|name": "the pin which measures the pulse, eg: DigitalPin.P0",
"pins.pulseIn|param|value": "the value of the pulse (default high)", "pins.pulseIn|param|value": "the value of the pulse, eg: PulseValue.High",
"pins.servoSetPulse": "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.", "pins.servoSetPulse": "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.",
"pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500", "pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500",
"pins.servoSetPulse|param|name": "pin name", "pins.servoSetPulse|param|name": "pin name",
"pins.servoWritePin": "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).", "pins.servoWritePin": "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).",
"pins.servoWritePin|param|name": "pin to write to", "pins.servoWritePin|param|name": "pin to write to, eg: AnalogPin.P0",
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0", "pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
"pins.setPull": "Configures the pull of this pin.", "pins.setPull": "Configures the pull of this pin.",
"pins.setPull|param|name": "pin to set the pull mode on", "pins.setPull|param|name": "pin to set the pull mode on, eg: DigitalPin.P0",
"pins.setPull|param|pull": "one of the mbed pull configurations: PullUp, PullDown, PullNone ", "pins.setPull|param|pull": "one of the mbed pull configurations, eg: PinPullMode.PullUp",
"pins.sizeOf": "Get the size in bytes of specified number format.", "pins.sizeOf": "Get the size in bytes of specified number format.",
"pins.spiWrite": "Write to the SPI slave and return the response", "pins.spiWrite": "Write to the SPI slave and return the response",
"pins.spiWrite|param|value": "Data to be sent to the SPI slave", "pins.spiWrite|param|value": "Data to be sent to the SPI slave",
@ -232,8 +236,9 @@
"serial.readUntil": "Reads a line of text from the serial port and returns the buffer when the delimiter is met.", "serial.readUntil": "Reads a line of text from the serial port and returns the buffer when the delimiter is met.",
"serial.readUntil|param|delimiter": "text delimiter that separates each text chunk", "serial.readUntil|param|delimiter": "text delimiter that separates each text chunk",
"serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.", "serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.",
"serial.redirect|param|rx": "the new reception pin", "serial.redirect|param|rate": "the new baud rate. eg: 115200",
"serial.redirect|param|tx": "the new transmission pins", "serial.redirect|param|rx": "the new reception pin, eg: SerialPin.P1",
"serial.redirect|param|tx": "the new transmission pins, eg: SerialPin.P0",
"serial.writeLine": "Prints a line of text to the serial", "serial.writeLine": "Prints a line of text to the serial",
"serial.writeNumber": "Prints a numeric value to the serial", "serial.writeNumber": "Prints a numeric value to the serial",
"serial.writeString": "Sends a piece of text through Serial connection.", "serial.writeString": "Sends a piece of text through Serial connection.",

View File

@ -123,7 +123,7 @@
"input.magneticForce|block": "magnetic force (µT)|%NAME", "input.magneticForce|block": "magnetic force (µT)|%NAME",
"input.onButtonPressed|block": "on button|%NAME|pressed", "input.onButtonPressed|block": "on button|%NAME|pressed",
"input.onGesture|block": "on |%NAME", "input.onGesture|block": "on |%NAME",
"input.onPinPressed|block": "on pin %NAME|pressed", "input.onPinPressed|block": "on pin %name|pressed",
"input.onPinReleased|block": "on pin %NAME|released", "input.onPinReleased|block": "on pin %NAME|released",
"input.pinIsPressed|block": "pin %NAME|is pressed", "input.pinIsPressed|block": "pin %NAME|is pressed",
"input.rotation|block": "rotation (°)|%NAME", "input.rotation|block": "rotation (°)|%NAME",

View File

@ -111,8 +111,8 @@ enum class Gesture {
namespace input { namespace input {
/** /**
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed * Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
* @param button TODO * @param button the button that needs to be pressed
* @param body TODO * @param body code to run when event is raised
*/ */
//% help=input/on-button-pressed weight=85 blockGap=8 //% help=input/on-button-pressed weight=85 blockGap=8
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192" //% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
@ -123,7 +123,8 @@ namespace input {
/** /**
* Do something when when a gesture is done (like shaking the micro:bit). * Do something when when a gesture is done (like shaking the micro:bit).
* @param body TODO * @param gesture the type of gesture to track, eg: Gesture.Shake
* @param body code to run when gesture is raised
*/ */
//% help=input/on-gesture weight=84 blockGap=8 //% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135" //% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
@ -138,11 +139,11 @@ namespace input {
/** /**
* Do something when a pin is pressed. * Do something when a pin is pressed.
* @param name the pin that needs to be pressed * @param name the pin that needs to be pressed, eg: TouchPin.P0
* @param body the code to run when the pin is pressed * @param body the code to run when the pin is pressed
*/ */
//% help=input/on-pin-pressed weight=83 //% help=input/on-pin-pressed weight=83
//% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094" //% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094"
void onPinPressed(TouchPin name, Action body) { void onPinPressed(TouchPin name, Action body) {
auto pin = getPin((int)name); auto pin = getPin((int)name);
if (!pin) return; if (!pin) return;
@ -154,7 +155,7 @@ namespace input {
/** /**
* Do something when a pin is released. * Do something when a pin is released.
* @param name the pin that needs to be released * @param name the pin that needs to be released, eg: TouchPin.P0
* @param body the code to run when the pin is released * @param body the code to run when the pin is released
*/ */
//% help=input/on-pin-released weight=6 blockGap=8 //% help=input/on-pin-released weight=6 blockGap=8
@ -171,6 +172,7 @@ namespace input {
/** /**
* Get the button state (pressed or not) for ``A`` and ``B``. * Get the button state (pressed or not) for ``A`` and ``B``.
* @param button the button to query the request, eg: Button.A
*/ */
//% help=input/button-is-pressed weight=60 //% help=input/button-is-pressed weight=60
//% block="button|%NAME|is pressed" //% block="button|%NAME|is pressed"
@ -189,7 +191,7 @@ namespace input {
/** /**
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit. * Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
* @param name pin used to detect the touch * @param name pin used to detect the touch, eg: TouchPin.P0
*/ */
//% help=input/pin-is-pressed weight=58 //% help=input/pin-is-pressed weight=58
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094" //% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"

View File

@ -170,7 +170,7 @@ namespace music {
/** /**
* Gets the frequency of a note. * Gets the frequency of a note.
* @param name the note name * @param name the note name, eg: Note.C
*/ */
//% weight=50 help=music/note-frequency //% weight=50 help=music/note-frequency
//% blockId=device_note block="%note" //% blockId=device_note block="%note"

View File

@ -92,7 +92,7 @@ namespace pins {
/** /**
* Read the specified pin or connector as either 0 or 1 * Read the specified pin or connector as either 0 or 1
* @param name pin to read from * @param name pin to read from, eg: DigitalPin.P0
*/ */
//% help=pins/digital-read-pin weight=30 //% help=pins/digital-read-pin weight=30
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 //% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
@ -102,7 +102,7 @@ namespace pins {
/** /**
* Set a pin or connector value to either 0 or 1. * Set a pin or connector value to either 0 or 1.
* @param name pin to write to * @param name pin to write to, eg: DigitalPin.P0
* @param value value to set on the pin, 1 eg,0 * @param value value to set on the pin, 1 eg,0
*/ */
//% help=pins/digital-write-pin weight=29 //% help=pins/digital-write-pin weight=29
@ -113,7 +113,7 @@ namespace pins {
/** /**
* Read the connector value as analog, that is, as a value comprised between 0 and 1023. * Read the connector value as analog, that is, as a value comprised between 0 and 1023.
* @param name pin to write to * @param name pin to write to, eg: AnalogPin.P0
*/ */
//% help=pins/analog-read-pin weight=25 //% help=pins/analog-read-pin weight=25
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" //% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
@ -123,7 +123,7 @@ namespace pins {
/** /**
* Set the connector value as analog. Value must be comprised between 0 and 1023. * Set the connector value as analog. Value must be comprised between 0 and 1023.
* @param name pin name to write to * @param name pin name to write to, eg: AnalogPin.P0
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0 * @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
*/ */
//% help=pins/analog-write-pin weight=24 //% help=pins/analog-write-pin weight=24
@ -135,7 +135,7 @@ namespace pins {
/** /**
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds. * 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. * 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 name analog pin to set period to, eg: AnalogPin.P0
* @param micros period in micro seconds. eg:20000 * @param micros period in micro seconds. eg:20000
*/ */
//% help=pins/analog-set-period weight=23 blockGap=8 //% help=pins/analog-set-period weight=23 blockGap=8
@ -146,6 +146,8 @@ namespace pins {
/** /**
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``. * Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
* @param name digital pin to register to, eg: DigitalPin.P0
* @param pulse the value of the pulse, eg: PulseValue.High
*/ */
//% help=pins/on-pulsed weight=22 blockGap=8 advanced=true //% help=pins/on-pulsed weight=22 blockGap=8 advanced=true
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" //% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
@ -169,8 +171,8 @@ namespace pins {
/** /**
* Returns the duration of a pulse in microseconds * Returns the duration of a pulse in microseconds
* @param name the pin which measures the pulse * @param name the pin which measures the pulse, eg: DigitalPin.P0
* @param value the value of the pulse (default high) * @param value the value of the pulse, eg: PulseValue.High
* @param maximum duration in micro-seconds * @param maximum duration in micro-seconds
*/ */
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value" //% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
@ -198,7 +200,7 @@ namespace pins {
/** /**
* 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). * 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 name pin to write to, eg: AnalogPin.P0
* @param value angle or rotation speed, eg:180,90,0 * @param value angle or rotation speed, eg:180,90,0
*/ */
//% help=pins/servo-write-pin weight=20 //% help=pins/servo-write-pin weight=20
@ -260,8 +262,8 @@ namespace pins {
/** /**
* Configures the pull of this pin. * Configures the pull of this pin.
* @param name pin to set the pull mode on * @param name pin to set the pull mode on, eg: DigitalPin.P0
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone * @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp
*/ */
//% help=pins/set-pull weight=3 advanced=true //% help=pins/set-pull weight=3 advanced=true
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" //% blockId=device_set_pull block="set pull|pin %pin|to %pull"

View File

@ -83,9 +83,9 @@ namespace serial {
/** /**
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX. * Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
* @param tx the new transmission pins * @param tx the new transmission pins, eg: SerialPin.P0
* @param rx the new reception pin * @param rx the new reception pin, eg: SerialPin.P1
* @param baud the new baud rate. eg: 115200 * @param rate the new baud rate. eg: 115200
*/ */
//% weight=10 //% weight=10
//% help=serial/redirect-to //% help=serial/redirect-to

44
libs/core/shims.d.ts vendored
View File

@ -216,8 +216,8 @@ declare namespace input {
/** /**
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed * Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
* @param button TODO * @param button the button that needs to be pressed
* @param body TODO * @param body code to run when event is raised
*/ */
//% help=input/on-button-pressed weight=85 blockGap=8 //% help=input/on-button-pressed weight=85 blockGap=8
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192" //% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
@ -226,7 +226,8 @@ declare namespace input {
/** /**
* Do something when when a gesture is done (like shaking the micro:bit). * Do something when when a gesture is done (like shaking the micro:bit).
* @param body TODO * @param gesture the type of gesture to track, eg: Gesture.Shake
* @param body code to run when gesture is raised
*/ */
//% help=input/on-gesture weight=84 blockGap=8 //% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135" //% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
@ -235,16 +236,16 @@ declare namespace input {
/** /**
* Do something when a pin is pressed. * Do something when a pin is pressed.
* @param name the pin that needs to be pressed * @param name the pin that needs to be pressed, eg: TouchPin.P0
* @param body the code to run when the pin is pressed * @param body the code to run when the pin is pressed
*/ */
//% help=input/on-pin-pressed weight=83 //% help=input/on-pin-pressed weight=83
//% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094" shim=input::onPinPressed //% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094" shim=input::onPinPressed
function onPinPressed(name: TouchPin, body: () => void): void; function onPinPressed(name: TouchPin, body: () => void): void;
/** /**
* Do something when a pin is released. * Do something when a pin is released.
* @param name the pin that needs to be released * @param name the pin that needs to be released, eg: TouchPin.P0
* @param body the code to run when the pin is released * @param body the code to run when the pin is released
*/ */
//% help=input/on-pin-released weight=6 blockGap=8 //% help=input/on-pin-released weight=6 blockGap=8
@ -254,6 +255,7 @@ declare namespace input {
/** /**
* Get the button state (pressed or not) for ``A`` and ``B``. * Get the button state (pressed or not) for ``A`` and ``B``.
* @param button the button to query the request, eg: Button.A
*/ */
//% help=input/button-is-pressed weight=60 //% help=input/button-is-pressed weight=60
//% block="button|%NAME|is pressed" //% block="button|%NAME|is pressed"
@ -264,7 +266,7 @@ declare namespace input {
/** /**
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit. * Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
* @param name pin used to detect the touch * @param name pin used to detect the touch, eg: TouchPin.P0
*/ */
//% help=input/pin-is-pressed weight=58 //% help=input/pin-is-pressed weight=58
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094" //% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
@ -512,7 +514,7 @@ declare namespace pins {
/** /**
* Read the specified pin or connector as either 0 or 1 * Read the specified pin or connector as either 0 or 1
* @param name pin to read from * @param name pin to read from, eg: DigitalPin.P0
*/ */
//% help=pins/digital-read-pin weight=30 //% help=pins/digital-read-pin weight=30
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin //% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin
@ -520,7 +522,7 @@ declare namespace pins {
/** /**
* Set a pin or connector value to either 0 or 1. * Set a pin or connector value to either 0 or 1.
* @param name pin to write to * @param name pin to write to, eg: DigitalPin.P0
* @param value value to set on the pin, 1 eg,0 * @param value value to set on the pin, 1 eg,0
*/ */
//% help=pins/digital-write-pin weight=29 //% help=pins/digital-write-pin weight=29
@ -529,7 +531,7 @@ declare namespace pins {
/** /**
* Read the connector value as analog, that is, as a value comprised between 0 and 1023. * Read the connector value as analog, that is, as a value comprised between 0 and 1023.
* @param name pin to write to * @param name pin to write to, eg: AnalogPin.P0
*/ */
//% help=pins/analog-read-pin weight=25 //% help=pins/analog-read-pin weight=25
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin //% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin
@ -537,7 +539,7 @@ declare namespace pins {
/** /**
* Set the connector value as analog. Value must be comprised between 0 and 1023. * Set the connector value as analog. Value must be comprised between 0 and 1023.
* @param name pin name to write to * @param name pin name to write to, eg: AnalogPin.P0
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0 * @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
*/ */
//% help=pins/analog-write-pin weight=24 //% help=pins/analog-write-pin weight=24
@ -547,7 +549,7 @@ declare namespace pins {
/** /**
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds. * 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. * 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 name analog pin to set period to, eg: AnalogPin.P0
* @param micros period in micro seconds. eg:20000 * @param micros period in micro seconds. eg:20000
*/ */
//% help=pins/analog-set-period weight=23 blockGap=8 //% help=pins/analog-set-period weight=23 blockGap=8
@ -556,6 +558,8 @@ declare namespace pins {
/** /**
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``. * Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
* @param name digital pin to register to, eg: DigitalPin.P0
* @param pulse the value of the pulse, eg: PulseValue.High
*/ */
//% help=pins/on-pulsed weight=22 blockGap=8 advanced=true //% help=pins/on-pulsed weight=22 blockGap=8 advanced=true
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed //% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed
@ -571,8 +575,8 @@ declare namespace pins {
/** /**
* Returns the duration of a pulse in microseconds * Returns the duration of a pulse in microseconds
* @param name the pin which measures the pulse * @param name the pin which measures the pulse, eg: DigitalPin.P0
* @param value the value of the pulse (default high) * @param value the value of the pulse, eg: PulseValue.High
* @param maximum duration in micro-seconds * @param maximum duration in micro-seconds
*/ */
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value" //% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
@ -581,7 +585,7 @@ declare namespace pins {
/** /**
* 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). * 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 name pin to write to, eg: AnalogPin.P0
* @param value angle or rotation speed, eg:180,90,0 * @param value angle or rotation speed, eg:180,90,0
*/ */
//% help=pins/servo-write-pin weight=20 //% help=pins/servo-write-pin weight=20
@ -617,8 +621,8 @@ declare namespace pins {
/** /**
* Configures the pull of this pin. * Configures the pull of this pin.
* @param name pin to set the pull mode on * @param name pin to set the pull mode on, eg: DigitalPin.P0
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone * @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp
*/ */
//% help=pins/set-pull weight=3 advanced=true //% help=pins/set-pull weight=3 advanced=true
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull //% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull
@ -685,9 +689,9 @@ declare namespace serial {
/** /**
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX. * Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
* @param tx the new transmission pins * @param tx the new transmission pins, eg: SerialPin.P0
* @param rx the new reception pin * @param rx the new reception pin, eg: SerialPin.P1
* @param baud the new baud rate. eg: 115200 * @param rate the new baud rate. eg: 115200
*/ */
//% weight=10 //% weight=10
//% help=serial/redirect-to //% help=serial/redirect-to