fixing references / snippets

cleanup "snippets" compilation state
This commit is contained in:
Peli de Halleux 2016-10-22 21:29:31 -07:00
parent fcefe1ed36
commit bd1536132d
51 changed files with 94 additions and 91 deletions

View File

@ -41,8 +41,8 @@ In JavaScript, there is the concept of an *empty statement*, which is whitespace
a semicolon in the context where a statement is expected.
So, the following code is an infinite loop
followed by a call to `showNumber` that will never execute:
```typescript
while(true) ;
```typescript-ignore
while(true) ;
basic.showNumber(1);
```

View File

@ -51,6 +51,8 @@ I'll be ${ age + 1 } years old next month.`
This is equivalent to declaring `sentence` like so:
```ts
let fullName: string = `Bob Bobbington`;
let age: number = 37;
let sentence: string = "Hello, my name is " + fullName + ".\n\n" +
"I'll be " + (age + 1) + " years old next month."
```
@ -82,7 +84,7 @@ A helpful addition to the standard set of datatypes from JavaScript is the `enum
As in languages like C#, an enum is a way of giving more friendly names to sets of numeric values.
```ts
enum Color {Red, Green, Blue};
enum Color {Red, Green, Blue}
let c: Color = Color.Green;
```
@ -91,14 +93,14 @@ You can change this by manually setting the value of one of its members.
For example, we can start the previous example at `1` instead of `0`:
```ts
enum Color {Red = 1, Green, Blue};
enum Color {Red = 1, Green, Blue}
let c: Color = Color.Green;
```
Or, even manually set all the values in the enum:
```ts
enum Color {Red = 1, Green = 2, Blue = 4};
enum Color {Red = 1, Green = 2, Blue = 4}
let c: Color = Color.Green;
```

View File

@ -6,43 +6,43 @@ a game similar to "Simon Says" with the BBC micro:bit.
Complete the following guided tutorial. Your code should look like this:
```blocks
newAction() // ***
```typescript
let action = 0;
function newAction() {}
input.onButtonPressed(Button.A, () => {
if (action == 0) {
game.addScore(1) // ***
newAction() // ***
game.addScore(1);
newAction();
}
}) // ***
})
input.onLogoDown(() => {
if (action == 1) {
game.addScore(1) // ***
newAction()
game.addScore(1);
newAction();
}
})
input.onGesture(Gesture.Shake, () => {
if (action == 2) {
game.addScore(1)
newAction()
game.addScore(1);
newAction();
}
})
input.onButtonPressed(Button.B, () => {
basic.showNumber(game.score(), 150) // ***
basic.pause(2000) // ***
newAction() // ***
basic.showNumber(game.score(), 150);
basic.pause(2000);
newAction();
})
```
### Challenge 1
Now let's add some more types of instructions for the player to follow. Let's add `PRESS PIN 0`. Change the global variable `action` to `math->random(4)` so that we can add a new **IF** statement that checks if `action=3`. If it does, display instructions to press pin 0.
Now let's add some more types of instructions for the player to follow. Let's add `PRESS PIN 0`.
Change the global variable `action` to `math->random(4)` so that we can add a new **IF** statement that checks if `action=3`. If it does, display instructions to press pin 0.
```blocks
/**
* {highlight}
*/
```typescript
let action = 0;
export function newAction() {
action = Math.random(4) // ***
action = Math.random(4)
if (action == 0) {
basic.showString("PUSH A", 150) // ***
}
@ -62,19 +62,22 @@ export function newAction() {
Now let's implement `PRESS PIN 0` in the main. Create a condition of `input->on pin pressed("P0")` that will add one to the score and calls the method `new action`.
```blocks
// **. . .**
```typescript
let action = 0;
export function newAction() {
// ...
}
input.onButtonPressed(Button.B, () => {
basic.showNumber(game.score(), 150) // ***
basic.pause(2000) // ***
newAction() // ***
}) // ***
basic.showNumber(game.score(), 150)
basic.pause(2000)
newAction()
})
input.onPinPressed(TouchPin.P0, () => {
if (action == 3) {
game.addScore(1) // ***
newAction() // ***
game.addScore(1)
newAction()
}
}) // ***
})
```
### Challenge 3

View File

@ -88,5 +88,5 @@ Have fun reviewing your simulation and analyze the acceleration by chart the Exc
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"
```package
microbit-radio
radio
```

View File

@ -29,6 +29,7 @@ Write the line of code that will display the string "puppy" using `data->coll`.
<br/>
```blocks
let coll: string[] = []
basic.showString(coll[0], 150)
```
@ -46,6 +47,7 @@ Write the line of code that will display the string "cat" using `data->coll`.
<br/>
```blocks
let coll: string[] = []
basic.showString(coll[2], 150)
```

View File

@ -44,5 +44,5 @@ radio.onDataReceived(() => { })
* learn how to pause your code for the specified number of milliseconds
```package
microbit-radio
radio
```

View File

@ -164,5 +164,5 @@ Connect the second micro:bit to your computer using your USB cable and run the p
The first person and second person take turns jumping in the “y” direction while the other player uses the micro:bit to track the results on the micro:bit!
```package
microbit-radio
radio
```

View File

@ -35,5 +35,5 @@ radio.receiveNumber();
* learn how to read the connector value as analog as a value comprised between 0 and 1023
```package
microbit-radio
radio
```

View File

@ -196,5 +196,5 @@ Let's select Style 10 as an example.
* Review and analyze the actual micro:bit device acceleration data on Excel
```package
microbit-radio
radio
```

View File

@ -25,8 +25,9 @@ let randomArrow = Math.random(4)
<br/>
```blocks
let randomArrow = Math.random(4);
if (randomArrow == 1) {
basic.plotImage(`
basic.showLeds(`
. . # . .
. . # . .
# # # # #
@ -43,8 +44,9 @@ if (randomArrow == 1) {
<br />
```blocks
let randomArrow = Math.random(4);
if (randomArrow == 2) {
basic.plotImage(`
basic.showLeds(`
. . # . .
. . # # .
# # # # #

View File

@ -61,5 +61,5 @@ radio.onDataReceived(() => {
```package
microbit-radio
radio
```

View File

@ -90,5 +90,5 @@ Have fun reviewing your simulation and analyze the acceleration by chart the Exc
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"
```package
microbit-radio
radio
```

View File

@ -8,7 +8,6 @@ We now need to digitally write to pin ``P0`` as **high** (1).
```blocks
pins.digitalWritePin(DigitalPin.P0, 1)
```
### Step 2
@ -19,7 +18,6 @@ So insert the appropriate LED plot x, y.
```blocks
pins.digitalWritePin(DigitalPin.P0, 1)
led.plot(2, 2)
```
### Step 3
@ -31,9 +29,7 @@ Then add a condition that occurs if we do not turn on a LED with plot x, y. We a
if (input.buttonIsPressed(Button.A)) {
pins.digitalWritePin(DigitalPin.P0, 1)
led.plot(2, 2)
} else {
}
} else { }
```
@ -63,7 +59,8 @@ basic.forever(() => {
} else {
pins.digitalWritePin(DigitalPin.P0, 0)
led.unplot(2, 2)
})
}
})
```
### Step 6
@ -87,9 +84,6 @@ basic.forever(() => {
basic.clearScreen();
}
});
```
Your telegraph is ready!

View File

@ -37,9 +37,9 @@ bluetooth.onBluetoothConnected(() => {});
```
```package
microbit-radio
microbit-devices
microbit-bluetooth
radio
devices
bluetooth
```
### See Also

View File

@ -32,7 +32,7 @@ bluetooth.uartWriteValue("", 0);
```
```package
microbit-bluetooth
bluetooth
```
### Advanced

View File

@ -95,5 +95,5 @@ https://www.youtube.com/watch?v=aep_GVowKfs
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -96,5 +96,5 @@ If you do find yourself needing to pair again you will first need to remove the
```package
microbit-bluetooth
bluetooth
```

View File

@ -33,5 +33,5 @@ http://www.youtube.com/watch?v=HyBcsD9Eh6I
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -33,5 +33,5 @@ http://www.youtube.com/watch?v=HyBcsD9Eh6I
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -38,5 +38,5 @@ For more advanced information on the micro:bit Bluetooth accelerometer service i
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -42,5 +42,5 @@ For more advanced information on the micro:bit Bluetooth button service includin
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -36,5 +36,5 @@ For more advanced information on the micro:bit Bluetooth IO pin service includin
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -38,5 +38,5 @@ For more advanced information on the micro:bit Bluetooth LED service including i
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -39,5 +39,5 @@ For more advanced information on the micro:bit Bluetooth magnetometer service in
```package
microbit-bluetooth
bluetooth
```

View File

@ -39,6 +39,6 @@ For more advanced information on the micro:bit Bluetooth temperature service inc
```package
microbit-bluetooth
bluetooth
```

View File

@ -40,5 +40,5 @@ For more advanced information on the micro:bit Bluetooth UART service including
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -48,5 +48,5 @@ For more advanced information on the micro:bit Bluetooth UART service including
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -24,5 +24,5 @@ For more advanced information on the micro:bit Bluetooth UART service including
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -47,5 +47,5 @@ For more advanced information on the micro:bit Bluetooth UART service including
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -24,5 +24,5 @@ For more advanced information on the micro:bit Bluetooth UART service including
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
bluetooth
```

View File

@ -19,7 +19,7 @@ devices.onSignalStrengthChanged(() => {
```
```package
microbit-devices
devices
```
### See Also

View File

@ -23,5 +23,5 @@ devices.onGamepadButton(MesDpadButtonInfo.ADown, () => {})
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [signal strength](/reference/devices/signal-strength), [on signal strength changed](/reference/devices/on-signal-strength-changed)
```package
microbit-devices
devices
```

View File

@ -34,5 +34,5 @@ devices.onNotified(MesDeviceInfo.IncomingCall, () => {
[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
microbit-devices
devices
```

View File

@ -34,5 +34,5 @@ devices.onSignalStrengthChanged(() => {
[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
microbit-devices
devices
```

View File

@ -62,5 +62,5 @@ devices.raiseAlertTo("ring alarm")
[tell remote control to](/reference/devices/tell-remote-control-to), [tell camera to](/reference/devices/tell-camera-to)
```package
microbit-devices
devices
```

View File

@ -33,5 +33,5 @@ devices.onSignalStrengthChanged(() => {
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [on signal strength changed](/reference/devices/on-signal-strength-changed)
```package
microbit-devices
devices
```

View File

@ -73,5 +73,5 @@ devices.tellCameraTo("stop video mode")
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to)
```package
microbit-devices
devices
```

View File

@ -86,5 +86,5 @@ devices.tellRemoteControlTo("volume down")
```package
microbit-devices
devices
```

View File

@ -33,12 +33,12 @@ basic.forever(() => {
This program measures the temperature using Fahrenheit degrees.
Fahrenheit is a way of measuring temperature that is commonly used in the United States.
To make a Celsius temperature into a Fahrenheit one, multiply the Celsius temperature by
1.8 and add 32.
``18``, divide by ``10`` and add ``32``.
```blocks
basic.forever(() => {
let c = input.temperature()
let f = (c * 1.8) + 32
let f = (c * 18) / 10 + 32
basic.showNumber(f)
})
```

View File

@ -20,7 +20,7 @@ radio.writeValueToSerial();
```
```package
microbit-radio
radio
```
### See Also

View File

@ -34,5 +34,5 @@ radio.onDataReceived(() => {
[send number](/reference/radio/send-number), [set group](/reference/radio/set-group)
```package
microbit-radio
radio
```

View File

@ -65,5 +65,5 @@ basic.forever(() => {
[send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -91,5 +91,5 @@ radio.onDataReceived(() => {
[send string](/reference/radio/send-string), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -40,5 +40,5 @@ basic.forever(() => {
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -45,5 +45,5 @@ basic.forever(() => {
[receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -42,5 +42,5 @@ A radio that can both transmit and receive is called a _transceiver_.
[receive string](/reference/radio/receive-string), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -45,5 +45,5 @@ radio.onDataReceived(() => {
[receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -35,5 +35,5 @@ radio.setGroup(128)
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -40,5 +40,5 @@ radio.setTransmitPower(7)
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -27,5 +27,5 @@ radio.setTransmitSerialNumber(true);
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```

View File

@ -53,5 +53,5 @@ Sample output to serial when ``A`` button pressed:
[on data received](/reference/radio/on-data-received)
```package
microbit-radio
radio
```