Radiodocsupdate (#1430)

* a few updates

* more updates

* reorder radio blocks

* more shuffling of new radio apis

* fixing hot or ocold

* more doc fixes

* more updates

* fixing docs issues

* more doc fixes

* restore docs errors

* missing packate

* renamed argument of callback

* mssing radio

* more odcs fixes

* lock turtle

* ignore docs for now
This commit is contained in:
Peli de Halleux
2018-10-15 15:32:09 -07:00
committed by GitHub
parent 11fbbea5bd
commit 2b504d863d
49 changed files with 218 additions and 136 deletions

View File

@ -46,8 +46,7 @@ Here is the complete Marco Polo program:
input.onButtonPressed(Button.A, () => {
radio.sendString("Marco")
})
radio.onDataPacketReceived(({ receivedString }) => {
radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
})
input.onButtonPressed(Button.B, () => {
@ -69,7 +68,7 @@ input.onButtonPressed(Button.A, () => {
radio.sendString("Marco")
music.playTone(131, music.beat(BeatFraction.Whole))
})
radio.onDataPacketReceived( ({ receivedString }) => {
radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
})
input.onButtonPressed(Button.B, () => {
@ -134,7 +133,7 @@ In order to know whether to display a dot, a dash, or a space/stop image, we nee
* Leave the righthand side default value of zero in the 0=0 block.
```blocks
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
if (receivedNumber == 0) {
}
@ -145,7 +144,7 @@ radio.onDataPacketReceived( ({ receivedNumber }) => {
* Create an image to represent a dot.
```blocks
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
if (receivedNumber == 0) {
basic.showLeds(`
. . . . .
@ -168,7 +167,7 @@ Challenge question: How can we fix this?
* Add a 'pause' block and a 'clear screen' block after the 'show leds' block
```blocks
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
if (receivedNumber == 0) {
basic.showLeds(`
. . . . .
@ -198,7 +197,7 @@ Now each time the sender presses button A, you see a dot appear.
```blocks
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
if (receivedNumber == 0) {
basic.showLeds(`
. . . . .
@ -282,7 +281,7 @@ input.onButtonPressed(Button.B, () => {
input.onButtonPressed(Button.AB, () => {
radio.sendNumber(2)
})
radio.onDataPacketReceived(({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
if (receivedNumber == 0) {
basic.showLeds(`
. . . . .

View File

@ -27,7 +27,7 @@ Second micro:bit that plays the notes
```blocks
let sound = 0
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
if (receivedNumber == 0) {
sound = 349
music.playTone(sound, music.beat(BeatFraction.Half))

View File

@ -89,7 +89,7 @@ basic.forever(() => {
This receiver @boardname@ uses the “on start” event to set up the title on the @boardname@ when started, the radio group, and the ``bodyElectricity`` variable to collect and store the data received.
The ``||radio:on radio received||`` event reads the number value sent from the sending @boardname@. The number is then stored in the ``bodyElectricity`` variable. the electricity on pin **0** and stores it in the variable ``bodyElectricity``. The last line uses the serial write command to send the text `"Body Electricity"` label and the value of ``bodyElectricity`` variable back to the Windows 10 MakeCode app. The data is sampled and send from 10 to 20 times per second.
The ``||radio:on received number||`` event reads the number value sent from the sending @boardname@. The number is then stored in the ``bodyElectricity`` variable. the electricity on pin **0** and stores it in the variable ``bodyElectricity``. The last line uses the serial write command to send the text `"Body Electricity"` label and the value of ``bodyElectricity`` variable back to the Windows 10 MakeCode app. The data is sampled and send from 10 to 20 times per second.
```blocks
// Body Electricity Receiver
@ -98,7 +98,7 @@ let bodyElectricty = 0
radio.setGroup(99)
// Radio Receiver event
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
bodyElectricty = receivedNumber
serial.writeValue("Body Electricty", bodyElectricty)
})

View File

@ -85,7 +85,7 @@ In the radio received event, the temperature is received from sending the micro:
let temperature = 0
radio.setGroup(99)
basic.showString("TEMPERATURE RECEIVER")
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
basic.showNumber(receivedNumber)
})
```
@ -99,7 +99,7 @@ This code is the same as above but one additional line of code is added to write
let temperature = 0
basic.showString("TEMPERATURE RECEIVER SERIAL")
radio.setGroup(99)
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
basic.showNumber(receivedNumber)
serial.writeValue("Celisus", receivedNumber)
})
@ -143,14 +143,14 @@ basic.showString("GRAVITY RECEIVER")
radio.setGroup(99)
```
The ``||radio:on radio received||`` event will constantly monitor radio signals from the radio group.
The ``||radio:on received number||`` event will constantly monitor radio signals from the radio group.
When a value is received from the group it is stored in the ``gravity`` variable.
The ``||serial:serial write value||`` sends 2 pieces of data back to the MakeCode app through the USB cable. First it sends a label `"gravity"` and then the value received as gravity from the ``||input:acceleration||`` method from the first micro:bit.
```blocks
basic.showString("GRAVITY RECEIVER")
radio.setGroup(99)
radio.onDataPacketReceived( ({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
serial.writeValue("gravity", receivedNumber)
})
```

View File

@ -52,7 +52,7 @@ radio.setGroup(99)
#### Code the receive event
7. The ``||radio:on radio received||`` event will constantly monitor radio signals from the radio group.
7. The ``||radio:on received number||`` event will constantly monitor radio signals from the radio group.
8. When a value is received from the group it is stored in the ``gravity`` variable.
9. The ``||serial:serial write Value||`` sends 2 pieces of data back to the MakeCode app through the USB cable. First it sends a label `"gravity"` and then the value received as gravity from the acceleration method from the first @boardname@.
10. Add a ``||led:toggle||`` to indicate that it's receiving data. Change ``x`` to `1` so that another LED blinks.
@ -60,8 +60,8 @@ radio.setGroup(99)
```blocks
basic.showString("GRAVITY RECEIVER")
radio.setGroup(99)
radio.onDataPacketReceived( ({ receivedNumber: gravity }) => {
serial.writeValue("gravity", gravity)
radio.onReceivedNumber(function (receivedNumber) {
serial.writeValue("gravity", receivedNumber)
led.toggle(1, 0)
})
```

View File

@ -71,11 +71,11 @@ radio.setGroup(10)
serial.writeLine("Acceleration")
```
The ``||radio:on radio received||`` event reads the number value from the sending @boardname@. The number is then stored in the variable ``receivedNumber``. The last line uses the serial write command to send the text ``"z"`` label and the value of ``receivedNumber`` variable back to the Windows 10 MakeCode app. The data is sampled and send from 10 to 20 times per second.
The ``||radio:on received number||`` event reads the number value from the sending @boardname@. The number is then stored in the variable ``receivedNumber``. The last line uses the serial write command to send the text ``"z"`` label and the value of ``receivedNumber`` variable back to the Windows 10 MakeCode app. The data is sampled and send from 10 to 20 times per second.
```blocks
// onRadio receive & write z value to serial
radio.onDataPacketReceived(({ receivedNumber }) => {
radio.onReceivedNumber(function (receivedNumber) {
serial.writeValue("z", receivedNumber)
})
```

View File

@ -102,14 +102,14 @@ basic.forever(() => {
In the starting of the code the title is displayed, radio group `99` is setup, and the initial ``temperature`` variable is set to `0`.
In the ``||radio:on radio received||`` event, the temperature is received from sending the @boardname@ radio. The receive temperature is then displayed on the LED display. This is repeated whenever a radio signal is received.
In the ``||radio:on received number||`` event, the temperature is received from sending the @boardname@ radio. The receive temperature is then displayed on the LED display. This is repeated whenever a radio signal is received.
```blocks
let temperature = 0
basic.showString("TEMPERATURE RADIO RECEIVER")
radio.setGroup(99)
radio.onDataPacketReceived( ({ receivedNumber: temperature }) => {
basic.showNumber(temperature)
radio.onReceivedNumber( function(receivedNumber) {
basic.showNumber(receivedNumber)
})
```
@ -121,9 +121,9 @@ This code is the same as above but one additional line of code is added to write
let temperature = 0
basic.showString("TEMPERATURE RADIO RECEIVER SERIAL")
radio.setGroup(99)
radio.onDataPacketReceived( ({ receivedNumber: temperature }) => {
basic.showNumber(temperature)
serial.writeValue("Celisus", temperature)
radio.onReceivedNumber( function(receivedNumber) {
basic.showNumber(receivedNumber)
serial.writeValue("Celisus", receivedNumber)
})
```