Skip to content

Commit be7858c

Browse files
authored
Cherry picked fixes from v0 to v1 (#1476)
* Fix example and do a few edits (#850) * Small fixes to the Karel project text (#862) * fix missing shadow type * add calibration info (#897) microbit-support:6348 User reported bug, but didn't realie micro:bit compass had to be calibrated on first run of the program. * Cherry pick adding various cross-editor compat APIs (#863) * fix nudge * Fix a typo ("screent") in the documentation (#1012) * Fix a typo "screent" -> "the LED screen" * Update showArrow doc string for consistency with other methods * Doc bugs found by xlators (#899) * Update rotation.md (#998) reflects actual behaviour of the board * fixed layout corruption (#1073) * Updating the new bug filer with the right link * Update challenges.md (#1325) For what I'm taught in school, 2 follows 1 😉😉. * Update simulator.md (#1209) * Update plant watering.md (#1264) the connection to servo are male not female * support for MIDI simulator in v0 (#1331) * Doc improvements (#1337) * update grammar in radio-dashboard sample code * Chanllenge 2 follows 1 I open all challenges.md without "Challenge 2" and review the file `grep -r "Challenge 2" -L | grep challenge | xargs -I@ code @` Changes to be committed: modified: docs/lessons/counter/challenges.md modified: docs/lessons/game-counter/challenges.md modified: docs/lessons/night-light/challenges.md modified: docs/lessons/snowflake-fall/challenges.md * Revert "support for MIDI simulator in v0 (#1331)" This reverts commit 30a9c41. * Revert "Cherry pick adding various cross-editor compat APIs (#863)" This reverts commit 7308dbe. * Fixed pin needed to replace button A (#1385) * Cherry pick part of the signature update in in2cWriteBuffer (#863): 7308dbe
1 parent ffe59b9 commit be7858c

27 files changed

+61
-58
lines changed

docs/contact.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
* Have a question, or running into an issue? Check out the [micro:bit Support Forums](https://support.microbit.org/).
44
* Want to get involved with the micro:bit developer community? [Get involved here](https://tech.microbit.org/get-involved/where-to-find/).
5-
* Think you've found a bug on MakeCode for micro:bit? File it [here](https://github.com/Microsoft/pxt-microbit/issues/new?labels=bug).
5+
* Think you've found a bug on MakeCode for micro:bit? File it [here](https://github.com/Microsoft/pxt-microbit/issues/new?template=bug_report.md).

docs/device/pins.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Unlike the three large pins that are dedicated to being used for external connec
4141

4242
* **pin 3**: GPIO shared with LED Col 1 of the LED screen; can be used for ADC and digital I/O when the LED screen is turned off.
4343
* **pin 4**: GPIO shared with LED Col 2 of the LED screen; can be used for ADC and digital I/O when the LED screen is turned off.
44-
* **pin 5**: GPIO shared with Button A. This lets you trigger or detect a button "A" click externally. This pin has a pull-up resistor, which means that by default it is at voltage of 3V. To replace button A on the micro:bit with an external button, connect one end of the external button to pin 4 and the other end to GND. When the button is pressed, the voltage on pin 4 is pulled down to 0, which generates a button click event.
44+
* **pin 5**: GPIO shared with Button A. This lets you trigger or detect a button "A" click externally. This pin has a pull-up resistor, which means that by default it is at voltage of 3V. To replace button A on the micro:bit with an external button, connect one end of the external button to pin 5 and the other end to GND. When the button is pressed, the voltage on pin 5 is pulled down to 0, which generates a button click event.
4545
* **pin 6**: GPIO shared with LED Col 9 of the LED screen; can be used for digital I/O when the LED screen is turned off.
4646
* **pin 7**: GPIO shared with LED Col 8 of the LED screen; can be used for digital I/O when the LED screen is turned off.
4747
* **pin 8**: Dedicated GPIO, for sending and sensing digital signals.

docs/device/screen.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# LED screen
22

3-
The micro:bit LED screen
4-
53
```sim
64
basic.showLeds(`
75
# . # . #
@@ -12,7 +10,7 @@ The micro:bit LED screen
1210
`);
1311
```
1412

15-
The micro:bit LED screen consists of 25 red LED lights arranged in a 5X5 grid (5 LEDs across by 5 LEDs down).
13+
The micro:bit LED screen has 25 red LED lights arranged in a 5X5 grid (5 LEDs across by 5 LEDs down).
1614
In the screen above, we created a checkerboard pattern using the LEDs.
1715

1816
## Which LED?
@@ -35,7 +33,7 @@ Here are the x, y coordinates for the LEDs in the 5X5 grid:
3533

3634
`(0,4)` `(1,4)` `(2,4)` `(3,4)` `(4,4)`
3735

38-
The x, y coordinates for the LED in the centre of the grid are `(2,2)`. Starting from `(0,0)` count over 2 columns and then down 2 rows.
36+
The x, y coordinates for the LED in the center of the grid are `(2,2)`. Starting from `(0,0)` count over 2 columns and then down 2 rows.
3937

4038
## Check your understanding
4139

@@ -71,11 +69,11 @@ if(led.point(0,0)) {
7169

7270
## Display images, strings and numbers
7371

74-
Instead of turning individual LEDs on or off, as above, you can display an [image](/reference/images/image) directly to the screen or show text/numbers on screen using the [show number](/reference/basic/show-number)/[show string](/reference/basic/show-string) function.
72+
Instead of turning individual LEDs on or off, as above, you can display an [image](/reference/images/image) directly to the screen or show text and numbers on screen using the [show number](/reference/basic/show-number) and [show string](/reference/basic/show-string) functions.
7573

7674
## The display buffer
7775

78-
The micro:bit runtime keeps an in-memory representation of the state of all 25 LEDS. This state is known as the "display buffer" and controls which LEDS are on and which are off. The plot/unplot/point functions access the display buffer directly. On the other hand, the functions that show an image, number or string overwrite the buffer completely. To illustrate, first try running this code sequence
76+
The micro:bit runtime keeps a representation of the state of all 25 LEDS in memory. This state is known as the "display buffer" and controls which LEDs are on and which are off. The plot, unplot, and point functions access the display buffer directly. On the other hand, the functions that show an image, number, or string overwrite the buffer completely. To illustrate this, first try running this code sequence
7977

8078
```blocks
8179
basic.showString("d")
@@ -86,15 +84,14 @@ You will see the letter "d" displayed as well as the LED in position `0,0` lit u
8684

8785
```blocks
8886
led.plot(0, 0)
89-
basic.showString("d", 150)
87+
basic.showString("d")
9088
```
9189

9290
You will not see the LED at position `0,0` lit up because the `show string` function overwrites the whole display buffer.
9391

94-
9592
## Pins: P3, P4, P6, P7, P9, P10
9693

97-
These pins are coupled to the LED matrix display, and also it’s associated ambient light sensing mode.
94+
These pins are coupled to the LED matrix display and also to the display's associated ambient light sensing mode.
9895
To disable the display driver feature (which will automatically disable the light sensing feature) use the function [led.enable](/reference/led/enable).
9996

10097
More information at http://tech.microbit.org/hardware/edgeconnector_ds/ .

docs/device/simulator.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Simulator
22

3-
The JavaScript simulator allows to test and execute most BBC micro:bit programs in the browser.
4-
It allows to emulate sensor data or user interactions.
3+
The JavaScript simulator allows you to test and execute most BBC micro:bit programs in the browser.
4+
It allows you to emulate sensor data or user interactions.
55

66
```sim
77
input.onButtonPressed(Button.A, () => {
@@ -22,4 +22,4 @@ input.onPinPressed(TouchPin.P2, () => {
2222
input.temperature()
2323
input.compassHeading()
2424
input.lightLevel()
25-
```
25+
```

docs/examples/radio-dashboard.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/**
55
* Radio monitoring dashboard
66
*
7-
* Each radio client is represented by a dot on the screen.
7+
* Each radio client is represented by a dot on the screen.
88
* Once a client is registered, it will stay at the same pixel location
99
* forever.
1010
*
@@ -31,16 +31,16 @@ const clients: Client[] = [];
3131

3232
/* lazy allocate sprite */
3333
function getClient(id: number): Client {
34-
// needs an id to track radio client identity
34+
// needs an id to track radio client's identity
3535
if (!id)
3636
return undefined;
3737

38-
// look for cache clients
38+
// look for cached clients
3939
for (const client of clients)
4040
if (client.id == id)
4141
return client;
4242
const n = clients.length;
43-
if (n == 24) // out of pixels
43+
if (n == 24) // out of pixels
4444
return undefined;
4545
const client: Client = {
4646
id: id,
@@ -87,4 +87,4 @@ game.addScore(1)
8787

8888
```package
8989
radio
90-
```
90+
```

docs/lessons/counter/challenges.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ input.onButtonPressed(Button.B, () => {
3131
})
3232
```
3333

34-
## Challenge 3
34+
## Challenge 2
3535

3636
Now let's try to reset the counter when the @boardname@ is shaken. You will need to register an event handler with `on shake`.
3737

docs/lessons/game-counter/challenges.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ input.onButtonPressed(Button.B, () => {
3131
```
3232

3333

34-
## Challenge 3
34+
## Challenge 2
3535

3636
Now let's try to reset the counter when the @boardname@ is shaken. You will need to register an event handler with `on shake`.
3737

docs/lessons/night-light/challenges.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ input.onButtonPressed(Button.B, () => {
4646
```
4747

4848

49-
## Challenge 3
49+
## Challenge 2
5050

5151
Add an event handler with `on shake` to change the LED brightness back to a `255`.

docs/lessons/snowflake-fall/challenges.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ basic.forever(() => {
6262

6363
* Run your program and see if it works.
6464

65-
## Challenge 3
65+
## Challenge 2
6666

6767
Add a fourth frame to the current animation... or make it your own!
6868

docs/projects/fireflies.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,18 @@ basic.forever(() => {
8282
})
8383
```
8484

85-
When a firefly receives a radio packet, it increments its clock by one:
85+
When a firefly receives a radio packet
86+
**and** it is not sending packet
87+
, it increments its clock by one:
8688

8789
```block
8890
// the clock ticker
8991
let clock = 0
9092
radio.onReceivedNumber(function (receivedNumber) {
9193
// advance clock to catch up neighbors
92-
clock += 1
94+
if (clock < 8) {
95+
clock += 1
96+
}
9397
})
9498
```
9599

docs/projects/guitar/lightsensor.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ music.playTone(261, music.beat(BeatFraction.Half))
7979
## ~
8080

8181
## Step 3: Multiply Frequency using Math blocks
82-
```blocks
82+
```blocks
8383
input.onButtonPressed(Button.A, () => {
8484
music.playTone(261 * 2, music.beat(BeatFraction.Half))
8585
})

docs/projects/karel.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Help Karel make LED art!
1111
![](/static/mb/projects/karel/hi.png "Hi")
1212

1313
The goal of this activity is to download the JavaScript code given below onto a @boardname@.
14-
Then USE the program to introduce new students to the @boardname@.
14+
Then use the program to introduce new students to the @boardname@.
1515
Students will not do the coding this time. They will be the users who get familiar with the board.
1616

1717
## How to play
@@ -95,6 +95,8 @@ Thanks for playing with Karel the LED!
9595

9696
Copy this code into the JavaScript editor and then download it to the board.
9797

98+
**Note:** For this project you need to manually copy the code and insert it into the JavaScript view of the editor.
99+
98100
```typescript
99101
/**
100102
* Karel the LED

docs/projects/magic-button-trick.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ input.onButtonPressed(Button.B, () => {
9898

9999
Now you just need to program your own @boardname@ and practice the trick a few times before performing for your friends. Try asking your friends to click the buttons after you have switched the labels and the trick won't work for them because they don't have a hidden magnet in their hand!
100100

101+
Remember, that as we are using @boardname@'s compass, it will need to be [calibrated](https://support.microbit.org/support/solutions/articles/19000008874-calibrating-the-micro-bit-compass-what-does-it-mean-when-the-micro-bit-says-draw-a-circle-or-tilt) each time we flash the program or run it for the first time.
102+
101103
## About the authors
102104

103-
This project was contributed by Brian and Jasmine Norman, aka [@MicroMonstersUK](https://twitter.com/MicroMonstersUK). You can checkout their [MicroMonsters](https://www.youtube.com/channel/UCK2DviDexh_Er2QYZerZyZQ) tutorials channel on YouTube for more projects.
105+
This project was contributed by Brian and Jasmine Norman, aka [@MicroMonstersUK](https://twitter.com/MicroMonstersUK). You can checkout their [MicroMonsters](https://www.youtube.com/channel/UCK2DviDexh_Er2QYZerZyZQ) tutorials channel on YouTube for more projects.

docs/projects/plant-watering.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This is a follow up of the **[soil moisture project](/projects/soil-moisture)**.
2020
* 1 @boardname@ with battery pack and batteries
2121
* 2 long nails or silver
2222
* 2 crocodile clips
23-
* 1 micro servo + 3 female-to-croc clips
23+
* 1 micro servo + 3 male-to-croc clips
2424
* 1 ice cream wooden stick
2525
* 2 elastics
2626
* 1 clear tape roll

docs/reference/basic/show-string.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Show String
22

3-
Show a sting on the [LED screen](/device/screen). It will slide left if it is bigger than the screen.
3+
Show a string on the [LED screen](/device/screen). It will scroll to left if it's bigger than the screen.
44

55
```sig
66
basic.showString("Hello!")

docs/reference/bluetooth/advertise-uid-buffer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Avertise UID Buffer
1+
# Advertise UID Buffer
22

33
Advertises a UID via the Eddystone protocol over Bluetooth.
44

docs/reference/bluetooth/advertise-uid.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Avertise UID
1+
# Advertise UID
22

33
Advertises a UID via the Eddystone protocol over Bluetooth.
44

docs/reference/bluetooth/advertise-url.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Avertise Url
1+
# Advertise Url
22

33
Advertises a URL via the Eddystone protocol over Bluetooth.
44

docs/reference/devices/on-notified.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# On Signal Strength Changed
1+
# On Notified
22

33
Register code to run when the signal strength of the paired device changes.
44

@@ -8,8 +8,6 @@ Register code to run when the signal strength of the paired device changes.
88

99
## ~
1010

11-
12-
1311
```sig
1412
devices.onNotified(MesDeviceInfo.IncomingCall, () => {})
1513
```

docs/reference/devices/tell-camera-to.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,46 @@ devices.tellCameraTo(MesCameraEvent.TakePhoto)
2222
To tell the connected device to take a picture:
2323

2424
```blocks
25-
devices.tellCameraTo(MesCameraEvent.StartVideoCapture)
25+
devices.tellCameraTo(MesCameraEvent.TakePhoto)
2626
```
2727

28-
To tell the connected device to start recording a video
28+
To tell the connected device to start recording a video:
2929

3030
```blocks
31-
devices.tellCameraTo(MesCameraEvent.StopVideoCapture)
31+
devices.tellCameraTo(MesCameraEvent.StartVideoCapture)
3232
```
3333

34-
To tell the connected device to stop recording a video
34+
To tell the connected device to stop recording a video:
3535

3636
```blocks
37-
devices.tellCameraTo(MesCameraEvent.ToggleFrontRear)
37+
devices.tellCameraTo(MesCameraEvent.StopVideoCapture)
3838
```
3939

40-
To tell the connected device to toggle front-rear
40+
To tell the connected device to toggle front-rear:
4141

4242
```blocks
43-
devices.tellCameraTo(MesCameraEvent.LaunchPhotoMode)
43+
devices.tellCameraTo(MesCameraEvent.ToggleFrontRear)
4444
```
4545

46-
To tell the connected device to launch photo mode
46+
To tell the connected device to launch photo mode:
4747

4848
```blocks
4949
devices.tellCameraTo(MesCameraEvent.LaunchPhotoMode)
5050
```
5151

52-
To tell the connected device to launch video mode
52+
To tell the connected device to launch video mode:
5353

5454
```blocks
5555
devices.tellCameraTo(MesCameraEvent.LaunchVideoMode)
5656
```
5757

58-
To tell the connected device to stop photo mode
58+
To tell the connected device to stop photo mode:
5959

6060
```blocks
6161
devices.tellCameraTo(MesCameraEvent.StopPhotoMode)
6262
```
6363

64-
To tell the connected device to stop video mode
64+
To tell the connected device to stop video mode:
6565

6666
```blocks
6767
devices.tellCameraTo(MesCameraEvent.StopVideoMode)

docs/reference/input/rotation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ check how the @boardname@ is moving.
1919

2020
## Returns
2121

22-
* a [number](/types/number) that means how much the microbit is tilted in the direction you say, from `-180` to `180` degrees
22+
* a [number](/types/number) that means how much the microbit is tilted in the direction you say; for `Rotation.Pitch` from `-90` to `90` degrees and for `Rotation.Roll` from `-180` to `180` degrees.
2323

2424
## Example: @boardname@ leveler
2525

libs/core/_locales/core-jsdoc-strings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
192192
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
193193
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
194-
"basic.showArrow": "Shows an arrow on screent",
194+
"basic.showArrow": "Draws an arrow on the LED screen",
195195
"basic.showArrow|param|direction": "the direction of the arrow",
196196
"basic.showArrow|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.",
197197
"basic.showIcon": "Draws the selected icon on the LED screen",
@@ -513,4 +513,4 @@
513513
"serial.writeValue": "Write a name:value pair as a line to the serial port.",
514514
"serial.writeValue|param|name": "name of the value stream, eg: x",
515515
"serial.writeValue|param|value": "to write"
516-
}
516+
}

libs/core/_locales/core-strings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@
326326
"pins.analogWritePin|block": "analog write|pin %name|to %value",
327327
"pins.digitalReadPin|block": "digital read|pin %name",
328328
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
329-
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof|repeated %repeat",
330-
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof|repeated %repeat",
329+
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format|repeated %repeat",
330+
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format|repeated %repeat",
331331
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
332332
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
333333
"pins.pulseDuration|block": "pulse duration (µs)",

libs/core/icons.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ namespace basic {
189189
}
190190

191191
/**
192-
* Shows an arrow on screent
192+
* Draws an arrow on the LED screen
193193
* @param direction the direction of the arrow
194194
* @param interval the amount of time (milliseconds) to show the icon. Default is 600.
195195
*/

libs/core/pins.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ namespace pins {
381381
* Write bytes to a 7-bit I2C `address`.
382382
*/
383383
//%
384-
void i2cWriteBuffer(int address, Buffer buf, bool repeat = false)
384+
int void i2cWriteBuffer(int address, Buffer buf, bool repeat = false)
385385
{
386-
uBit.i2c.write(address << 1, (char*)buf->data, buf->length, repeat);
386+
return uBit.i2c.write(address << 1, (char*)buf->data, buf->length, repeat);
387387
}
388388

389389
SPI* spi = NULL;

0 commit comments

Comments
 (0)