Updates for V4 (#197)

* update yotta defaults for 16kb devices

* refactor deprecated blocks

* updates for button events

* update button events

* update refference

* update docs

* update docs

* update button event blocks

* update docs

* update block id
This commit is contained in:
Juri Wolf
2022-08-10 18:36:19 +02:00
committed by GitHub
parent 32783f38ba
commit 5f7a8e5301
107 changed files with 1218 additions and 706 deletions

View File

@ -19,6 +19,7 @@ Two @boardname@s work like remote levels. They lie flat and detect any change in
```typescript
let ax = 0;
let ay = 0;
radio.setGroup(3)
basic.forever(() => {
ax = input.acceleration(Dimension.X);
ay = input.acceleration(Dimension.Y);

View File

@ -29,6 +29,7 @@ thing from nearby @boardname@s. It shows these numbers as a
[bar graph](/reference/led/plot-bar-graph).
```blocks
radio.setGroup(1)
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X));
})
@ -43,6 +44,7 @@ This program uses the signal strength from received packets to graph the
approximate distance between two @boardname@s.
```blocks
radio.setGroup(1)
basic.forever(() => {
radio.sendNumber(0)
})

View File

@ -23,6 +23,7 @@ https://www.youtube.com/watch?v=Re3H2ISfQE8
This program continuously sends a cheerful message. It also receives a messages from nearby @boardname@s. It shows these messages on the screen.
```blocks
radio.setGroup(1)
basic.forever(() => {
radio.sendString("I'm happy");
})

View File

@ -27,6 +27,7 @@ thing from nearby @boardname@s, show the numbers as a
[bar graph](/reference/led/plot-bar-graph).
```blocks
radio.setGroup(1)
basic.forever(() => {
radio.sendValue("accel-x", input.acceleration(Dimension.X))
})

View File

@ -34,7 +34,7 @@ If you load this program onto two or more @boardname@s, you can send a code word
The other @boardname@s will receive the code word and then show it.
```blocks
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
radio.sendString("Codeword: TRIMARAN")
basic.showString("SENT");
})
@ -59,10 +59,10 @@ This program will also receive your friend's mood.
```blocks
let data: string = "";
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
radio.sendString("H");
});
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
radio.sendString("S");
});
radio.onDataReceived(() => {

View File

@ -18,7 +18,7 @@ In addition to a [number](types/number), [string](/types/string), or name-value
## Returns
* a [number](/types/number) that is the property selected in the **type** parameter:
>* ``signal strength``: the value ranges from `-128` to `-42` (`-128` means a weak signal and `-42` means a strong one.)
>* ``signal strength``: the value ranges from `-128` up to `-28` (`-128` means a weak signal and `-28` means a strong one.)
>* ``serial number``: the value is the serial number of the board sending the packet.
>* ``time``: the value is the system time, in microseconds, of the sender at the time when the packet was sent.
@ -28,6 +28,7 @@ This program uses the signal strength from received packets to graph the
approximate distance between two @boardname@s.
```blocks
radio.setGroup(1)
basic.forever(() => {
radio.sendNumber(0)
})

View File

@ -6,29 +6,35 @@ Find how strong the radio signal is.
radio.receivedSignalStrength();
```
## ~ hint
### ~ hint
**Deprecated**
#### Deprecated
This API has been deprecated! Use [received packet](/reference/radio/received-packet) instead.
## ~
### ~
Find how strong the ``radio`` signal is, from `-128` to `-42`.
(`-128` means a weak signal and `-42` means a strong one.)
Find how strong the ``radio`` signal is, from `-128` to `-28`.
(`-128` means a weak signal and `-28` means a strong one.)
The @boardname@ finds the signal strength by checking how strong it was
the last time it ran the
[on received number](/reference/radio/on-received-number) function. That means
it needs to run **receive number** first.
## Returns
* a [number](/types/number) between `-128` and `-42` that means
* a [number](/types/number) between `-128` and `-28` that means
how strong the signal is.
### ~ hint
#### Signal strength and board version
Measurement of the received signal strength is dependent on what version of @boardname@ you have. The @boardname@ boards prior to v2 can typically measure a signal strength up to `-42` dBm. Now, v2 boards will measure a signal strength up to `-28` dBm (typical).
### ~
## Simulator
This function only works on the @boardname@, not in browsers.
@ -49,7 +55,8 @@ basic.forever(() => {
## See also
[on received number](/reference/radio/on-received-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
[on received number](/reference/radio/on-received-number), [send number](/reference/radio/send-number),
[on data received](/reference/radio/on-data-received), [received packet](/reference/received-packet)
```package
radio

View File

@ -19,6 +19,7 @@ If you load this program onto two @boardname@s, each board will send the level i
```typescript
let ax = 0;
let ay = 0;
radio.setGroup(6)
basic.forever(() => {
ax = input.acceleration(Dimension.X);
ay = input.acceleration(Dimension.Y);

View File

@ -27,7 +27,7 @@ in the `x` direction (left and right) to other @boardname@s. This kind
of program might be useful in a model car or model rocket.
```blocks
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
radio.sendNumber(input.acceleration(Dimension.X))
})
```

View File

@ -26,7 +26,8 @@ code word from one of them to the others by pressing button `A`. The
other @boardname@s will receive the code word and then show it.
```blocks
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
radio.setGroup(1)
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
radio.sendString("Codeword: TRIMARAN")
basic.showString("SENT");
})

View File

@ -29,7 +29,7 @@ or model rocket.
```blocks
radio.setGroup(99)
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
radio.sendValue("acc", input.acceleration(Dimension.X))
})
```

View File

@ -20,6 +20,14 @@ to talk to each other because they will have the same group ID.
* **id**: a [number](/types/number) from ``0`` to ``255``.
### ~ reminder
#### Default radio group
If you haven't set a radio group for the @boardname@, it will use one selected randomly. If you are transmiting data to a @boardname@ that has a different hardware version from the sending @boardname@, it will select a random default group that is not the same as the other @boardname@. To be certain that your program will send or receive data using the same radio group, you will need to first choose and set a radio group for your program if you want it to work between different versions of the @boardname@.
### ~
## Simulator
This function only works on the @boardname@, not in browsers.

View File

@ -9,6 +9,14 @@ radio.writeReceivedPacketToSerial();
This should be called within a callback to
[on data packet received](/reference/radio/on-data-packet-received).
### ~ hint
#### Deprecated
This API has been deprecated! Use [serial write value](/reference/serial/write-value) instead.
### ~
## Data received format
The format for received data when these send functions are used:
@ -19,6 +27,8 @@ The format for received data when these send functions are used:
### ~hint
#### Default serial number
The serial number value sent in the packet is set to `0` unless transmission of the serial number is enabled with ``||radio:radio set transmit serial number||``.
### ~
@ -30,7 +40,8 @@ the second @boardname@), this program sends temperature data to the
serial port.
```blocks
input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
radio.setGroup(44)
input.onButtonEvent(Button.A, input.buttonEventClick(), function () {
radio.sendNumber(input.temperature())
radio.sendValue("temp", input.temperature())
radio.sendString("It's warm now")

View File

@ -29,7 +29,8 @@ the second @boardname@), this program sends temperature data to
serial.
```blocks
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
radio.setGroup(1)
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
radio.sendNumber(input.temperature());
});
radio.onDataReceived(() => {