Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
532abadb6b | |||
eea179e07c | |||
f94015803f | |||
f085253306 | |||
6de2f22542 | |||
3051e09bcf | |||
bd835a8a6e | |||
f75a034a3f | |||
71b3b6bb22 | |||
b868bd1e09 | |||
02e48f196c |
@ -234,22 +234,19 @@ Here are the blocks to make your coin flipper. When you press button
|
||||
on the LED screen.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
```
|
||||
### ~hint
|
||||
|
||||
The ``pick random true or false`` block randomly tells the ``if``
|
||||
block `true` or `false`. If the ``pick`` block
|
||||
picked `true`, the ``if`` block shows the letter `H`. Otherwise, it
|
||||
shows the letter `T`.
|
||||
block `true` or `false`. If the ``pick`` block picked `true`, the
|
||||
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
|
||||
|
||||
That's it!
|
||||
|
||||
@ -280,20 +277,18 @@ show your score.
|
||||
When you're done, your coin flipping program should look like this:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1);
|
||||
});
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
basic.showNumber(game.score());
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1);
|
||||
});
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
basic.showNumber(game.score());
|
||||
});
|
||||
```
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
# Change Tempo By
|
||||
|
||||
Change the tempo by the specified amount
|
||||
Makes the [tempo](/reference/music/tempo) (speed of a piece of music)
|
||||
faster or slower by the amount you say.
|
||||
|
||||
## Simulator
|
||||
|
||||
Simulation of this function is available in many, but not all browsers.
|
||||
This function only works on the micro:bit and in some browsers.
|
||||
|
||||
```sig
|
||||
music.changeTempoBy(20)
|
||||
@ -12,7 +13,21 @@ music.changeTempoBy(20)
|
||||
|
||||
### Parameters
|
||||
|
||||
* `bpm` : [Number](/reference/types/number) - change the tempo by beats per minute
|
||||
* a [number](/reference/types/number) that says how much to change the bpm (beats per minute, or number of beats in a minute of the music that the micro:bit is playing).
|
||||
|
||||
### Examples
|
||||
|
||||
This program makes the music faster by 12 bpm.
|
||||
|
||||
```blocks
|
||||
music.changeTempoBy(12)
|
||||
```
|
||||
|
||||
This program makes the music _slower_ by 12 bpm.
|
||||
|
||||
```blocks
|
||||
music.changeTempoBy(-12)
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
# Rest
|
||||
|
||||
Rests (plays nothing) for a specified time through pin PO.
|
||||
Rest (play no sound) through pin `PO` for the amount of time you say.
|
||||
|
||||
## Simulator
|
||||
|
||||
Simulation of this function is available in many, but not all browsers.
|
||||
This function only works on the micro:bit and in some browsers.
|
||||
|
||||
```sig
|
||||
music.rest(400)
|
||||
@ -12,7 +12,7 @@ music.rest(400)
|
||||
|
||||
### Parameters
|
||||
|
||||
* `ms`: [Number](/reference/types/number) - the duration of the rest (milliseconds)
|
||||
* a [number](/reference/types/number) saying how many milliseconds the micro:bit should rest. One second is 1000 milliseconds.
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -1,14 +1,17 @@
|
||||
# Set Tempo
|
||||
|
||||
Sets the tempo to the specified amount
|
||||
Makes the tempo (speed of a piece of music) as fast or slow as you say.
|
||||
|
||||
```sig
|
||||
music.setTempo(60)
|
||||
```
|
||||
## Simulator
|
||||
|
||||
This function only works on the micro:bit and in some browsers.
|
||||
|
||||
### Parameters
|
||||
|
||||
* Returns : [Number](/reference/types/number) - sets the tempo in beats per minute
|
||||
* a [number](/reference/types/number) that means the bpm you want (beats per minute, or number of beats in a minute of the music that the micro:bit is playing).
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -129,7 +129,7 @@ namespace devices {
|
||||
|
||||
/**
|
||||
* Sends a ``camera`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=30 help=devices/tell-camera-to
|
||||
//% blockId=devices_camera icon="\uf030" block="tell camera to|%property" blockGap=8
|
||||
@ -139,7 +139,7 @@ namespace devices {
|
||||
|
||||
/**
|
||||
* Sends a ``remote control`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=29 help=devices/tell-remote-control-to
|
||||
//% blockId=devices_remote_control block="tell remote control to|%property" blockGap=14 icon="\uf144"
|
||||
@ -149,7 +149,7 @@ namespace devices {
|
||||
|
||||
/**
|
||||
* Sends an ``alert`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=27 help=devices/raise-alert-to
|
||||
//% blockId=devices_alert block="raise alert to|%property" icon="\uf0f3"
|
||||
@ -159,19 +159,19 @@ namespace devices {
|
||||
|
||||
/**
|
||||
* Registers code to run when the device notifies about a particular event.
|
||||
* @param event TODO
|
||||
* @param body TODO
|
||||
* @param event event description
|
||||
* @param body code handler when event is triggered
|
||||
*/
|
||||
//% help=devices/on-notified weight=26
|
||||
//% blockId=devices_device_info_event block="on notified" icon="\uf10a"
|
||||
//% blockId=devices_device_info_event block="on notified|%event" icon="\uf10a"
|
||||
void onNotified(MesDeviceInfo event, Action body) {
|
||||
registerWithDal(MES_DEVICE_INFO_ID, (int)event, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register code to run when the micro:bit receives a command from the paired gamepad.
|
||||
* @param name TODO
|
||||
* @param body TODO
|
||||
* @param name button name
|
||||
* @param body code to run when button is pressed
|
||||
*/
|
||||
//% help=devices/on-gamepad-button weight=40
|
||||
//% weight=25
|
||||
@ -188,7 +188,7 @@ namespace devices {
|
||||
static void initSignalStrength() {
|
||||
if (_signalStrength < 0) {
|
||||
_signalStrength = 0;
|
||||
uBit.MessageBus.listen(MES_SIGNAL_STRENGTH_ID, MICROBIT_EVT_ANY, signalStrengthHandler);
|
||||
uBit.messageBus.listen(MES_SIGNAL_STRENGTH_ID, MICROBIT_EVT_ANY, signalStrengthHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,5 +20,5 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"installedVersion": "zakvul"
|
||||
"installedVersion": "ljipgq"
|
||||
}
|
||||
|
16
libs/microbit-devices/shims.d.ts
vendored
16
libs/microbit-devices/shims.d.ts
vendored
@ -7,7 +7,7 @@ declare namespace devices {
|
||||
|
||||
/**
|
||||
* Sends a ``camera`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=30 help=devices/tell-camera-to
|
||||
//% blockId=devices_camera icon="\uf030" block="tell camera to|%property" blockGap=8 shim=devices::tellCameraTo
|
||||
@ -15,7 +15,7 @@ declare namespace devices {
|
||||
|
||||
/**
|
||||
* Sends a ``remote control`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=29 help=devices/tell-remote-control-to
|
||||
//% blockId=devices_remote_control block="tell remote control to|%property" blockGap=14 icon="\uf144" shim=devices::tellRemoteControlTo
|
||||
@ -23,7 +23,7 @@ declare namespace devices {
|
||||
|
||||
/**
|
||||
* Sends an ``alert`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=27 help=devices/raise-alert-to
|
||||
//% blockId=devices_alert block="raise alert to|%property" icon="\uf0f3" shim=devices::raiseAlertTo
|
||||
@ -31,17 +31,17 @@ declare namespace devices {
|
||||
|
||||
/**
|
||||
* Registers code to run when the device notifies about a particular event.
|
||||
* @param event TODO
|
||||
* @param body TODO
|
||||
* @param event event description
|
||||
* @param body code handler when event is triggered
|
||||
*/
|
||||
//% help=devices/on-notified weight=26
|
||||
//% blockId=devices_device_info_event block="on notified" icon="\uf10a" shim=devices::onNotified
|
||||
//% blockId=devices_device_info_event block="on notified|%event" icon="\uf10a" shim=devices::onNotified
|
||||
function onNotified(event: MesDeviceInfo, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Register code to run when the micro:bit receives a command from the paired gamepad.
|
||||
* @param name TODO
|
||||
* @param body TODO
|
||||
* @param name button name
|
||||
* @param body code to run when button is pressed
|
||||
*/
|
||||
//% help=devices/on-gamepad-button weight=40
|
||||
//% weight=25
|
||||
|
@ -9,9 +9,13 @@
|
||||
"testFiles": [
|
||||
"neotest.ts"
|
||||
],
|
||||
"microbit": {
|
||||
"yotta": {
|
||||
"config": {
|
||||
"MICROBIT_BLE_ENABLED": "0"
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"public": true,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.2.153",
|
||||
"version": "0.2.155",
|
||||
"description": "BBC micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -29,6 +29,6 @@
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.2.165"
|
||||
"pxt-core": "0.2.167"
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,9 @@
|
||||
"corepkg": "microbit",
|
||||
"bundleddirs": [
|
||||
"libs/microbit",
|
||||
"libs/microbit-radio"
|
||||
"libs/microbit-radio",
|
||||
"libs/microbit-devices",
|
||||
"libs/neopixel"
|
||||
],
|
||||
"cloud": {
|
||||
"workspace": false,
|
||||
@ -105,10 +107,6 @@
|
||||
{
|
||||
"name": "Lessons",
|
||||
"path": "/lessons"
|
||||
},
|
||||
{
|
||||
"name": "Device",
|
||||
"path": "/device"
|
||||
}
|
||||
],
|
||||
"sideDoc": "getting-started"
|
||||
|
Reference in New Issue
Block a user