pxt-microbit 8.1.9 → 8.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/block-tests.js +1 -1
- package/built/target.js +1 -1
- package/built/target.json +1 -1
- package/built/targetlight.js +1 -1
- package/built/targetlight.json +1 -1
- package/built/web/react-common-authcode.css +1 -1
- package/built/web/react-common-multiplayer.css +1 -1
- package/built/web/react-common-skillmap.css +1 -1
- package/built/web/rtlreact-common-authcode.css +1 -1
- package/built/web/rtlreact-common-multiplayer.css +1 -1
- package/built/web/rtlreact-common-skillmap.css +1 -1
- package/built/web/rtlsemantic.css +6 -6
- package/built/web/semantic.css +6 -6
- package/docs/courses/ucp-science.md +2 -2
- package/docs/extensions/extension-gallery.md +4 -0
- package/docs/projects/plot-acceleration.md +15 -3
- package/docs/projects/snap-the-dot.md +2 -2
- package/docs/projects/spy/snap-the-dot.md +2 -2
- package/docs/projects/turtle-square.md +4 -0
- package/docs/projects/v2-clap-lights.md +2 -2
- package/docs/projects/v2-morse-chat.md +6 -0
- package/docs/reference/input/compass-heading.md +75 -18
- package/docs/reference/radio/set-group.md +21 -13
- package/package.json +2 -2
- package/targetconfig.json +2 -1
|
@@ -33,7 +33,7 @@ The lesson series includes:
|
|
|
33
33
|
* [Rocket Acceleration](/courses/ucp-science/rocket-acceleration)
|
|
34
34
|
* [Egg Drop Experiment](/courses/ucp-science/egg-drop)
|
|
35
35
|
* [Spoon Race](/courses/ucp-science/spoon-race)
|
|
36
|
-
|
|
37
|
-
The [Science Experiments](https://sites.google.com/view/utahcodingproject/
|
|
36
|
+
|
|
37
|
+
The [Science Experiments](https://sites.google.com/view/utahcodingproject/microbits/microbit-science-experiments) lesson series is generously provided by the [Utah Coding Project](https://sites.google.com/view/utahcodingproject/home) and is developed by [Carl Lyman](mailto:utahcoding@outlook.com).
|
|
38
38
|
|
|
39
39
|
[](https://creativecommons.org/licenses/by-nc-sa/4.0/)
|
|
@@ -192,6 +192,10 @@ Many extensions are available to work with interface kits, add-on hardware, or o
|
|
|
192
192
|
|
|
193
193
|
```codecard
|
|
194
194
|
[{
|
|
195
|
+
"name": "KY-040 Rotary Encoder Plus",
|
|
196
|
+
"url":"/pkg/steveturbek/pxt-rotary-encoder-KY-040-plus",
|
|
197
|
+
"cardType": "package"
|
|
198
|
+
}, {
|
|
195
199
|
"name": "MonkMakes Plant Monitor",
|
|
196
200
|
"url":"/pkg/monkmakes/plant-monitor-makecode",
|
|
197
201
|
"cardType": "package"
|
|
@@ -19,7 +19,17 @@ basic.forever(function() {
|
|
|
19
19
|
|
|
20
20
|
## Console
|
|
21
21
|
|
|
22
|
-
Click on the **Show
|
|
22
|
+
Click on the **(+)** in the ``||led:plot bar graph||`` block to expand it. The ``||led:serial write||`` parameter will appear and is set to **ON**. Now, after a moment, the **Show data Simulator** button will show up near the simulator. Click on it to see a chart of the values plotted by the block over a period of time. Hover over the board in the simulator to make a force in the ``x`` dimension.
|
|
23
|
+
|
|
24
|
+
```blocks
|
|
25
|
+
basic.forever(function() {
|
|
26
|
+
led.plotBarGraph(
|
|
27
|
+
input.acceleration(Dimension.X),
|
|
28
|
+
0,
|
|
29
|
+
true
|
|
30
|
+
)
|
|
31
|
+
})
|
|
32
|
+
```
|
|
23
33
|
|
|
24
34
|
## Maximum value
|
|
25
35
|
|
|
@@ -30,7 +40,8 @@ For example, we can tell the block that we don't expect values beyond ``1000`` m
|
|
|
30
40
|
basic.forever(function() {
|
|
31
41
|
led.plotBarGraph(
|
|
32
42
|
input.acceleration(Dimension.X),
|
|
33
|
-
1000
|
|
43
|
+
1000,
|
|
44
|
+
true
|
|
34
45
|
)
|
|
35
46
|
})
|
|
36
47
|
```
|
|
@@ -43,7 +54,8 @@ You can use this block for pretty much any kind of data. Try it out! Plot the ``
|
|
|
43
54
|
basic.forever(function() {
|
|
44
55
|
led.plotBarGraph(
|
|
45
56
|
input.lightLevel(),
|
|
46
|
-
0
|
|
57
|
+
0,
|
|
58
|
+
true
|
|
47
59
|
)
|
|
48
60
|
})
|
|
49
61
|
```
|
|
@@ -64,8 +64,8 @@ input.onButtonPressed(Button.A, function () {
|
|
|
64
64
|
})
|
|
65
65
|
basic.forever(function () {
|
|
66
66
|
sprite.move(1)
|
|
67
|
-
basic.pause(100)
|
|
68
67
|
sprite.ifOnEdgeBounce()
|
|
68
|
+
basic.pause(100)
|
|
69
69
|
})
|
|
70
70
|
```
|
|
71
71
|
|
|
@@ -84,8 +84,8 @@ input.onButtonPressed(Button.A, function () {
|
|
|
84
84
|
})
|
|
85
85
|
basic.forever(function () {
|
|
86
86
|
sprite.move(1)
|
|
87
|
-
basic.pause(100)
|
|
88
87
|
sprite.ifOnEdgeBounce()
|
|
88
|
+
basic.pause(100)
|
|
89
89
|
})
|
|
90
90
|
```
|
|
91
91
|
|
|
@@ -69,8 +69,8 @@ input.onButtonPressed(Button.A, function () {
|
|
|
69
69
|
})
|
|
70
70
|
basic.forever(function () {
|
|
71
71
|
sprite.move(1)
|
|
72
|
-
basic.pause(100)
|
|
73
72
|
sprite.ifOnEdgeBounce()
|
|
73
|
+
basic.pause(100)
|
|
74
74
|
})
|
|
75
75
|
```
|
|
76
76
|
|
|
@@ -90,8 +90,8 @@ input.onButtonPressed(Button.A, function () {
|
|
|
90
90
|
})
|
|
91
91
|
basic.forever(function () {
|
|
92
92
|
sprite.move(1)
|
|
93
|
-
basic.pause(100)
|
|
94
93
|
sprite.ifOnEdgeBounce()
|
|
94
|
+
basic.pause(100)
|
|
95
95
|
})
|
|
96
96
|
```
|
|
97
97
|
|
|
@@ -133,7 +133,7 @@ Your @boardname@ might detect sounds when you don't want it to. Setting a [__*so
|
|
|
133
133
|
|
|
134
134
|
```blocks
|
|
135
135
|
// @highlight
|
|
136
|
-
input.setSoundThreshold(SoundThreshold.Loud,
|
|
136
|
+
input.setSoundThreshold(SoundThreshold.Loud, 128)
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
## {Testing, round 2}
|
|
@@ -158,7 +158,7 @@ input.onSound(DetectedSound.Loud, function () {
|
|
|
158
158
|
basic.clearScreen()
|
|
159
159
|
}
|
|
160
160
|
})
|
|
161
|
-
input.setSoundThreshold(SoundThreshold.Loud,
|
|
161
|
+
input.setSoundThreshold(SoundThreshold.Loud, 128)
|
|
162
162
|
```
|
|
163
163
|
|
|
164
164
|
```validation.global
|
|
@@ -21,10 +21,12 @@ Morse code is an alphabet composed of dots (short signals) and dashes (long sign
|
|
|
21
21
|
|
|
22
22
|
hint~
|
|
23
23
|
|
|
24
|
+
■ From the ``||radio:Radio||`` category, get a ``||radio:radio set group [1]||`` and drop it into your empty ``||basic:on start||`` container. You can leave the group ID at `1` or change it to something different (the radio group ID is like a channel number to talk on).
|
|
24
25
|
■ From the ``||input:Input||`` category in the toolbox, drag an ``||input:on logo [pressed]||`` container into to your workspace.
|
|
25
26
|
■ From the ``||radio:Radio||`` category, get ``||radio:radio send number [0]||`` and snap it into your empty ``||input:on logo [pressed]||`` container.
|
|
26
27
|
|
|
27
28
|
```blocks
|
|
29
|
+
radio.setGroup(1)
|
|
28
30
|
input.onLogoEvent(TouchButtonEvent.Pressed, function () {
|
|
29
31
|
radio.sendNumber(0)
|
|
30
32
|
})
|
|
@@ -37,6 +39,7 @@ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
|
|
|
37
39
|
■ On the greyed-out ``||input(noclick):on logo [pressed]||`` container, click on the **``pressed``** dropdown and set it to ``||input(noclick):long pressed||``.
|
|
38
40
|
|
|
39
41
|
```blocks
|
|
42
|
+
radio.setGroup(1)
|
|
40
43
|
// @highlight
|
|
41
44
|
input.onLogoEvent(TouchButtonEvent.LongPressed, function () {
|
|
42
45
|
})
|
|
@@ -51,6 +54,7 @@ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
|
|
|
51
54
|
■ Set the number to be ``1``.
|
|
52
55
|
|
|
53
56
|
```blocks
|
|
57
|
+
radio.setGroup(1)
|
|
54
58
|
input.onLogoEvent(TouchButtonEvent.LongPressed, function () {
|
|
55
59
|
// @highlight
|
|
56
60
|
radio.sendNumber(1)
|
|
@@ -236,6 +240,7 @@ Test what you've created. Remember to turn your sound on!
|
|
|
236
240
|
💡 If your screen is too small, you might not be able to see it.
|
|
237
241
|
|
|
238
242
|
```blocks
|
|
243
|
+
radio.setGroup(1)
|
|
239
244
|
radio.onReceivedNumber(function (receivedNumber) {
|
|
240
245
|
if (receivedNumber == 0) {
|
|
241
246
|
basic.showLeds(`
|
|
@@ -276,6 +281,7 @@ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
|
|
|
276
281
|
■ If you have multiple @boardname@s with sound (they have **shiny gold** logos at the top), download this code and try it out!
|
|
277
282
|
|
|
278
283
|
```blocks
|
|
284
|
+
radio.setGroup(1)
|
|
279
285
|
radio.onReceivedNumber(function (receivedNumber) {
|
|
280
286
|
if (receivedNumber == 0) {
|
|
281
287
|
basic.showLeds(`
|
|
@@ -1,42 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# compass Heading
|
|
2
2
|
|
|
3
3
|
Find which direction on a compass the @boardname@ is facing.
|
|
4
4
|
|
|
5
5
|
The @boardname@ measures the **compass heading** from `0` to `359`
|
|
6
|
-
degrees with its **magnetometer** chip. Different numbers mean
|
|
7
|
-
|
|
6
|
+
degrees with its **magnetometer** chip. Different numbers mean North,
|
|
7
|
+
East, South, and West.
|
|
8
8
|
|
|
9
9
|
```sig
|
|
10
|
-
input.compassHeading()
|
|
10
|
+
input.compassHeading()
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Returns
|
|
14
14
|
|
|
15
15
|
* a [number](/types/number) from `0` to `359` degrees, which means the compass heading. If the compass isn't ready, it returns `-1003`.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Compass points
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
`degrees` variable.
|
|
19
|
+
In history, a compass was a device that pointed in the direction of the magnetic North Pole. A needle or or a spot on a moving dial was magnetically attracted to the pole. Using a circular card or diagram arranged with direction indications you could align the indicator with the mark that meant "North" and see which direction the heading you wanted was in.
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
</br>
|
|
22
|
+
**Magnetic compass**<br>
|
|
23
|
+
_by Evan Amos, Public Domain_
|
|
24
|
+
|
|
25
|
+
The compass pointer (needle) is always pointing to magnetic North. The compass dial might not have alignment with the needle. Once the needle is aligned with the dial, the compass will show what the direction is for a heading. The basic 4 compass points are **North (W), East (E), South (S),** and **West (W)**. These are also called the _Four Cardinal Directions_.
|
|
26
|
+
|
|
27
|
+
In the compass examples below, the needle is pointing toward magnetic North. Next, the needle becomes aligned with the "N" symbol. If you wanted to walk East, you would take the compass and turn it so the "E" symbol is pointing directly ahead of you. While you walk East, keep the needle aligned with the "N" symbol.
|
|
28
|
+
|
|
29
|
+
| Needle Heading | Compass Aligned |
|
|
30
|
+
|-|-|
|
|
31
|
+
|  | 
|
|
32
|
+
|
|
33
|
+
## Directions and degrees
|
|
34
|
+
|
|
35
|
+
Modern compasses also use degree markings along with direction symbols. The compass dial shows degree markings from `0°` to `360°`.
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
The degree markings map to directions. Below is a list of directions and their degree values.
|
|
40
|
+
|
|
41
|
+
|Direction|Symbol|Degrees|
|
|
42
|
+
|-|-|-|
|
|
43
|
+
|North|N|0°|
|
|
44
|
+
|Northeast|NE|45°|
|
|
45
|
+
|East|E|90°|
|
|
46
|
+
|Southeast|SE|135°|
|
|
47
|
+
|South|S|180°|
|
|
48
|
+
|Southwest|SE|225°|
|
|
49
|
+
|West|W|270°|
|
|
50
|
+
|Northwest|NW|315°|
|
|
51
|
+
|
|
52
|
+
</br>
|
|
53
|
+
|
|
54
|
+
Besides the 4 Cardinal Directions, there are *Intercardinal Directions* like Northeast (shown in the list above). Additionally, there are direction names between the Cardinal and Intercardinal ones. One of these is North-Northeast (NNE) whose degree value is 22.5° and another is West-Southwest (WSW) at 247.5°.
|
|
55
|
+
|
|
56
|
+
### ~tip
|
|
57
|
+
|
|
58
|
+
#### Running compass programs on the @boardname@
|
|
25
59
|
|
|
26
|
-
|
|
60
|
+
When testing and using your compass programs on the board, hold the @boardname@ face up (logo side up) and the top edge toward the direction to measure (bottom edge connector side is toward your body).
|
|
61
|
+
|
|
62
|
+
### ~
|
|
63
|
+
|
|
64
|
+
### ~hint
|
|
27
65
|
|
|
28
66
|
#### Compass simulation
|
|
29
67
|
|
|
30
|
-
When you run a program
|
|
31
|
-
|
|
68
|
+
When you run a program in the simulator that uses ``||input:compassHeading||``, a compass direction needle appears on the screen. Click and rotate the direction needle to change the compass heading.
|
|
69
|
+
|
|
70
|
+
```sim
|
|
71
|
+
basic.forever(function () {
|
|
72
|
+
basic.showNumber(input.compassHeading())
|
|
73
|
+
basic.pause(5000)
|
|
74
|
+
})
|
|
75
|
+
```
|
|
32
76
|
|
|
33
77
|
### ~
|
|
34
78
|
|
|
35
|
-
##
|
|
79
|
+
## Examples
|
|
80
|
+
|
|
81
|
+
### Digital compass
|
|
82
|
+
|
|
83
|
+
Display the current compass heading in degrees `0` - `359`.
|
|
84
|
+
|
|
85
|
+
```blocks
|
|
86
|
+
basic.forever(function () {
|
|
87
|
+
basic.showNumber(input.compassHeading())
|
|
88
|
+
basic.pause(1000)
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Analog compass
|
|
36
93
|
|
|
37
|
-
|
|
38
|
-
that means whether the @boardname@ is facing north (
|
|
39
|
-
east (
|
|
94
|
+
Find the compass heading and then show an arrow
|
|
95
|
+
that means whether the @boardname@ is facing north (🠉), south (🠋),
|
|
96
|
+
east (🠊), or west (🠈).
|
|
40
97
|
|
|
41
98
|
```blocks
|
|
42
99
|
let degrees = 0
|
|
@@ -71,7 +128,7 @@ confuse the @boardname@.
|
|
|
71
128
|
|
|
72
129
|
#### Make a calibration tool
|
|
73
130
|
|
|
74
|
-
Keep the calibration
|
|
131
|
+
Keep the calibration current by running it when the user pressed **A+B**.
|
|
75
132
|
|
|
76
133
|
```block
|
|
77
134
|
input.onButtonPressed(Button.AB, () => {
|
|
@@ -1,43 +1,50 @@
|
|
|
1
1
|
# set Group
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
with radio.
|
|
3
|
+
Set the group ID for sending and receiving messages over radio.
|
|
5
4
|
|
|
6
5
|
```sig
|
|
7
|
-
radio.setGroup(0)
|
|
6
|
+
radio.setGroup(0)
|
|
8
7
|
```
|
|
9
8
|
|
|
10
9
|
A group is like a cable channel (a @boardname@ can only
|
|
11
|
-
send or receive in one group at a time)
|
|
12
|
-
channel number.
|
|
10
|
+
send or receive date in one group at a time) and the group ID is like the channel number.
|
|
13
11
|
|
|
14
|
-
If you
|
|
15
|
-
function, it will figure out its own group ID by itself. If you load
|
|
16
|
-
the very same program onto two different @boardname@s, they will be able
|
|
12
|
+
If you load the same program onto two different @boardname@s, they will be able
|
|
17
13
|
to talk to each other because they will have the same group ID.
|
|
18
14
|
|
|
19
15
|
## Parameters
|
|
20
16
|
|
|
21
|
-
* **id**: a [number](/types/number) from ``0`` to ``255``.
|
|
17
|
+
* **id**: a radio group ID [number](/types/number) from ``0`` to ``255``.
|
|
22
18
|
|
|
23
19
|
### ~ reminder
|
|
24
20
|
|
|
25
21
|
#### Default radio group
|
|
26
22
|
|
|
27
|
-
If you haven't set a radio group for the @boardname@, it will use
|
|
23
|
+
If you haven't set a radio group for the @boardname@, it will use the default group number of **0**.
|
|
28
24
|
|
|
29
25
|
### ~
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
### ~ alert
|
|
28
|
+
|
|
29
|
+
#### Simulator
|
|
32
30
|
|
|
33
31
|
This function only works on the @boardname@, not in browsers.
|
|
34
32
|
|
|
33
|
+
### ~
|
|
34
|
+
|
|
35
35
|
## Example
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Set a radio group to send and receive a [number](/types/number) between @boardname@s.
|
|
38
38
|
|
|
39
39
|
```blocks
|
|
40
|
-
radio.setGroup(
|
|
40
|
+
radio.setGroup(1)
|
|
41
|
+
radio.onReceivedNumber(function (receivedNumber) {
|
|
42
|
+
basic.showNumber(0)
|
|
43
|
+
basic.clearScreen()
|
|
44
|
+
})
|
|
45
|
+
input.onButtonPressed(Button.A, function () {
|
|
46
|
+
radio.sendNumber(0)
|
|
47
|
+
})
|
|
41
48
|
```
|
|
42
49
|
|
|
43
50
|
## See also
|
|
@@ -49,6 +56,7 @@ radio.setGroup(128)
|
|
|
49
56
|
[send value](/reference/radio/send-value),
|
|
50
57
|
[send string](/reference/radio/send-string)
|
|
51
58
|
|
|
59
|
+
|
|
52
60
|
```package
|
|
53
61
|
radio
|
|
54
62
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pxt-microbit",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.11",
|
|
4
4
|
"description": "micro:bit target for Microsoft MakeCode (PXT)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"JavaScript",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"pxt-common-packages": "13.2.3",
|
|
49
|
-
"pxt-core": "12.3.
|
|
49
|
+
"pxt-core": "12.3.6"
|
|
50
50
|
},
|
|
51
51
|
"overrides": {}
|
|
52
52
|
}
|
package/targetconfig.json
CHANGED
|
@@ -438,6 +438,7 @@
|
|
|
438
438
|
"bestmodules-libraries/pxt-bmduino": { "tags": [ "Science" ] },
|
|
439
439
|
"forward-education/pxt-coding-for-good": { "tags": [ "Science" ] },
|
|
440
440
|
"dfrobot/pxt-dfrobot_huskylensv2": { "tags": [ "Science" ] },
|
|
441
|
+
"steveturbek/pxt-rotary-encoder-ky-040-plus": { "tags": [ "Science" ] },
|
|
441
442
|
"microsoft/pxt-simx-sample": {
|
|
442
443
|
"simx": {
|
|
443
444
|
"sha": "7301f5900879b85127482d79bab48f03c25690a8",
|
|
@@ -539,6 +540,6 @@
|
|
|
539
540
|
]
|
|
540
541
|
},
|
|
541
542
|
"electronManifest": {
|
|
542
|
-
"latest": "v8.0.
|
|
543
|
+
"latest": "v8.0.19"
|
|
543
544
|
}
|
|
544
545
|
}
|