pxt-microbit 4.0.9 → 4.0.13

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.
Files changed (36) hide show
  1. package/built/target-strings.json +2 -1
  2. package/built/target.js +38 -30
  3. package/built/target.json +38 -30
  4. package/built/targetlight.json +5 -5
  5. package/built/web/rtlsemantic.css +1 -1
  6. package/built/web/semantic.css +1 -1
  7. package/docs/blocks/comments.md +131 -0
  8. package/docs/blocks/loops.md +12 -0
  9. package/docs/extensions.md +40 -0
  10. package/docs/projects/SUMMARY.md +7 -1
  11. package/docs/projects/micro-chat.md +8 -8
  12. package/docs/projects/mood-radio.md +3 -1
  13. package/docs/projects/multi-dice.md +8 -6
  14. package/docs/projects/plot-acceleration.md +2 -2
  15. package/docs/projects/v2-blow-away.md +317 -0
  16. package/docs/projects/v2-clap-lights.md +195 -0
  17. package/docs/projects/v2-countdown.md +151 -0
  18. package/docs/projects/v2-morse-chat.md +297 -0
  19. package/docs/projects/v2-pet-hamster.md +165 -0
  20. package/docs/projects.md +8 -2
  21. package/docs/reference/basic/forever.md +17 -4
  22. package/docs/reference/basic/show-number.md +1 -1
  23. package/docs/reference/loops/every-interval.md +42 -0
  24. package/docs/reference/radio/on-received-buffer.md +1 -0
  25. package/docs/reference/radio/on-received-number.md +2 -0
  26. package/docs/reference/radio/on-received-string.md +1 -0
  27. package/docs/reference/radio/on-received-value.md +1 -0
  28. package/docs/reference/radio/received-packet.md +1 -0
  29. package/docs/reference/radio/send-buffer.md +1 -0
  30. package/docs/reference/radio/send-string.md +1 -0
  31. package/docs/reference/radio/set-group.md +8 -0
  32. package/docs/reference/radio/write-received-packet-to-serial.md +1 -0
  33. package/docs/reference/radio/write-value-to-serial.md +1 -0
  34. package/docs/v2tutorials.md +39 -0
  35. package/package.json +2 -2
  36. package/targetconfig.json +23 -6
