pxt-microbit 4.0.12 → 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 (37) hide show
  1. package/built/hexcache/{b2e08efad14a6680dc3a2942b93acef42d2045d9f2907e7fe5926264d0c04310.hex → 6526a3337377701ca7bf1d9940f76fdccac145405380ee3ecc2c96f6049e34ce.hex} +10240 -10251
  2. package/built/hexcache/{8cf431acbfd0538188a30333695c29dc120ffe3e58cc5c076bdf928db97027da.hex → 8fc8a1499d69a5d8cc851cf49d16112b3021ab801238204dacf84073acf90e7c.hex} +10835 -10846
  3. package/built/target-strings.json +2 -1
  4. package/built/target.js +38 -30
  5. package/built/target.json +38 -30
  6. package/built/targetlight.json +5 -5
  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 +1 -1
  36. package/pxtarget.json +1 -1
  37. package/targetconfig.json +23 -6
@@ -157,7 +157,7 @@
157
157
  "codalTarget": {
158
158
  "name": "codal-microbit-v2",
159
159
  "url": "https://github.com/lancaster-university/codal-microbit-v2",
160
- "branch": "v0.2.33",
160
+ "branch": "v0.2.32",
161
161
  "type": "git"
162
162
  },
163
163
  "codalBinary": "MICROBIT",
@@ -355,10 +355,10 @@
355
355
  },
356
356
  "uploadDocs": true,
357
357
  "versions": {
358
- "branch": "v4.0.12",
359
- "tag": "v4.0.12",
360
- "commits": "https://github.com/microsoft/pxt-microbit/commits/47d96faa65c0cceb96e8e37e6e83fcce4ef402c8",
361
- "target": "4.0.12",
358
+ "branch": "v4.0.13",
359
+ "tag": "v4.0.13",
360
+ "commits": "https://github.com/microsoft/pxt-microbit/commits/4513d0b7072da874595e86f2f253829757a34997",
361
+ "target": "4.0.13",
362
362
  "pxt": "7.0.8"
363
363
  },
