Update 'radio' docs for v1 (#937)
This commit is contained in:
48
docs/reference/radio/on-received-value.md
Normal file
48
docs/reference/radio/on-received-value.md
Normal file
@ -0,0 +1,48 @@
|
||||
# on Received Value
|
||||
|
||||
Run part of a program when the @boardname@ receives a name-value-pair over ``radio``.
|
||||
|
||||
```sig
|
||||
radio.onReceivedValue(function (name, value) {})
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
* **name**: a [string](/types/string) that is a name for the value received.
|
||||
* **value**: a [number](/types/number) that is the value received.
|
||||
|
||||
## Example
|
||||
|
||||
This program keeps sending numbers that say how fast the @boardname@ is
|
||||
slowing down or speeding up. When it receives numbers for the same
|
||||
thing from nearby @boardname@s, show the numbers as a
|
||||
[bar graph](/reference/led/plot-bar-graph).
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendValue("accel-x", input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onReceivedValue(function (name, value) {
|
||||
if (name == "accel-x") {
|
||||
led.plotBarGraph(value, 1023);
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
The ``||radio:on received value||`` event can only be created once, due to the hardware restrictions.
|
||||
|
||||
The radio set group might need to be set, synchronized , before the radio events will function.
|
||||
|
||||
## See also
|
||||
|
||||
[on received number](/reference/radio/on-received-number),
|
||||
[send number](/reference/radio/send-number),
|
||||
[send string](/reference/radio/send-string),
|
||||
[send value](/reference/radio/send-value),
|
||||
[set group](/reference/radio/set-group)
|
||||
|
||||
```package
|
||||
radio
|
||||
```
|
Reference in New Issue
Block a user