updated docs

This commit is contained in:
Peli de Halleux 2016-05-16 22:18:58 -07:00
parent 1cf070d649
commit 845d7a004c
5 changed files with 113 additions and 24 deletions

View File

@ -1,23 +0,0 @@
# microbit Reference
```namespaces
basic.showNumber(0);
input.onButtonPressed(Button.A, () => {
});
led.plot(0, 0);
music.playTone(0, 0);
game.addScore(1);
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`);
pins.digitalReadPin(DigitalPin.P0);
serial.writeValue(x, 0);
control.inBackground(() => {
});
```

View File

@ -8,8 +8,14 @@ pins.digitalWritePin(DigitalPin.P0, 0);
pins.analogReadPin(AnalogPin.P0); pins.analogReadPin(AnalogPin.P0);
pins.analogWritePin(AnalogPin.P0, 1023); pins.analogWritePin(AnalogPin.P0, 1023);
pins.analogSetPeriod(AnalogPin.P0, 20000); pins.analogSetPeriod(AnalogPin.P0, 20000);
pins.onPulsed(DigitalPin.P0, PulseValue.High, () => {
});
pins.pulseDuration();
pins.servoWritePin(AnalogPin.P0, 180); pins.servoWritePin(AnalogPin.P0, 180);
pins.servoSetPulse(AnalogPin.P0, 1500); pins.servoSetPulse(AnalogPin.P0, 1500);
pins.i2cReadNumber(0, NumberFormat.Int8LE);
pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE);
pins.map(0, 0, 1023, 0, 4); pins.map(0, 0, 1023, 0, 4);
pins.analogPitch(0, 0); pins.analogPitch(0, 0);
pins.analogSetPitchPin(AnalogPin.P0); pins.analogSetPitchPin(AnalogPin.P0);

View File

@ -4,13 +4,17 @@ Communicate data using radio packets
```cards ```cards
radio.sendNumber(0); radio.sendNumber(0);
radio.sendNumbers(0, 0, 0, 0); radio.sendValue("data", 0);
radio.sendString("");
radio.onDataReceived(() => { radio.onDataReceived(() => {
}); });
radio.receiveNumber(); radio.receiveNumber();
radio.receivedNumberAt(0); radio.receivedNumberAt(0);
radio.receiveString();
radio.receivedSignalStrength(); radio.receivedSignalStrength();
radio.setGroup(0); radio.setGroup(0);
radio.setTransmitPower(0); radio.setTransmitPower(0);
radio.writeValueToSerial();
radio.setTransmitSerialNumber(◊);
``` ```

View File

@ -0,0 +1,98 @@
{
"basic": "Provides access to basic micro:bit functionality.",
"basic.clearScreen": "Turn off all LEDs",
"basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
"basic.pause": "Pause for the specified time in milliseconds",
"basic.plotLeds": "Draws an image on the LED screen.",
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
"basic.showLeds": "Draws an image on the LED screen.",
"basic.showNumber": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.",
"basic.showString": "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.",
"control": "Runtime and event utilities.",
"control.inBackground": "Schedules code that run in the background.",
"control.reset": "Resets the BBC micro:bit.",
"game": "A single-LED sprite game engine",
"game.addScore": "Adds points to the current score",
"game.gameOver": "Displays a game over animation.",
"game.score": "Gets the current score",
"game.setScore": "Sets the current score value",
"game.startCountdown": "Starts a game countdown timer",
"images": "Creation, manipulation and display of LED images.",
"images.createBigImage": "Creates an image with 2 frames.",
"images.createImage": "Creates an image that fits on the LED screen.",
"input": "Events and data from sensors",
"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.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
"input.calibrate": "Obsolete, compass calibration is automatic.",
"input.compassHeading": "Get the current compass 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.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
"input.onGesture": "Attaches code to run when the screen is facing up.",
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
"input.onPinPressed": "Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.",
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
"input.onShake": "Attaches code to run when the device is shaken.",
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
"input.rotation": "The pitch of the device, rotation along the ``x-axis``, in degrees.",
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
"led": "Control of the LED screen.",
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
"led.fadeIn": "Fades in the screen display.",
"led.fadeOut": "Fades out the screen brightness.",
"led.plot": "Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
"led.plotAll": "Turns all LEDS on",
"led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
"led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
"led.screenshot": "Takes a screenshot of the LED screen and returns an image.",
"led.setBrightness": "Set the screen brightness from 0 (off) to 255 (full bright).",
"led.setDisplayMode": "Sets the display mode between black and white and greyscale for rendering LEDs.",
"led.stopAnimation": "Cancels the current animation and clears other pending animations.",
"led.toggle": "Toggles a particular pixel",
"led.toggleAll": "Inverts the current LED display",
"led.unplot": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
"music": "Generation of music tones through pin ``P0``.",
"music.beat": "Returns the duration of a beat in milli-seconds",
"music.changeTempoBy": "Change the tempo by the specified amount",
"music.noteFrequency": "Gets the frequency of a note.",
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
"music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
"music.ringTone": "Plays a tone through pin ``P0``.",
"music.setTempo": "Sets the tempo to the specified amount",
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
"pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
"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.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
"pins.i2cWriteNumber": "Write one number to a 7-bit I2C address.",
"pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
"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.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulse`` handler.",
"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.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).",
"radio": "Communicate data using radio packets",
"radio.onDataReceived": "Registers code to run when a packet is received over radio.",
"radio.receiveNumber": "Reads the next packet as a number from the radio queue.",
"radio.receiveString": "Reads the next packet as a string and returns it.",
"radio.receivedNumberAt": "Reads a number at a given index, between ``0`` and ``3``, from the packet received by ``receive number``. Not supported in simulator.",
"radio.receivedSignalStrength": "Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.\nnamespace=radio",
"radio.sendNumber": "Broadcasts a number over radio to any connected micro:bit in the group.",
"radio.sendString": "Broadcasts a number over radio to any connected micro:bit in the group.",
"radio.sendValue": "Broadcasts a name / value pair along with the device serial number\nand running time to any connected BBC micro:bit in the group.",
"radio.setGroup": "Sets the group id for radio communications. A micro:bit can only listen to one group ID at any time.\n@ param id the group id between ``0`` and ``255``, 1 eg",
"radio.setTransmitPower": "Change the output power level of the transmitter to the given value.",
"radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.",
"radio.writeValueToSerial": "Reads a value sent with `stream value` and writes it\nto the serial stream as JSON",
"serial": "Reading and writing data over a serial connection.",
"serial.writeLine": "Prints a line of text to the serial",
"serial.writeValue": "Writes a ``name: value`` pair line to the serial."
}

View File

@ -72,7 +72,11 @@
"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.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.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.i2cReadNumber": "Read one number from 7-bit I2C address.",
"pins.i2cWriteNumber": "Write one number to a 7-bit I2C address.",
"pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.", "pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
"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.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulse`` handler.",
"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.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).",
"serial": "Reading and writing data over a serial connection.", "serial": "Reading and writing data over a serial connection.",