364
364
  "blocksprj": {
@@ -0,0 +1,131 @@
1
+ # Comments
2
+
3
+ For simple programs, is easy to understand the steps and the flow the program might take when it runs. If you have just a few steps in your program that run one after the other in a sequence, it's fairly easy to understand what's happening at each place in your program.
4
+
5
+ The following program does 4 simple things:
6
+
7
+ 1. Show a "Hello" message
8
+ 2. Display a smiley face as part of a greeting
9
+ 2. Pause for a second so you can see the smiley
10
+ 3. Clear the screen
11
+
12
+ ```blocks
13
+ basic.showString("Hello!")
14
+ basic.showIcon(IconNames.Happy)
15
+ basic.pause(1000)
16
+ basic.clearScreen()
17
+ ```
18
+
19
+ It's quite obvious what this program is doing. Each block does one thing, the next block runs after the previous one in a sequence, then the program ends. Let's say you want the user to show that they saw the greeting. You could add button press event that shows a check mark icon.
20
+
21
+ ```blocks
22
+ basic.showString("Hello!")
23
+ basic.showIcon(IconNames.Happy)
24
+ basic.pause(1000)
25
+ basic.clearScreen()
26
+ input.onButtonPressed(Button.A, function () {
27
+ basic.showIcon(IconNames.Yes)
28
+ })
29
+ ```
30
+
31
+ You know, of course, that the button press event means that the user has acknowleged your greeting. If you shared your program with someone else though, they might not understand why you wanted to add the button press to the program.
32
+
33
+ ## Block comments
34
+
35
+ To let others know what certain parts of your program are supposed to do, you can add **comments**. Comments are a text description that says what that part of your program is doing. To put a comment on a block, open the block menu and select **Add comment**.
36
+
37
+ ![Block menu](/static/blocks/block-menu.jpg)
38
+
39
+ A place for your comment will appear and you can type in your description of what that block is for and what it's supposed to do.
40
+
41
+ ![Insert the comment](/static/blocks/insert-comment.jpg)
42
+
43
+ Once a comment is added to a block, a comment icon will show in the upper-left corner of the block. Here's our program with the comment on the ``||input:on button A press||``.
44
+
45
+ ```blocks
46
+ // Signal that the greeting was seen
47
+ input.onButtonPressed(Button.A, function () {
48
+ basic.showIcon(IconNames.Yes)
49
+ })
50
+ basic.showString("Hello!")
51
+ basic.showIcon(IconNames.Happy)
52
+ basic.pause(1000)
53
+ basic.clearScreen()
54
+ ```
55
+
56
+ In the Blocks editor, the comment is displayed when you click on the comment icon. If you view the JavaScript or Python code, you'll see a comment line directly above the button press code.
57
+
58
+ ```typescript
59
+ // Signal that the greeting was seen
60
+ input.onButtonPressed(Button.A, function () {
61
+ basic.showIcon(IconNames.Yes)
62
+ })
63
+ basic.showString("Hello!")
64
+ basic.showIcon(IconNames.Happy)
65
+ basic.pause(1000)
66
+ basic.clearScreen()
67
+ ```
68
+
69
+ When a program contains conditionals, loops, or functions, adding comments becomes important to help understand what's happening at those places in your program. The program can take a different path based on a condition, result from a function, or some other action.
70
+
71
+ ### ~ hint
72
+
73
+ #### Workspace comments
74
+
75
+ You can add comments an notes about your project with **Workspace Comments**. Just right-click on the Workspace background and choose **Add Comment** to insert your comments for the project.
76
+
77
+ ```block
78
+ /**
79
+ * This is a workspace comment.
80
+ *
81
+ * Use this space to make comments
82
+ *
83
+ * and notes about your project.
84
+ */
85
+ // Display a message
86
+ function showMessage () {
87
+ basic.showString("Workspaces have comments!")
88
+ }
89
+ ```
90
+
91
+ ### ~
92
+
93
+ The following example has a conditional inside a loop to choose one of three different mood values. For each mood, a function will display an icon for it. Each block has a comment that describes what it will do. Take a look at the JavaScript or Python code to see the comments on the code text also.
94
+
95
+ ```blocks
96
+ /**
97
+ * The mood icon project.
98
+ *
99
+ * TODO: add more moods
100
+ *
101
+ * 1. Sad
102
+ *
103
+ * 2. Confused
104
+ */
105
+ // Display an emotion of love
106
+ function heart () {
107
+ basic.showIcon(IconNames.Heart)
108
+ }
109
+ // Show a surprised expression
110
+ function surprised () {
111
+ basic.showIcon(IconNames.Surprised)
112
+ }
113
+ // Display a smiley mood
114
+ function smiley () {
115
+ basic.showIcon(IconNames.Happy)
116
+ }
117
+ // My program that shows three mood icons
118
+ // Run the loop to show 3 icons
119
+ for (let index = 0; index <= 2; index++) {
120
+ // Select an icon based on the index
121
+ if (index == 0) {
122
+ smiley()
123
+ } else if (index == 1) {
124
+ heart()
125
+ } else {
126
+ surprised()
127
+ }
128
+ // Pause for a second between moods
129
+ basic.pause(1000)
130
+ }
131
+ ```
@@ -1,3 +1,15 @@
1
1
  # @extends
2
2
 
3
3
  ## #specific
4
+
5
+ ```cards
6
+ loops.everyInterval(500, function () {})
7
+ ```
8
+
9
+ ## #seealso
10
+
11
+ [for](/blocks/loops/for),
12
+ [while](/blocks/loops/while),
13
+ [repeat](/blocks/loops/repeat),
14
+ [for of](/blocks/loops/for-of),
15
+ [every](/reference/loops/every)
@@ -62,6 +62,14 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
62
62
 
63
63
  ```codecard
64
64
  [{
65
+ "name": "Kitronik 128x64 Display",
66
+ "url": "/pkg/KitronikLtd/pxt-kitronik-128x64Display",
67
+ "cardType": "package"
68
+ }, {
69
+ "name": "Monk Makes 7-Segment",
70
+ "url": "/pkg/monkmakes/monkmakes-7-segment",
71
+ "cardType": "package"
72
+ }, {
65
73
  "name": "Pimoroni inky:bit",
66
74
  "url": "/pkg/pimoroni/pxt-inkybit",
67
75
  "cardType": "package"
@@ -156,6 +164,10 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
156
164
 
157
165
  ```codecard
158
166
  [{
167
+ "name": "TCS3200 Color sensor",
168
+ "url":"/pkg/joy-it/pxt-SEN-Color",
169
+ "cardType": "package"
170
+ }, {
159
171
  "name": "MPU6050 Gyroscope",
160
172
  "url":"/pkg/joy-it/SEN-MPU6050",
161
173
  "cardType": "package"
@@ -316,9 +328,21 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
316
328
 
317
329
  ```codecard
318
330
  [{
331
+ "name": "KittenBot Powerbrick",
332
+ "url": "/pkg/KittenBot/pxt-powerbrick",
333
+ "cardType": "package"
334
+ }, {
335
+ "name": "Kitronik LAB:bit",
336
+ "url": "/pkg/KitronikLtd/pxt-kitronik-lab-bit",
337
+ "cardType": "package"
338
+ }, {
319
339
  "name": "PT-BOT PTKidsBIT",
320
340
  "url": "/pkg/iBuilds/pxt-PTKidsBIT",
321
341
  "cardType": "package"
342
+ }, {
343
+ "name": "Stemhub City",
344
+ "url": "/pkg/stemhub/pxt-StemhubCity",
345
+ "cardType": "package"
322
346
  }, {
323
347
  "name": "Pi Supply tinker:kit",
324
348
  "url": "/pkg/PiSupply/pxt-tinker-kit",
@@ -388,6 +412,10 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
388
412
 
389
413
  ```codecard
390
414
  [{
415
+ "name": "Elecfreaks Smart AI Lens ",
416
+ "url":"/pkg/elecfreaks/pxt-PlanetX-AI",
417
+ "cardType": "package"
418
+ }, {
391
419
  "name": "MU Vision camera",
392
420
  "url":"/pkg/mu-opensource/pxt-muvision",
393
421
  "cardType": "package"
@@ -401,6 +429,18 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
401
429
 
402
430
  ```codecard
403
431
  [{
432
+ "name": "MakeKit Hoverbit",
433
+ "url":"/pkg/gomakekit/Hoverbit_V2",
434
+ "cardType": "package"
435
+ }, {
436
+ "name": "Stemhubbit car",
437
+ "url":"/pkg/stemhub/pxt-Stemhubbit",
438
+ "cardType": "package"
439
+ }, {
440
+ "name": "MATRIX Micro",
441
+ "url":"/pkg/pxt-MatrixMicro",
442
+ "cardType": "package"
443
+ }, {
404
444
  "name": "PTKidsBIT",
405
445
  "url":"/pkg/iBuilds/pxt-PTKidsBIT-Robot",
406
446
  "cardType": "package"
@@ -7,6 +7,12 @@
7
7
  * [Dice](/projects/dice)
8
8
  * [Love Meter](/projects/love-meter)
9
9
  * [Micro Chat](/projects/micro-chat)
10
+ * [Tutorials for the new micro:bit (V2)](/v2tutorials)
11
+ * [Pet Hamster](/projects/v2-pet-hamster)
12
+ * [Countdown](/projects/v2-countdown)
13
+ * [Morse Chat](/projects/v2-morse-chat)
14
+ * [Clap Lights](/projects/v2-clap-lights)
15
+ * [Blow Away](/projects/v2-blow-away)
10
16
  * [Live Coding](/live-coding)
11
17
  * [Flashing Heart](https://youtu.be/NvEOKZ8wh9s)
12
18
  * [Name Tag](https://youtu.be/xpRI5jjQ31E)
@@ -106,7 +112,7 @@
106
112
  * [Square](/projects/turtle-square)
107
113
  * [Spiral](/projects/turtle-spiral)
108
114
  * [Scanner](/projects/turtle-scanner)
109
- * [Blocks To JavaScript](/courses/blocks-to-javascript)
115
+ * [Blocks to JavaScript](/courses/blocks-to-javascript)
110
116
  * [Hello JavaScript](/courses/blocks-to-javascript/hello-javascript)
111
117
  * [Starter Blocks](/courses/blocks-to-javascript/starter-blocks)
112
118
  * [Writing Code](/courses/blocks-to-javascript/writing-code)
@@ -6,6 +6,14 @@
6
6
 
7
7
  Use the **radio** to send and receive messages with other @boardname@.
8
8
 
9
+ ## Set a radio group
10
+
11
+ The first thing you want to do is to put in a ``||radio:set group||``. This will make certain that you and another @boardname@ will receive just the messages assigned to that group and not the messages sent from some other @boardname@ that's not part of your conversation. This like tuning to a particular channel to talk on.
12
+
13
+ ```blocks
14
+ radio.setGroup(1)
15
+ ```
16
+
9
17
  ## Sending a message
10
18
 
11
19
  Use ``||input:on button pressed||`` to send a text message over radio with ``||radio:send string||``.
@@ -53,14 +61,6 @@ radio.onReceivedString(function (receivedString) {
53
61
 
54
62
  If you have two @boardname@s, download the program to each one. Press button **A** on one and see if the other gets a message.
55
63
 
56
- ## Groups
57
-
58
- Use the ``||radio:set group||`` block to assign a **group** number to your program. You will only receive messages from @boardname@s within the same group. Use this to avoid receiving messages from every @boardname@ that is transmitting.
59
-
60
- ```blocks
61
- radio.setGroup(123)
62
- ```
63
-
64
64
  ```package
65
65
  radio
66
66
  ```
@@ -15,6 +15,7 @@ between @boardname@s using the radio antenna, just like a phone can send text me
15
15
  Let's add blocks that send a number when button ``A`` is pressed. We assume that `0` is the "mood code" to send for **smiley**.
16
16
 
17
17
  ```blocks
18
+ radio.setGroup(1)
18
19
  input.onButtonPressed(Button.A, () => {
19
20
  radio.sendNumber(0)
20
21
  basic.showIcon(IconNames.Happy)
@@ -65,9 +66,10 @@ That's it. Download your code to multiple @boardname@s and try it out!
65
66
 
66
67
  Try adding a new code and use the ``||input:on shake||`` event to send it.
67
68
 
68
- ## Full sources
69
+ ## Complete program
69
70
 
70
71
  ```blocks
72
+ radio.setGroup(1)
71
73
  input.onButtonPressed(Button.A, () => {
72
74
  radio.sendNumber(0)
73
75
  basic.showIcon(IconNames.Happy)
@@ -22,9 +22,9 @@ input.onGesture(Gesture.Shake, function () {
22
22
 
23
23
  We need to store the result of the dice cast in a variable. A **variable** is like a place in the memory of the @boardname@ where you save information, like numbers.
24
24
 
25
- * Go to the **Variables** toolbox and click ``||Make a Variable||`` to create a new variable. We will call it **dice**.
26
- * Add a ``||set dice to||`` block and drag the ``||pick random||`` into it.
27
- * Drag a ``||dice||`` from the **Variables** toolbox into the ``||basic:show number||`` block.
25
+ * Go to the **Variables** toolbox and click ``Make a Variable`` to create a new variable. We will call it **dice**.
26
+ * Add a ``||variables:set dice to||`` block and drag the ``||math:pick random||`` into it.
27
+ * Drag a ``||variables:dice||`` variable from the **Variables** toolbox into the ``||basic:show number||`` block.
28
28
 
29
29
  ```blocks
30
30
  let dice = 0
@@ -36,9 +36,10 @@ input.onGesture(Gesture.Shake, function () {
36
36
 
37
37
  ## Send the dice
38
38
 
39
- Put in a ``||radio:send number||`` and a ``||dice||`` to send the value stored in the ``dice`` variable via radio.
39
+ Put in a ``||radio:send number||`` and a ``||variables:dice||`` to send the value stored in the ``||variables:dice||`` variable via radio. Make sure to add a ``||radio:set group||`` to ``||basic:on start||`` with the group number set to the group you want to use.
40
40
 
41
41
  ```blocks
42
+ radio.setGroup(1)
42
43
  let dice = 0
43
44
  input.onGesture(Gesture.Shake, function () {
44
45
  dice = randint(1, 6)
@@ -49,7 +50,7 @@ input.onGesture(Gesture.Shake, function () {
49
50
 
50
51
  ## Receive the dice
51
52
 
52
- Go get an ``||radio:on received number||`` event block. This event runs when a radio message from another @boardname@ arrives. The ``receivedNumber`` value is the value of the dice in this game.
53
+ Go get an ``||radio:on received number||`` event block. This event runs when a radio message from another @boardname@ arrives. The ``||variables:receivedNumber||`` value is the value of the dice in this game.
53
54
 
54
55
  ```blocks
55
56
  radio.onReceivedNumber(function (receivedNumber) {
@@ -58,7 +59,7 @@ radio.onReceivedNumber(function (receivedNumber) {
58
59
 
59
60
  ## Check your cast
60
61
 
61
- Add a ``||logic:if||`` block to test if ``receivedNumber`` is greater or equal to ``dice``.
62
+ Add a ``||logic:if||`` block to test if ``||variables:receivedNumber||`` is greater or equal to ``||variables:dice||``.
62
63
  If is, you lost so display a sad face on the screen.
63
64
 
64
65
  ```blocks
@@ -78,6 +79,7 @@ If you have more than one @boardname@, download your code onto each one and try
78
79
 
79
80
  ```blocks
80
81
  let dice = 0
82
+ radio.setGroup(1)
81
83
  input.onGesture(Gesture.Shake, function () {
82
84
  dice = randint(1, 6)
83
85
  basic.showNumber(dice)
@@ -6,7 +6,7 @@ The ``||led:plot bar graph||`` uses the screen to display the _magnitude_ (how b
6
6
 
7
7
  ## Acceleration
8
8
 
9
- In a ``||loops:forever||`` loop, ``||led:plot||`` ``||input:acceleration||`` in the ``x`` dimension on the LEDs.
9
+ In a ``||basic:forever||`` loop, ``||led:plot||`` ``||input:acceleration||`` in the ``x`` dimension on the LEDs.
10
10
 
11
11
  ```blocks
12
12
  basic.forever(function() {
@@ -50,4 +50,4 @@ basic.forever(function() {
50
50
 
51
51
  ## Download and try
52
52
 
53
- Download the code to your @boardname@ and test the sensors.
53
+ Download the code to your @boardname@ and test the sensors.