Fixing singal strength docs and adding an example (#347)
This commit is contained in:
parent
e9558ce158
commit
9a4a2264fa
@ -21,7 +21,7 @@ To add or remove the parts of the packet from the block, try clicking the blue g
|
|||||||
* `receivedString` - The [string](/reference/types/string) that was sent in this packet or the empty string if this packet did not contain a string. See [send string](/reference/radio/send-string) and [send value](/reference/radio/send-value)
|
* `receivedString` - The [string](/reference/types/string) that was sent in this packet or the empty string if this packet did not contain a string. See [send string](/reference/radio/send-string) and [send value](/reference/radio/send-value)
|
||||||
* `time` - The system time of the @boardname@ that sent this packet at the time the packet was sent.
|
* `time` - The system time of the @boardname@ that sent this packet at the time the packet was sent.
|
||||||
* `serial` - The serial number of the @boardname@ that sent this packet or `0` if the @boardname@ did not include its serial number.
|
* `serial` - The serial number of the @boardname@ that sent this packet or `0` if the @boardname@ did not include its serial number.
|
||||||
* `signal` - How strong the radio signal is from `255` (weak) to `0` (strong).
|
* `signal` - How strong the radio signal is from `-128` (weak) to `-42` (strong).
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@ -39,6 +39,23 @@ radio.onDataPacketReceived(({ receivedNumber }) => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
This program uses the signal strength from received packets to graph the
|
||||||
|
approximate distance between two @boardname@s.
|
||||||
|
|
||||||
|
```blocks
|
||||||
|
basic.forever(() => {
|
||||||
|
radio.sendNumber(0)
|
||||||
|
})
|
||||||
|
radio.onDataPacketReceived(({ signal, receivedNumber }) => {
|
||||||
|
led.plotBarGraph(
|
||||||
|
Math.abs(signal + 42),
|
||||||
|
128 - 42
|
||||||
|
)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
### See also
|
### See also
|
||||||
|
|
||||||
[send number](/reference/radio/send-number),
|
[send number](/reference/radio/send-number),
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
> Note: This API has been deprecated! Use [on data packet received](/reference/radio/on-data-packet-received) instead.
|
> Note: This API has been deprecated! Use [on data packet received](/reference/radio/on-data-packet-received) instead.
|
||||||
|
|
||||||
Find how strong the ``radio`` signal is, from `255` to `0`.
|
Find how strong the ``radio`` signal is, from `-128` to `-42`.
|
||||||
(`255` means a weak signal and `0` means a strong one.)
|
(`-128` means a weak signal and `-42` means a strong one.)
|
||||||
|
|
||||||
The @boardname@ finds the signal strength by checking how strong it was
|
The @boardname@ finds the signal strength by checking how strong it was
|
||||||
the last time it ran the
|
the last time it ran the
|
||||||
@ -16,7 +16,7 @@ radio.receivedSignalStrength();
|
|||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
* a [number](/reference/types/number) between `255` and `0` that means
|
* a [number](/reference/types/number) between `-128` and `-42` that means
|
||||||
how strong the signal is.
|
how strong the signal is.
|
||||||
|
|
||||||
### Simulator
|
### Simulator
|
||||||
|
Loading…
Reference in New Issue
Block a user