pxt-calliope/docs/reference/devices/on-signal-strength-changed.md

37 lines
745 B
Markdown
Raw Normal View History

2016-03-25 16:47:20 -07:00
# On Signal Strength Changed
Register code to run when the signal strength of the paired device changes.
## ~hint
2016-03-25 16:47:20 -07:00
**App required** You must use one of the [micro:bit apps](https://microbit.org/guide/mobile/) to use this functionality.
## ~
2016-03-25 16:47:20 -07:00
2016-06-20 22:06:19 -07:00
2016-04-15 16:15:08 -07:00
```sig
devices.onSignalStrengthChanged(() => {})
2016-03-25 16:47:20 -07:00
```
## Parameters
2016-03-25 16:47:20 -07:00
* ``body``: code to run when the signal strength changes.
## Examples
2016-03-25 16:47:20 -07:00
Display the signal strength on screen:
```blocks
2016-03-25 16:47:20 -07:00
devices.onSignalStrengthChanged(() => {
basic.showNumber(devices.signalStrength())
2016-03-25 16:47:20 -07:00
})
```
## See Also
2016-03-25 16:47:20 -07:00
2016-06-20 22:06:19 -07:00
[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
devices
2016-06-20 22:06:19 -07:00
```