updated devices docs

This commit is contained in:
Peli de Halleux 2016-06-20 22:06:19 -07:00
parent dd181e4178
commit 8f3c585588
7 changed files with 77 additions and 110 deletions

View File

@ -2,12 +2,13 @@
Register code to run when the micro:bit receives a command from the paired gamepad. Register code to run when the micro:bit receives a command from the paired gamepad.
## Bluetooth required ### ~hint
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
such as a smartphone, over Bluetooth (Smart).
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device. The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
### ~
```sig ```sig
devices.onGamepadButton(MesDpadButtonInfo.ADown, () => {}) devices.onGamepadButton(MesDpadButtonInfo.ADown, () => {})
@ -21,10 +22,6 @@ devices.onGamepadButton(MesDpadButtonInfo.ADown, () => {})
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [signal strength](/reference/devices/signal-strength), [on signal strength changed](/reference/devices/on-signal-strength-changed) [tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [signal strength](/reference/devices/signal-strength), [on signal strength changed](/reference/devices/on-signal-strength-changed)
```config ```package
{ microbit-devices
"dependencies": {
"microbit-devices": "*"
}
}
``` ```

View File

@ -1,15 +1,16 @@
# On Signal Strength Changed # On Signal Strength Changed
The `on signal strength changed` function.
Register code to run when the signal strength of the paired device changes. Register code to run when the signal strength of the paired device changes.
## Bluetooth required ### ~hint
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
such as a smartphone, over Bluetooth (Smart).
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device. The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
### ~
```sig ```sig
devices.onSignalStrengthChanged(() => {}) devices.onSignalStrengthChanged(() => {})
``` ```
@ -30,4 +31,8 @@ devices.onSignalStrengthChanged(() => {
### See Also ### See Also
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [signal strength](/reference/devices/signal-strength) [tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [signal strength](/reference/devices/signal-strength)
```package
microbit-devices
```

View File

@ -1,15 +1,15 @@
# raise alert to # raise alert to
The raise alert to function.
Raise an alert on a remote device. Raise an alert on a remote device.
## Bluetooth required ### ~hint
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
such as a smartphone, over Bluetooth (Smart).
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device. The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
### ~
```sig ```sig
export function raiseAlertTo(event: string) export function raiseAlertTo(event: string)
@ -23,37 +23,37 @@ export function raiseAlertTo(event: string)
To tell the connected device to display toast To tell the connected device to display toast
``` ```blocks
devices.raiseAlertTo("display toast") devices.raiseAlertTo("display toast")
``` ```
To tell the connected device to vibrate To tell the connected device to vibrate
``` ```blocks
devices.raiseAlertTo("vibrate") devices.raiseAlertTo("vibrate")
``` ```
To tell the connected device to play a sound To tell the connected device to play a sound
``` ```blocks
devices.raiseAlertTo("play sound") devices.raiseAlertTo("play sound")
``` ```
To tell the connected device to play a ringtone To tell the connected device to play a ringtone
``` ```blocks
devices.raiseAlertTo("play ringtone") devices.raiseAlertTo("play ringtone")
``` ```
To tell the connected device to find my phone To tell the connected device to find my phone
``` ```blocks
devices.raiseAlertTo("find my phone") devices.raiseAlertTo("find my phone")
``` ```
To tell the connected device to ring alarm To tell the connected device to ring alarm
``` ```blocks
devices.raiseAlertTo("ring alarm") devices.raiseAlertTo("ring alarm")
``` ```
@ -61,3 +61,6 @@ devices.raiseAlertTo("ring alarm")
[tell remote control to](/reference/devices/tell-remote-control-to), [tell camera to](/reference/devices/tell-camera-to) [tell remote control to](/reference/devices/tell-remote-control-to), [tell camera to](/reference/devices/tell-camera-to)
```package
microbit-devices
```

View File

@ -1,36 +0,0 @@
# Receive Number
The broadcast function.
Reads the next radio packet as a number data packet.
## Important Security Consideration
The functions in the ``radio`` namespace allow the BBC micro:bit to communicate with other micro:bits.
This API does not contain any form of encryption, authentication or authorization. It's purpose is solely for use as a teaching aid to demonstrate how simple communications operates, and to provide a sandpit through which learning can take place.
For serious applications, BLE should be considered a substantially more secure alternative.
```sig
radio.receiveNumber();
```
### Returns
* packet - a number received.
### Examples
Broadcasts the value of ``acceleration`` x to other micro:bits.
```
radio.onDataReceived(() => {
led.plotBarGraph(radio.receiveNumber(), 1023)
})
```
### See also
[send number](/reference/radio/send-number), [receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received), [set group](/reference/radio/set-group)

View File

@ -1,17 +1,17 @@
# Signal Strength # Signal Strength
The `signal strength` function.
Returns the signal strength reported by the paired device from ``0`` (no signal) to ``4`` (full strength). Returns the signal strength reported by the paired device from ``0`` (no signal) to ``4`` (full strength).
## Important Security Consideration ### ~hint
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
such as a smartphone, over Bluetooth (Smart).
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device. The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
``` ### ~
devices.signalStrength() : number
```sig
devices.signalStrength();
``` ```
### Returns ### Returns
@ -22,7 +22,7 @@ devices.signalStrength() : number
Display the signal strength on screen: Display the signal strength on screen:
``` ```blocks
devices.onSignalStrengthChanged(() => { devices.onSignalStrengthChanged(() => {
basic.showNumber(devices.signalStrength(), 150) basic.showNumber(devices.signalStrength(), 150)
}) })
@ -32,3 +32,6 @@ devices.onSignalStrengthChanged(() => {
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [on signal strength changed](/reference/devices/on-signal-strength-changed) [tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [on signal strength changed](/reference/devices/on-signal-strength-changed)
```package
microbit-devices
```

View File

@ -1,23 +1,17 @@
# tell camera to # tell camera to
The tell camera to function.
Access the photo/video-taking functionality of a remote device using the ``tell camera to`` function. Access the photo/video-taking functionality of a remote device using the ``tell camera to`` function.
## Bluetooth required ### ~hint
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
such as a smartphone, over Bluetooth (Smart).
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device. The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
### Block Editor ### ~
![](/static/mb/tell-camera-to-0.png) ```sig
devices.tellCameraTo()
### JavaScript
```
export function tellCameraTo(event: string)
``` ```
### Parameters ### Parameters
@ -28,49 +22,49 @@ export function tellCameraTo(event: string)
To tell the connected device to take a picture: To tell the connected device to take a picture:
``` ```blocks
devices.tellCameraTo("take photo") devices.tellCameraTo("take photo")
``` ```
To tell the connected device to start recording a video To tell the connected device to start recording a video
``` ```blocks
devices.tellCameraTo("start video capture") devices.tellCameraTo("start video capture")
``` ```
To tell the connected device to stop recording a video To tell the connected device to stop recording a video
``` ```blocks
devices.tellCameraTo("stop video capture") devices.tellCameraTo("stop video capture")
``` ```
To tell the connected device to toggle front-rear To tell the connected device to toggle front-rear
``` ```blocks
devices.tellCameraTo("toggle front-rear") devices.tellCameraTo("toggle front-rear")
``` ```
To tell the connected device to launch photo mode To tell the connected device to launch photo mode
``` ```blocks
devices.tellCameraTo("launch photo mode") devices.tellCameraTo("launch photo mode")
``` ```
To tell the connected device to launch video mode To tell the connected device to launch video mode
``` ```blocks
devices.tellCameraTo("launch video mode") devices.tellCameraTo("launch video mode")
``` ```
To tell the connected device to stop photo mode To tell the connected device to stop photo mode
``` ```blocks
devices.tellCameraTo("stop photo mode") devices.tellCameraTo("stop photo mode")
``` ```
To tell the connected device to stop video mode To tell the connected device to stop video mode
``` ```blocks
devices.tellCameraTo("stop video mode") devices.tellCameraTo("stop video mode")
``` ```
@ -78,3 +72,6 @@ devices.tellCameraTo("stop video mode")
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to) [tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to)
```package
microbit-devices
```

View File

@ -1,23 +1,17 @@
# tell remote control to # tell remote control to
The tell remote control to function.
Control the presentation of media content available on a remote device using the `tell remote control` to function. Control the presentation of media content available on a remote device using the `tell remote control` to function.
## ### ~hint
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart).
The functions in the ``devices`` namespace allow the BBC micro:bit to communicate with a separate (remote) device,
such as a smartphone, over Bluetooth (Smart).
The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device. The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
### Block Editor ### ~
![](/static/mb/tell-remote-control-to-0.png) ```sig
devices.tellRemoteControlTo(event: string)
### JavaScript
```
export function tellRemoteControlTo(event: string)
``` ```
### Parameters ### Parameters
@ -40,49 +34,49 @@ export function tellRemoteControlTo(event: string)
To tell the connected device to start playing: To tell the connected device to start playing:
``` ```blocks
devices.tellRemoteControlTo("play") devices.tellRemoteControlTo("play")
``` ```
To tell the connected device to stop playing To tell the connected device to stop playing
``` ```blocks
devices.tellRemoteControlTo("stop") devices.tellRemoteControlTo("stop")
``` ```
To tell the connected device to go to next track To tell the connected device to go to next track
``` ```blocks
devices.tellRemoteControlTo("next track") devices.tellRemoteControlTo("next track")
``` ```
To tell the connected device to go to previous track To tell the connected device to go to previous track
``` ```blocks
devices.tellRemoteControlTo("previous track") devices.tellRemoteControlTo("previous track")
``` ```
To tell the connected device to go forward To tell the connected device to go forward
``` ```blocks
devices.tellRemoteControlTo("forward") devices.tellRemoteControlTo("forward")
``` ```
To tell the connected device to rewind To tell the connected device to rewind
``` ```blocks
devices.tellRemoteControlTo("rewind") devices.tellRemoteControlTo("rewind")
``` ```
To tell the connected device volume up To tell the connected device volume up
``` ```blocks
devices.tellRemoteControlTo("volume up") devices.tellRemoteControlTo("volume up")
``` ```
To tell the connected device volume down To tell the connected device volume down
``` ```blocks
devices.tellRemoteControlTo("volume down") devices.tellRemoteControlTo("volume down")
``` ```
@ -90,3 +84,7 @@ devices.tellRemoteControlTo("volume down")
[tell camera to](/reference/devices/tell-camera-to), [raise alert to](/reference/devices/raise-alert-to) [tell camera to](/reference/devices/tell-camera-to), [raise alert to](/reference/devices/raise-alert-to)
```package
microbit-devices
```