pxt-microbit Accessibility PR (#529)

* Accessibility changes
This commit is contained in:
Sam El-Husseini
2017-09-07 13:42:08 -07:00
committed by GitHub
parent 3f87576a50
commit e3975e65e5
357 changed files with 1641 additions and 3540 deletions

View File

@ -7,12 +7,12 @@ Use [analog set pitch pin](/reference/pins/analog-set-pitch-pin) to set the curr
pins.analogPitch(440, 300)
```
### Parameters
## Parameters
* `frequency` : [Number](/types/number)
* `ms`: [Number](/types/number)
### Example
## Example
```blocks
pins.analogSetPitchPin("P0")
@ -22,12 +22,12 @@ pins.analogSetPitchPin(AnalogPin.P1);
pins.analogPitch(frequency1, duration)
```
### Some common notes
## Some common notes
* 440 = A4 on piano
* see [piano key frequencies ](https://en.wikipedia.org/wiki/Piano_key_frequencies) for more information
### See also
## See also
[@boardname@ pins](/device/pins), [analog set period](/reference/pins/analog-set-period), [analog set pitch pin](/reference/pins/analog-set-pitch-pin)

View File

@ -7,12 +7,12 @@ Read an **analog** signal (`0` through `1023`) from the
pins.analogReadPin(AnalogPin.P0)
```
### Parameters
## Parameters
* ``name`` is a [string](/types/string) with the name of the pin
you say (`P0` through `P4`, or `P10`)
### Returns
## Returns
* a [number](/types/number) from `0` through `1023`
@ -26,13 +26,13 @@ basic.forever(() => {
});
```
#### ~hint
### ~hint
If you are using **analog read pin** with another @boardname@ running **analog write pin**, then things can get tricky. Remember that the @boardname@ that runs **analog set pin** writes 0's and 1's at a very high frequency to achieve an average of the desired value. Sadly, if you try to read that average from another @boardname@, then the @boardname@ will either read 0 or 1023. You could try to read a higher number of values (e.g. a million) in a loop, then computer then average. Alternatively, you can plug in a capacitor in-between the two @boardname@s.
#### ~
### ~
### See also
## See also
[@boardname@ pins](/device/pins),
[on pin pressed](/reference/input/on-pin-pressed),

View File

@ -8,7 +8,7 @@ Before you call this function, you should set the specified pin as analog.
pins.analogSetPeriod(AnalogPin.P0, 20000)
```
### Parameters
## Parameters
* ``name``: a [string](/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`)
* ``micros``: a [number](/types/number) that specifies the analog period in microseconds.
@ -21,7 +21,7 @@ pins.analogWritePin(AnalogPin.P0, 512)
pins.analogSetPeriod(AnalogPin.P0, 20000)
```
### See also
## See also
[@boardname@ pins](/device/pins),
[on pin pressed](/reference/input/on-pin-pressed),

View File

@ -6,11 +6,11 @@ Specify which [pin](/device/pins) (P0, P1, P2) is used to generate tones.
pins.analogSetPitchPin(AnalogPin.P0)
```
### Parameters
## Parameters
* `name` - [String](/types/string); the pin name ("P0", "P1", or "P2")
### Example
## Example
```blocks
pins.analogSetPitchPin(AnalogPin.P0)
@ -19,12 +19,12 @@ let duration = 1000
pins.analogPitch(frequency, duration)
```
### Some common notes
## Some common notes
* 440 = A4 on piano
* see [piano key frequencies ](https://en.wikipedia.org/wiki/Piano_key_frequencies) for more information
### See also
## See also
[@boardname@ pins](/device/pins), [analog set period](/reference/pins/analog-set-period), [analog pitch](/reference/pins/analog-pitch)

View File

@ -7,12 +7,12 @@ Write an **analog** signal (`0` through `1023`) to the
pins.analogWritePin(AnalogPin.P0, 400)
```
### Parameters
## Parameters
* ``name`` is a [string](/types/string) that is the pin name you say (`P0` through `P4`, or `P10`)
* ``value`` is a [number](/types/number) from `0` through `1023`
### Example
## Example
This program writes `1023` to pin `P0`.
@ -20,15 +20,15 @@ This program writes `1023` to pin `P0`.
pins.analogWritePin(AnalogPin.P0, 1023)
```
#### ~hint
### ~hint
When you tell it to write `256` (for example), this function does not
_really_ write `256`. Instead, it writes a lot of different numbers,
and their average is `256`.
#### ~
### ~
### See also
## See also
[@boardname@ pins](/device/pins), [on pin pressed](/reference/input/on-pin-pressed), [analog read pin](/reference/pins/analog-read-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)

View File

@ -7,22 +7,22 @@ the @boardname@ board.
pins.digitalReadPin(DigitalPin.P3)
```
### ~avatar
## ~avatar
Some pins are also used by the [LED screen](/device/screen).
Please read the [page about pins](/device/pins) carefully.
### ~
## ~
### Parameters
## Parameters
* ``name`` is a [string](/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
### Returns
## Returns
* a [number](/types/number) that can be `0` or `1`
### Example: football score keeper
## Example: football score keeper
This program reads pin `P0` to find when a goal is scored. When `P0`
is `1`, the program makes the score bigger and plays a buzzer sound
@ -54,13 +54,13 @@ input.onButtonPressed(Button.B, () => {
pins.digitalWritePin(DigitalPin.P1, 0);
});
```
#### ~hint
### ~hint
Remember to connect `GND` on both @boardname@s together!
#### ~
### ~
### See also
## See also
[@boardname@ pins](/device/pins),
[digital write pin](/reference/pins/digital-write-pin),

View File

@ -7,19 +7,19 @@ the @boardname@ board.
pins.digitalWritePin(DigitalPin.P1, 1)
```
### ~avatar
## ~avatar
Some pins are also used by the [LED screen](/device/screen).
Please read the [page about pins](/device/pins) carefully.
### ~
## ~
### Parameters
## Parameters
* ``name`` is a [string](/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
* ``value`` is a [number](/types/number) that can be either `0` or `1`
### Example: football score keeper
## Example: football score keeper
This program reads pin `P0` to find when a goal is scored. When `P0`
is `1`, the program makes the score bigger and plays a buzzer sound
@ -53,7 +53,7 @@ input.onButtonPressed(Button.B, () => {
});
```
### See also
## See also
[@boardname@ pins](/device/pins),
[digital read pin](/reference/pins/digital-read-pin),

View File

@ -7,7 +7,7 @@ number format.
pins.i2cReadNumber(0, NumberFormat.Int8LE, false);
```
### Parameters
## Parameters
* ``address``: the 7-bit I2C address from which to read the number.
* ``format``: the number format. Formats include
@ -19,7 +19,7 @@ pins.i2cReadNumber(0, NumberFormat.Int8LE, false);
* The number in each format name stands for the number of bits in the format.
* ``repeated`` repeated start, true - don't send stop at end
### Example
## Example
The following example reads a number in big-endian, 16-bit, unsigned integer
format from the 7-bit I2C address `32`.
@ -28,12 +28,12 @@ format from the 7-bit I2C address `32`.
pins.i2cReadNumber(32, NumberFormat.UInt16BE, false);
```
#### ~hint
### ~hint
This function is not supported in the simulator.
#### ~
### ~
### See also
## See also
[I2C](https://en.wikipedia.org/wiki/I%C2%B2C)

View File

@ -7,7 +7,7 @@ specified number format.
pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE, true);
```
### Parameters
## Parameters
* ``address``: the 7-bit I2C address to which to send ``value``
* ``value``: the number to send to ``address``
@ -20,7 +20,7 @@ pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE, true);
* The number in each format name stands for the number of bits in the format.
* ``repeated`` repeated start, true - don't send stop at end
### Example
## Example
The following example sends the value `2055` to the 7-bit I2C
address `32` in big-endian 32-bit integer format.
@ -29,12 +29,12 @@ address `32` in big-endian 32-bit integer format.
pins.i2cWriteNumber(32, 2055, NumberFormat.Int32BE);
```
#### ~hint
### ~hint
This function is not supported in the simulator.
#### ~
### ~
### See also
## See also
[I2C](https://en.wikipedia.org/wiki/I%C2%B2C)

View File

@ -14,7 +14,7 @@ calling this function.
pins.map(0, 0, 4, 0, 1023);
```
### Parameters
## Parameters
* ``value``: a [number](/types/number) that specifies the value to map
* ``fromLow``: a [number](/types/number) that specifies the lower bound of the origin interval
@ -33,7 +33,7 @@ let index = pins.map(value1, 0, 1023, 0, 4)
led.plot(0, index)
```
### See also
## See also
[analog read pin](/reference/pins/analog-read-pin)

View File

@ -8,12 +8,12 @@ pulses **High** or **Low** (as specified).
pins.onPulsed(DigitalPin.P0, PulseValue.High, () => { });
```
### Parameters
## Parameters
* ``name``: The @boardname@ hardware pin to configure (``P0`` through ``P20``)
* ``pulse``: Which state will cause the associated block to execute (**High** or **Low**)
### Example
## Example
The following example configures pin ``P2`` for digital input,
and then displays the string `LOW` whenever ``P2`` pulses low.
@ -24,7 +24,7 @@ pins.onPulsed(DigitalPin.P2, PulseValue.Low, () => {
});
```
### See also
## See also
[servo set pulse](/reference/pins/servo-set-pulse),
[pulse duration](/reference/pins/pulse-duration),

View File

@ -8,11 +8,11 @@ This function should be called from an **on pulsed** handler.
pins.pulseDuration();
```
### Returns
## Returns
The duration of the last pulse, measured in microseconds.
### Example
## Example
The following example waits for pin ``P0`` to be pulsed high, and then
displays the duration of the pulse in microseconds on the LED screen.
@ -23,7 +23,7 @@ pins.onPulsed(DigitalPin.P0, PulseValue.High, () => {
});
```
### See also
## See also
[servo set pulse](/reference/pins/servo-set-pulse),
[on pulsed](/reference/pins/on-pulsed),

View File

@ -7,24 +7,24 @@ the @boardname@ board in microseconds.
pins.pulseIn(DigitalPin.P0, PulseValue.High)
```
### ~avatar
## ~avatar
Some pins are also used by the [LED screen](/device/screen).
Please read the [page about pins](/device/pins) carefully.
### ~
## ~
### Parameters
## Parameters
* ``name`` is a [string](/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
* ``value`` is the value of the pulse, ``high`` or ``low``
* ``maxDuration``, maximum duration in micro-seconds. If no pulse is received
### Returns
## Returns
* a [number](/types/number) that represents the pulse duration in micro-seconds
### Example: Measuring distance with a sonar
## Example: Measuring distance with a sonar
The following script sends a pulse on ``P0`` and reads the pulse returned by a HC-SR04 sonar to determine the distance of the object in front of the sensor.
@ -43,12 +43,12 @@ basic.forever(() => {
})
```
#### ~hint
### ~hint
This function is not supported in the simulator.
#### ~
### ~
### See also
## See also
[digital write pin](/reference/pins/digital-write-pin),

View File

@ -7,12 +7,12 @@ ms, and set the pulse width to the specified value.
pins.servoSetPulse(AnalogPin.P1, 1500)
```
### Parameters
## Parameters
* ``name``: a [string](/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`)
* ``micros``: a [number](/types/number) that specifies the analog period in microseconds.
### Example
## Example
The following code sets the servo pulse to `1000` microseconds.
@ -20,7 +20,7 @@ The following code sets the servo pulse to `1000` microseconds.
pins.servoSetPulse(AnalogPin.P0, 1000)
```
### See also
## See also
[@boardname@ pins](/device/pins),
[on pin pressed](/reference/input/on-pin-pressed),

View File

@ -12,20 +12,20 @@ and approximately `90` specifies no movement.)
pins.servoWritePin(AnalogPin.P0, 180)
```
### Parameters
## Parameters
* ``name``: a [string](/types/string) that specifies the pin name (`P0` through `P4`, or `P10`)
* ``value``: a [number](/types/number) from `0` through `180`
### Examples
## Examples
#### Setting the shaft angle to midpoint on a servo
### Setting the shaft angle to midpoint on a servo
```blocks
pins.servoWritePin(AnalogPin.P0, 90)
```
#### Controlling the shaft by using the tilt information of the accelerometer
### Controlling the shaft by using the tilt information of the accelerometer
```blocks
basic.forever(() => {
@ -36,13 +36,13 @@ basic.forever(() => {
})
```
#### Setting the full speed on a continuous servo
### Setting the full speed on a continuous servo
```blocks
pins.servoWritePin(AnalogPin.P0, 0)
```
### See also
## See also
[@boardname@ pins](/device/pins), [servo set pulse](/reference/pins/servo-set-pulse)

View File

@ -6,12 +6,12 @@ Configure the type of events emitted by a given pin.
pins.setEvents(DigitalPin.P0, PinEventType.Edge);
```
### Parameters
## Parameters
* ``name``: The @boardname@ hardware pin to configure (``P0`` through ``P20``)
* ``type``: The type of events this pin should emit
### Example
## Example
The following example configures pin ``P0`` and then
subscribes to the rise and fall events.

View File

@ -16,12 +16,12 @@ pins.setPull(DigitalPin.P9, PinPullMode.PullDown);
The pull-up and -down resistors are about 13kOhm.
### Parameters
## Parameters
* ``name``: The @boardname@ hardware pin to configure (``P0``-``P20``)
* ``pull``: The pull to which to set the pin (**down**, **up**, or **none**)
### Example
## Example
The following example sets the pull of pin ``P0`` to **up** (high).
@ -29,6 +29,6 @@ The following example sets the pull of pin ``P0`` to **up** (high).
pins.setPull(DigitalPin.P0, PinPullMode.PullUp);
```
### See also
## See also
[@boardname@ | mbed](https://developer.mbed.org/platforms/Microbit/)

View File

@ -6,11 +6,11 @@ Sets the SPI format
pins.spiFormat(8, 3);
```
### Parameters
## Parameters
* ``bits``,
* ``mode``,
### See also
## See also
[SPI](https://developer.mbed.org/handbook/SPI)

View File

@ -6,14 +6,14 @@ Write to the SPI Slave and return the response.
pins.spiWrite(0);
```
### Parameters
## Parameters
* ``value``: value Data to be sent to the SPI slave
### Returns
## Returns
* a [number](/types/number) Response from the SPI slave
### See also
## See also
[SPI](https://developer.mbed.org/handbook/SPI)

View File

@ -6,12 +6,12 @@ Sets the SPI MOSI, MISO and SCK pins
pins.spiPins(DigitalPin.P0, DigitalPin.P1, DigitalPin.P2);
```
### Parameters
## Parameters
* ``MOSI``, the ``MOSI`` pin
* ``MISO``, the ``MISO`` pin
* ``SCK``, the ``SCK`` pin
### See also
## See also
[SPI](https://developer.mbed.org/handbook/SPI)

View File

@ -6,14 +6,14 @@ Write to the SPI Slave and return the response.
pins.spiWrite(0);
```
### Parameters
## Parameters
* ``value``: value Data to be sent to the SPI slave
### Returns
## Returns
* a [number](/types/number) Response from the SPI slave
### See also
## See also
[SPI](https://developer.mbed.org/handbook/SPI)