@@ -0,0 +1,165 @@
1
+ # Pet Hamster
2
+
3
+ ## 1. Introduction @unplugged
4
+
5
+ 👋 Meet your new pet hamster, Cyrus 🐹
6
+
7
+ ![Pet hamster banner message](/static/mb/projects/pet-hamster.png)
8
+
9
+ ## 2. Cyrus's asleep face
10
+
11
+ 😴 **Sleeping on the job** 😴
12
+
13
+ Cyrus is a very sleepy hamster. In fact, Cyrus is almost always sleeping.
14
+
15
+ ---
16
+
17
+ ► From the ``||basic:Basic||`` category, find ``||basic:show icon [ ]||`` and snap it into your ``||basic:on start||`` container.
18
+
19
+ ► Set it to show the asleep ``-_-`` face.
20
+ 💡 In the ``show icon`` dropdown menu options, you can hover to see what each design is called!
21
+
22
+ ```blocks
23
+ basic.showIcon(IconNames.Asleep)
24
+ ```
25
+
26
+ ## 3. Giggly Cyrus
27
+
28
+ 🤣 **That tickles** 🤣
29
+
30
+ Pressing Cyrus's logo tickles them!
31
+
32
+ ---
33
+
34
+ ► From ``||input:Input||``, find the ``||input:on logo [pressed]||`` container and drag it into your workspace.
35
+
36
+ ► Go to ``||basic:Basic||`` and grab **another** ``||basic:show icon [ ]||``. Snap it into your **empty** ``||input:on logo [pressed]||`` container.
37
+
38
+ ► Set the icon (Cyrus's face) to happy ``:)``.
39
+
40
+ ```blocks
41
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
42
+ basic.showIcon(IconNames.Happy)
43
+ })
44
+ ```
45
+
46
+ ## 4. Tickle sound
47
+
48
+ 🎶 **The sounds of Cyrus** 🎶
49
+
50
+ ---
51
+
52
+ ► From the ``||music:Music||`` category, get a ``||music:play sound [giggle] until done||`` and add it to the **bottom** of your ``||input:on logo [pressed]||`` container.
53
+
54
+ ```blocks
55
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
56
+ basic.showIcon(IconNames.Happy)
57
+ // @highlight
58
+ soundExpression.giggle.playUntilDone()
59
+ })
60
+ ```
61
+
62
+ ## 5. Dizzy Cyrus
63
+
64
+ 😵 **All shaken up** 💫
65
+
66
+ Whenever Cyrus is shaken, they get sad 🙁
67
+
68
+ ---
69
+
70
+ ► From ``||input:Input||``, find ``||input:on [shake]||`` and drag it into your workspace.
71
+
72
+ ► From the ``||basic:Basic||`` category, grab ``||basic:show icon [ ]||`` and snap it into your **new** ``||input:on [shake]||`` container.
73
+
74
+ ► Set the icon (Cyrus's face) to sad ``:(``.
75
+
76
+ ```blocks
77
+ input.onGesture(Gesture.Shake, function () {
78
+ basic.showIcon(IconNames.Sad)
79
+ })
80
+ ```
81
+
82
+ ## 6. Dizzy sound
83
+
84
+ ► From the ``||music:Music||`` category, find the ``||music:play sound [giggle] until done||`` block and add it to the **bottom** of your ``||input:on [shake]||`` container.
85
+
86
+ ► Click on the **dropdown** and set it so Cyrus plays a ``||music:sad||`` sound until done.
87
+
88
+ ```blocks
89
+ input.onGesture(Gesture.Shake, function () {
90
+ basic.showIcon(IconNames.Sad)
91
+ // @highlight
92
+ soundExpression.sad.playUntilDone()
93
+ })
94
+ ```
95
+
96
+ ## 7. Cyrus's default face pt. 1
97
+
98
+ 💤 **Back to sleep** 💤
99
+
100
+ Let's ensure that Cyrus will always go back to sleep after being shaken or tickled.
101
+
102
+ ---
103
+
104
+ ► Right click the ``||basic:show icon[-_-]||`` block in your workspace (inside the ``||basic:on start||`` container) and choose **Duplicate**.
105
+
106
+ ► Snap your copied block in at the **very bottom** of your ``||input:on [shake]||`` container.
107
+
108
+ ```blocks
109
+ input.onGesture(Gesture.Shake, function () {
110
+ basic.showIcon(IconNames.Sad)
111
+ soundExpression.sad.playUntilDone()
112
+ // @highlight
113
+ basic.showIcon(IconNames.Asleep)
114
+ })
115
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
116
+ basic.showIcon(IconNames.Happy)
117
+ soundExpression.giggle.playUntilDone()
118
+ })
119
+ basic.showIcon(IconNames.Asleep)
120
+ ```
121
+
122
+ ## 8. Cyrus's default face pt. 2
123
+
124
+ ► Duplicate the ``||basic:show icon[-_-]||`` block again and this time snap it in at the **very bottom** of your ``||input:on logo [pressed]||`` container.
125
+
126
+ ```blocks
127
+ input.onGesture(Gesture.Shake, function () {
128
+ basic.showIcon(IconNames.Sad)
129
+ soundExpression.sad.playUntilDone()
130
+ basic.showIcon(IconNames.Asleep)
131
+ })
132
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
133
+ basic.showIcon(IconNames.Happy)
134
+ soundExpression.giggle.playUntilDone()
135
+ // @highlight
136
+ basic.showIcon(IconNames.Asleep)
137
+ })
138
+ basic.showIcon(IconNames.Asleep)
139
+ ```
140
+
141
+ ## 9. Testing in the simulator
142
+
143
+ 🐾 **Test what you've created** 🐾
144
+
145
+ Check out the simulator and make sure your speakers are on 🔊
146
+
147
+ Play with Cyrus to see how they react 🐹
148
+ **Click on the SHAKE button** to shake Cyrus.
149
+ **Touch the gold logo at the top** (it looks like a piggy snout 🐽) to tickle Cyrus.
150
+
151
+ If you have a new @boardname@ (the one with the **shiny gold** logo at the top), download this code and try it out!
152
+
153
+ ```blocks
154
+ input.onGesture(Gesture.Shake, function () {
155
+ basic.showIcon(IconNames.Sad)
156
+ soundExpression.sad.playUntilDone()
157
+ basic.showIcon(IconNames.Asleep)
158
+ })
159
+ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
160
+ basic.showIcon(IconNames.Happy)
161
+ soundExpression.giggle.playUntilDone()
162
+ basic.showIcon(IconNames.Asleep)
163
+ })
164
+ basic.showIcon(IconNames.Asleep)
165
+ ```
package/docs/projects.md CHANGED
@@ -8,6 +8,11 @@
8
8
  "imageUrl": "/static/mb/projects/a1-display.png",
9
9
  "largeImageUrl": "/static/mb/projects/flashing-heart/sim.gif"
10
10
  },
11
+ {
12
+ "name": "Tutorials for the new micro:bit (V2)",
13
+ "url": "/v2tutorials",
14
+ "imageUrl": "/static/mb/projects/pet-hamster.png"
15
+ },
11
16
  {
12
17
  "name": "Live Coding",
13
18
  "url": "/live-coding",
@@ -54,7 +59,7 @@
54
59
  "imageUrl": "/static/mb/projects/turtle-square.png"
55
60
  },
56
61
  {
57
- "name": "Blocks To JavaScript",
62
+ "name": "Blocks to JavaScript",
58
63
  "url": "/courses/blocks-to-javascript",
59
64
  "imageUrl": "/static/courses/blocks-to-javascript/hello-javascript.png"
60
65
  },
@@ -94,6 +99,7 @@
94
99
  ## See Also
95
100
 
96
101
  [Tutorials](/tutorials),
102
+ [Tutorials for the new micro:bit (V2)](/v2tutorials),
97
103
  [Live Coding](/live-coding),
98
104
  [Games](/projects/games),
99
105
  [Radio Games](/projects/radio-games),
@@ -103,7 +109,7 @@
103
109
  [Science](/projects/science),
104
110
  [Tools](/projects/tools),
105
111
  [Turtle](/projects/turtle),
106
- [Blocks To JavaScript](/courses/blocks-to-javascript),
112
+ [Blocks to JavaScript](/courses/blocks-to-javascript),
107
113
  [Courses](/courses),
108
114
  [Behind the MakeCode Hardware](/behind-the-makecode-hardware),
109
115
  [Science Experiments](/science-experiments),
@@ -1,4 +1,4 @@
1
- # Forever
1
+ # forever
2
2
 
3
3
  Keep running part of a program
4
4
  [in the background](/reference/control/in-background).
@@ -8,7 +8,20 @@ basic.forever(() => {
8
8
  })
9
9
  ```
10
10
 
11
- ## Example: compass
11
+ You can have part of a program continuously by placing it in an **forever** loop. The **forever** loop will _yield_ to the other code in your program though, allowing that code to have time to run when needs to.
12
+
13
+ ### ~ reminder
14
+
15
+ #### Event-based loops
16
+
17
+ Both the **forever** loop and the **every** loop are _event-based_ loops where the code inside is run as part of a function. These are different from the [for](/blocks/loops/for) and [while](/blocks/loops/while) loops. Those are loops are part of the programming language and can have [break](/blocks/loops/break) and [continue](/blocks/loops/continue) statements in them.
18
+ You can NOT use **break** or **continue** in either a **forever** loop or an **every** loop.
19
+
20
+ ### ~
21
+
22
+ ## Examples
23
+
24
+ ### Example: compass
12
25
 
13
26
  The following example constantly checks the
14
27
  [compass heading](/reference/input/compass-heading)
@@ -32,7 +45,7 @@ basic.forever(() => {
32
45
  })
33
46
  ```
34
47
 
35
- ## Example: counter
48
+ ### Example: counter
36
49
 
37
50
  The following example keeps showing the [number](/types/number) stored in a global variable.
38
51
  When you press button `A`, the number gets bigger.
@@ -66,5 +79,5 @@ input.onButtonPressed(Button.A, () => {
66
79
 
67
80
  ## See also
68
81
 
69
- [while](/blocks/loops/while), [on button pressed](/reference/input/on-button-pressed), [in background](/reference/control/in-background)
82
+ [while](/blocks/loops/while), [in background](/reference/control/in-background), [every](/reference/loops/every-interval)
70
83
 
@@ -8,7 +8,7 @@ basic.showNumber(2)
8
8
 
9
9
  ## Parameters
10
10
 
11
- * `value` is a [Number](/types/number).
11
+ * `value` is a [Number](/types/number). If the number is not single-digit number, it will scroll on the display.
12
12
  * `interval` is an optional [Number](/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
13
13
 
14
14
  ## Examples:
@@ -0,0 +1,42 @@
1
+ # every Interval
2
+
3
+ Run part of the program in a loop continuously at a time interval.
4
+
5
+ ```sig
6
+ loops.everyInterval(500, function () {})
7
+ ```
8
+
9
+ If you want to run some code continuously, but on a time interval, then use an **every** loop. You set the amount of time that the loop waits before the code inside runs again. This is similar to a [forever](/reference/basic/forever) loop, in that it runs continuously, except that there's a time interval set to wait on before the loop runs the next time. This loop is useful when you want some of a program's code run on a _schedule_.
10
+
11
+ ## Parameters
12
+
13
+ * **interval**: a [number](/types/number) that is the amount of time in milliseconds to wait before running the loop again.
14
+
15
+ ### ~ reminder
16
+
17
+ #### Event-based loops
18
+
19
+ Both the **every** loop and the **forever** loop are _event-based_ loops where the code inside is run as part of a function. These are different from the [for](/blocks/loops/for) and [while](/blocks/loops/while) loops. Those are loops are part of the programming language and can have [break](/blocks/loops/break) and [continue](/blocks/loops/continue) statements in them.
20
+ You can NOT use **break** or **continue** in either an **every** loop or a **forever** loop.
21
+
22
+ ### ~
23
+
24
+ ## Example
25
+
26
+ At every `200` milliseconds of time, check if either the **A** or **B** button is pressed. If so, show on the screen which one is pressed.
27
+
28
+ ```blocks
29
+ loops.everyInterval(200, function () {
30
+ if (input.buttonIsPressed(Button.A)) {
31
+ basic.showString("A")
32
+ } else if (input.buttonIsPressed(Button.B)) {
33
+ basic.showString("B")
34
+ } else {
35
+ basic.clearScreen()
36
+ }
37
+ })
38
+ ```
39
+
40
+ ## See also
41
+
42
+ [forever](/reference/basic/forever)
@@ -19,6 +19,7 @@ Two @boardname@s work like remote levels. They lie flat and detect any change in
19
19
  ```typescript
20
20
  let ax = 0;
21
21
  let ay = 0;
22
+ radio.setGroup(3)
22
23
  basic.forever(() => {
23
24
  ax = input.acceleration(Dimension.X);
24
25
  ay = input.acceleration(Dimension.Y);
@@ -29,6 +29,7 @@ thing from nearby @boardname@s. It shows these numbers as a
29
29
  [bar graph](/reference/led/plot-bar-graph).
30
30
 
31
31
  ```blocks
32
+ radio.setGroup(1)
32
33
  basic.forever(() => {
33
34
  radio.sendNumber(input.acceleration(Dimension.X));
34
35
  })
@@ -43,6 +44,7 @@ This program uses the signal strength from received packets to graph the
43
44
  approximate distance between two @boardname@s.
44
45
 
45
46
  ```blocks
47
+ radio.setGroup(1)
46
48
  basic.forever(() => {
47
49
  radio.sendNumber(0)
48
50
  })
@@ -23,6 +23,7 @@ https://www.youtube.com/watch?v=Re3H2ISfQE8
23
23
  This program continuously sends a cheerful message. It also receives a messages from nearby @boardname@s. It shows these messages on the screen.
24
24
 
25
25
  ```blocks
26
+ radio.setGroup(1)
26
27
  basic.forever(() => {
27
28
  radio.sendString("I'm happy");
28
29
  })
@@ -27,6 +27,7 @@ thing from nearby @boardname@s, show the numbers as a
27
27
  [bar graph](/reference/led/plot-bar-graph).
28
28
 
29
29
  ```blocks
30
+ radio.setGroup(1)
30
31
  basic.forever(() => {
31
32
  radio.sendValue("accel-x", input.acceleration(Dimension.X))
32
33
  })
@@ -28,6 +28,7 @@ This program uses the signal strength from received packets to graph the
28
28
  approximate distance between two @boardname@s.
29
29
 
30
30
  ```blocks
31
+ radio.setGroup(1)
31
32
  basic.forever(() => {
32
33
  radio.sendNumber(0)
33
34
  })
@@ -19,6 +19,7 @@ If you load this program onto two @boardname@s, each board will send the level i
19
19
  ```typescript
20
20
  let ax = 0;
21
21
  let ay = 0;
22
+ radio.setGroup(6)
22
23
  basic.forever(() => {
23
24
  ax = input.acceleration(Dimension.X);
24
25
  ay = input.acceleration(Dimension.Y);
@@ -26,6 +26,7 @@ code word from one of them to the others by pressing button `A`. The
26
26
  other @boardname@s will receive the code word and then show it.
27
27
 
28
28
  ```blocks
29
+ radio.setGroup(1)
29
30
  input.onButtonPressed(Button.A, () => {
30
31
  radio.sendString("Codeword: TRIMARAN")
31
32
  basic.showString("SENT");
@@ -20,6 +20,14 @@ to talk to each other because they will have the same group ID.
20
20
 
21
21
  * **id**: a [number](/types/number) from ``0`` to ``255``.
22
22
 
23
+ ### ~ reminder
24
+
25
+ #### Default radio group
26
+
27
+ If you haven't set a radio group for the @boardname@, it will use one selected randomly. If you are transmiting data to a @boardname@ that has a different hardware version from the sending @boardname@, it will select a random default group that is not the same as the other @boardname@. To be certain that your program will send or receive data using the same radio group, you will need to first choose and set a radio group for your program if you want it to work between different versions of the @boardname@.
28
+
29
+ ### ~
30
+
23
31
  ## Simulator
24
32
 
25
33
  This function only works on the @boardname@, not in browsers.
@@ -40,6 +40,7 @@ the second @boardname@), this program sends temperature data to the
40
40
  serial port.
41
41
 
42
42
  ```blocks
43
+ radio.setGroup(44)
43
44
  input.onButtonPressed(Button.A, function () {
44
45
  radio.sendNumber(input.temperature())
45
46
  radio.sendValue("temp", input.temperature())
@@ -29,6 +29,7 @@ the second @boardname@), this program sends temperature data to
29
29
  serial.
30
30
 
31
31
  ```blocks
32
+ radio.setGroup(1)
32
33
  input.onButtonPressed(Button.A, () => {
33
34
  radio.sendNumber(input.temperature());
34
35
  });
@@ -0,0 +1,39 @@
1
+ # Projects
2
+
3
+ Here are some cool tutorials to get you started with your new @boardname@ (V2)!
4
+
5
+ ## Basic
6
+
7
+ ```codecard
8
+ [{
9
+ "name": "Pet Hamster",
10
+ "url":"/projects/v2-pet-hamster",
11
+ "description": "Interact with your very own micro:bit hamster named Cyrus.",
12
+ "imageUrl": "/static/mb/projects/pet-hamster.png",
13
+ "cardType": "tutorial"
14
+ }, {
15
+ "name": "Countdown",
16
+ "url":"/projects/v2-countdown",
17
+ "description": "Create a musical countdown sequence.",
18
+ "imageUrl": "/static/mb/projects/countdown.png",
19
+ "cardType": "tutorial"
20
+ }, {
21
+ "name": "Morse Chat",
22
+ "url":"/projects/v2-morse-chat",
23
+ "description": "Learn how to send morse code messages to a pig named Sky.",
24
+ "imageUrl": "/static/mb/projects/morse-chat.png",
25
+ "cardType": "tutorial"
26
+ }, {
27
+ "name": "Clap Lights",
28
+ "url":"/projects/v2-clap-lights",
29
+ "description": "Turn your micro:bit's lights on or off when you clap.",
30
+ "imageUrl": "/static/mb/projects/clap-lights.png",
31
+ "cardType": "tutorial"
32
+ }, {
33
+ "name": "Blow Away",
34
+ "url":"/projects/v2-blow-away",
35
+ "description": "Use the sound of your breath to blow a ghost named Haven away.",
36
+ "imageUrl": "/static/mb/projects/blow-away.png",
37
+ "cardType": "tutorial"
38
+ }]
39
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pxt-microbit",
3
- "version": "4.0.9",
3
+ "version": "4.0.13",
4
4
  "description": "micro:bit target for Microsoft MakeCode (PXT)",
5
5
  "keywords": [
6
6
  "JavaScript",
@@ -45,6 +45,6 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "pxt-common-packages": "9.0.1",
48
- "pxt-core": "7.0.6"
48
+ "pxt-core": "7.0.8"
49
49
  }
50
50
  }
package/targetconfig.json CHANGED
@@ -206,18 +206,34 @@
206
206
  "microsoft/pxt-data-streamer",
207
207
  "iBuilds/pxt-PTKidsBIT-Robot",
208
208
  "4tronix/EggBit",
209
- "joy-it/SEN-MPU6050"
209
+ "joy-it/SEN-MPU6050",
210
+ "gomakekit/Hoverbit_V2",
211
+ "Matrix-Robotics/pxt-MatrixMicro",
212
+ "elecfreaks/pxt-PlanetX-AI",
213
+ "joy-it/pxt-SEN-Color",
214
+ "stemhub/pxt-Stemhubbit",
215
+ "KitronikLtd/pxt-kitronik-lab-bit",
216
+ "KitronikLtd/pxt-kitronik-128x64Display",
217
+ "monkmakes/monkmakes-7-segment",
218
+ "stemhub/pxt-StemhubCity",
219
+ "KittenBot/pxt-powerbrick"
210
220
  ],
211
221
  "preferredRepos": [
212
222
  "Microsoft/pxt-neopixel",
213
- "Microsoft/pxt-microturtle",
214
- "Tinkertanker/pxt-tinkercademy-tinker-kit",
223
+ "4tronix/BitBot",
224
+ "dfrobot/pxt-maqueen",
215
225
  "kittenbot/pxt-robotbit",
216
226
  "Microsoft/pxt-sonar",
217
- "4tronix/BitBot",
227
+ "Microsoft/pxt-microturtle",
228
+ "Tinkertanker/pxt-tinkercademy-tinker-kit",
229
+ "seeed-studio/pxt-grove",
230
+ "elecfreaks/pxt-cutebot",
231
+ "dfrobot/pxt-dfrobot-maqueenplus",
232
+ "tinkertanker/pxt-iot-environment-kit",
233
+ "tinkertanker/pxt-ringbitcar",
218
234
  "kitronikltd/pxt-kitronik-servo-lite",
219
235
  "kitronikltd/pxt-kitronik-motor-driver",
220
- "Tinkertanker/pxt-ringbitcar"
236
+ "tinkertanker/pxt-smarthome"
221
237
  ],
222
238
  "upgrades": {
223
239
  "tinkertanker/pxt-iot-environment-kit": "min:v4.2.1",
@@ -259,6 +275,7 @@
259
275
  },
260
276
  "galleries": {
261
277
  "Tutorials": "tutorials",
278
+ "Tutorials for the new micro:bit (V2)": "v2tutorials",
262
279
  "Live Coding": {
263
280
  "url": "live-coding",
264
281
  "shuffle": "daily",
@@ -272,7 +289,7 @@
272
289
  "Science": "projects/science",
273
290
  "Tools": "projects/tools",
274
291
  "Turtle": "projects/turtle",
275
- "Blocks To JavaScript": "courses/blocks-to-javascript",
292
+ "Blocks to JavaScript": "courses/blocks-to-javascript",
276
293
  "Courses": "courses",
277
294
  "Behind the MakeCode Hardware": {
278
295
  "url": "behind-the-makecode-hardware",