pxt-microbit 4.1.43 → 4.1.46
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/README.md +1 -1
- package/built/common-sim.js +63 -63
- package/built/editor.js +24 -12
- package/built/sim.js +4 -0
- package/built/target.js +43 -32
- package/built/target.json +43 -32
- package/built/targetlight.json +5 -5
- package/built/web/blockly.css +1 -1
- package/built/web/rtlblockly.css +1 -1
- package/built/web/rtlsemantic.css +1 -1
- package/built/web/semantic.css +1 -1
- package/docs/extensions.md +4 -0
- package/docs/projects/v2-play-sound-long.md +144 -0
- package/docs/projects/v2-play-sound.md +167 -0
- package/package.json +3 -3
- package/targetconfig.json +7 -3
package/docs/extensions.md
CHANGED
|
@@ -481,6 +481,10 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
|
|
|
481
481
|
|
|
482
482
|
```codecard
|
|
483
483
|
[{
|
|
484
|
+
"name": "Elecfreaks XGO",
|
|
485
|
+
"url":"/pkg/elecfreaks/pxt-xgo",
|
|
486
|
+
"cardType": "package"
|
|
487
|
+
}, {
|
|
484
488
|
"name": "Robotixlab Theta",
|
|
485
489
|
"url":"/pkg/4tronix/Theta",
|
|
486
490
|
"cardType": "package"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Dance to the Beat
|
|
2
|
+
|
|
3
|
+
## 1. Introduction @unplugged
|
|
4
|
+
|
|
5
|
+
The new micro:bits have speakers, which leaves you free to move around in ways you weren't able to before!
|
|
6
|
+
|
|
7
|
+
Let's use movement to create a beat box of your own.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## 2. Understanding Input
|
|
13
|
+
|
|
14
|
+
Let's find out what numbers the micro:bit produces when you move it around.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
⇼ Open the ``||serial:^ Advanced||`` category to show the ``||serial:Serial||`` label.
|
|
19
|
+
|
|
20
|
+
⇼ From ``||serial:Serial||``, drag the ``||serial:serial write value ["x"] = [0]||``
|
|
21
|
+
block into the ``||basic:forever||`` loop container.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
```blocks
|
|
26
|
+
basic.forever(function(){
|
|
27
|
+
serial.writeValue("x", 0)
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## 3. See the Console
|
|
34
|
+
|
|
35
|
+
When your code runs again, you'll see a button below the micro:bit that says
|
|
36
|
+
"Show console Simulator".
|
|
37
|
+
|
|
38
|
+
Click that button to see what happens.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
The graph for the simulator should stay flat at 0
|
|
43
|
+
and the text in the console below should say "x:0".
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## 4. Acceleration Values
|
|
48
|
+
|
|
49
|
+
For the graph to change with the speed of your movement, we need to replace the "0"
|
|
50
|
+
with the micro:bit **acceleration** value.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
⇼ Open the ``||input:Input||`` category and drag ``||input:acceleration (mg) [x]||``
|
|
55
|
+
over to replace "0" in the ``||serial:serial write value ["x"] = [0]||``
|
|
56
|
+
block.
|
|
57
|
+
|
|
58
|
+
⇼ Change "x" to "a" (for "acceleration".)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
```blocks
|
|
63
|
+
basic.forever(function(){
|
|
64
|
+
serial.writeValue("a", input.acceleration(Dimension.X))
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## 5. Look Again
|
|
71
|
+
|
|
72
|
+
Click the "Show console Simulator" button again.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
Now you should see your graph and text change between **-1023** and **1023** as you click
|
|
77
|
+
around on the micro:bit simulator to pretend like you're swinging it around.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## 6. Compass Values
|
|
82
|
+
|
|
83
|
+
For the graph to change with the speed of your movement, we need to replace the "0" with
|
|
84
|
+
the micro:bit **acceleration** value.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
⇼ Open the ``||input:Input||`` category and drag ``||input:acceleration (mg) [x]||``
|
|
89
|
+
over to replace "0" in the ``||serial:serial write value ["x"] = [0]||``
|
|
90
|
+
block.
|
|
91
|
+
|
|
92
|
+
⇼ Change "x" to "a" (for "acceleration".)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
```blocks
|
|
97
|
+
basic.forever(function(){
|
|
98
|
+
serial.writeValue("a", input.acceleration(Dimension.X))
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Finale
|
|
103
|
+
|
|
104
|
+
👏 **YOU DID IT!** 👏
|
|
105
|
+
|
|
106
|
+
Don't forget to test your code in the simulator!
|
|
107
|
+
|
|
108
|
+
If you have a new @boardname@ (the one with the **shiny gold** logo at the top), download this code and try it out!
|
|
109
|
+
|
|
110
|
+
```blocks
|
|
111
|
+
basic.forever(function () {
|
|
112
|
+
serial.writeValue("Accel", input.acceleration(Dimension.X))
|
|
113
|
+
serial.writeValue("Compass", input.compassHeading())
|
|
114
|
+
music.playSoundEffect(music.createSoundEffect(
|
|
115
|
+
WaveShape.Sine,
|
|
116
|
+
input.acceleration(Dimension.X),
|
|
117
|
+
input.compassHeading(),
|
|
118
|
+
255,
|
|
119
|
+
0,
|
|
120
|
+
500,
|
|
121
|
+
SoundExpressionEffect.None,
|
|
122
|
+
InterpolationCurve.Linear
|
|
123
|
+
), SoundExpressionPlayMode.UntilDone)
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```ghost
|
|
128
|
+
|
|
129
|
+
basic.forever(function () {
|
|
130
|
+
serial.writeValue("Accel", input.acceleration(Dimension.X))
|
|
131
|
+
serial.writeValue("Compass", input.compassHeading())
|
|
132
|
+
music.playSoundEffect(music.createSoundEffect(
|
|
133
|
+
WaveShape.Sine,
|
|
134
|
+
input.acceleration(Dimension.X),
|
|
135
|
+
input.compassHeading(),
|
|
136
|
+
255,
|
|
137
|
+
0,
|
|
138
|
+
500,
|
|
139
|
+
SoundExpressionEffect.None,
|
|
140
|
+
InterpolationCurve.Linear
|
|
141
|
+
), SoundExpressionPlayMode.UntilDone)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
```
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Dance to the Beat
|
|
2
|
+
|
|
3
|
+
## 1. Introduction @unplugged
|
|
4
|
+
|
|
5
|
+
The new micro:bit has speakers so you can hear sounds without being tied down!
|
|
6
|
+
|
|
7
|
+
Let's use movement to create an electronic beat of our own.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## 2. Add Play Sound Block
|
|
13
|
+
|
|
14
|
+
To start your electronic beat, you'll want to repeat a sound forever.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
⇼ Open the ``||music:Music||`` category and drag the ``||music:play sound [♫ ∿∿∿∿ +] [until done]||``
|
|
19
|
+
block into the empty ``||basic:forever||`` loop container.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
```blocks
|
|
24
|
+
basic.forever(function(){
|
|
25
|
+
music.playSoundEffect(music.createSoundEffect(WaveShape.Sine, 5000, 0, 255, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear), SoundExpressionPlayMode.UntilDone)
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## 3. Listen Close
|
|
32
|
+
|
|
33
|
+
When your code runs again, you should hear a short laser/alarm
|
|
34
|
+
sound that repeats over and over forever.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
💡 _You can press the stop button (_⏹️_) beneath the simulator to prevent the noise from bothering you while you're coding._
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## 4. Make a Change
|
|
45
|
+
|
|
46
|
+
For the sound to change with your speed of movement, we need to put the
|
|
47
|
+
micro:bit **acceleration** value in the sound block.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
⇼ On the ``||music:play sound [♫ ∿∿∿ +] [until done]||`` block, click the plus icon (**+**)
|
|
52
|
+
to show the start frequency value of 5000.
|
|
53
|
+
|
|
54
|
+
⇼ From the ``||input:Input||`` category, drag the ``||input:acceleration (mg) [x]||``
|
|
55
|
+
value block to replace **5000**.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
```blocks
|
|
59
|
+
basic.forever(function(){
|
|
60
|
+
music.playSoundEffect(music.createSoundEffect(WaveShape.Sine, input.acceleration(Dimension.X), 0, 255, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear), SoundExpressionPlayMode.UntilDone)
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## 5. Listen Again
|
|
67
|
+
|
|
68
|
+
Run your code again.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
This time, hover around above the micro:bit to simulate swinging it from side to side.
|
|
73
|
+
You should hear the sound change as the micro:bit moves.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## 6. Rotation Values
|
|
78
|
+
|
|
79
|
+
You can make the beat even more fun by changing the end frequency as the micro:bit rotates.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
⇼ From the ``||input:...more||`` category, drag the ``||input:rotation (°) [pitch]||``
|
|
84
|
+
value block to replace the frequency **0**.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
```blocks
|
|
88
|
+
basic.forever(function(){
|
|
89
|
+
music.playSoundEffect(music.createSoundEffect(WaveShape.Sine, input.acceleration(Dimension.X), input.rotation(Rotation.Pitch), 255, 0, 500, SoundExpressionEffect.None, InterpolationCurve.Linear), SoundExpressionPlayMode.UntilDone)
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## 7. Listen Again
|
|
96
|
+
|
|
97
|
+
Run your code again.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
This time, roll over the micro:bit in all directions to simulate turning it while you
|
|
101
|
+
swing it around.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
You should hear the sound change from high to low and low to high.
|
|
106
|
+
|
|
107
|
+
Try moving the micro:bit in different ways. Can you make a fun beat?
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## 8. Customize Your Beat
|
|
112
|
+
|
|
113
|
+
Try changing the **duration** of the beat to something other than **500**. <br/>
|
|
114
|
+
Then, change the dropdown selection inside both the **acceleration** and **rotation**
|
|
115
|
+
blocks.
|
|
116
|
+
|
|
117
|
+
What else can you click on to edit your sound?
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## Finale
|
|
123
|
+
|
|
124
|
+
👏 **YOU DID IT!** 👏
|
|
125
|
+
|
|
126
|
+
Imagine how exciting this project will be when it's loaded on a micro:bit!
|
|
127
|
+
|
|
128
|
+
If you have a micro:bit v2 (the one with the **shiny gold** logo at the top),
|
|
129
|
+
download this code and hold your micro:bit while you dance.
|
|
130
|
+
|
|
131
|
+
Congratulations, you are your own DJ!
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
```blocks
|
|
136
|
+
basic.forever(function () {
|
|
137
|
+
music.playSoundEffect(music.createSoundEffect(
|
|
138
|
+
WaveShape.Sine,
|
|
139
|
+
input.acceleration(Dimension.X),
|
|
140
|
+
input.rotation(Rotation.Pitch),
|
|
141
|
+
255,
|
|
142
|
+
0,
|
|
143
|
+
500,
|
|
144
|
+
SoundExpressionEffect.None,
|
|
145
|
+
InterpolationCurve.Linear
|
|
146
|
+
), SoundExpressionPlayMode.UntilDone)
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```ghost
|
|
151
|
+
|
|
152
|
+
basic.forever(function () {
|
|
153
|
+
serial.writeValue("Accel", input.acceleration(Dimension.X))
|
|
154
|
+
serial.writeValue("Rotation", input.rotation(Rotation.Pitch),)
|
|
155
|
+
music.playSoundEffect(music.createSoundEffect(
|
|
156
|
+
WaveShape.Sine,
|
|
157
|
+
input.acceleration(Dimension.X),
|
|
158
|
+
input.rotation(Rotation.Pitch),
|
|
159
|
+
255,
|
|
160
|
+
0,
|
|
161
|
+
500,
|
|
162
|
+
SoundExpressionEffect.None,
|
|
163
|
+
InterpolationCurve.Linear
|
|
164
|
+
), SoundExpressionPlayMode.UntilDone)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pxt-microbit",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.46",
|
|
4
4
|
"description": "micro:bit target for Microsoft MakeCode (PXT)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"JavaScript",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typescript": "4.2.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"pxt-common-packages": "9.5.
|
|
48
|
-
"pxt-core": "7.5.
|
|
47
|
+
"pxt-common-packages": "9.5.11",
|
|
48
|
+
"pxt-core": "7.5.44"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/targetconfig.json
CHANGED
|
@@ -249,7 +249,7 @@
|
|
|
249
249
|
"bsiever/microbit-pxt-blehid",
|
|
250
250
|
"DFRobot/pxt-DFRobot_Environment_Science",
|
|
251
251
|
"ekkai/aicococam",
|
|
252
|
-
|
|
252
|
+
"elecfreaks/pxt-xgo",
|
|
253
253
|
"microsoft/pxt-jacdac",
|
|
254
254
|
"microsoft/pxt-jacdac/accelerometer",
|
|
255
255
|
"microsoft/pxt-jacdac/acidity",
|
|
@@ -759,7 +759,11 @@
|
|
|
759
759
|
"smarthon/pxt-smartcity": { "tags": [ "Kits" ] },
|
|
760
760
|
"aorczyk/soroban": { "tags": [ "Utilities" ] },
|
|
761
761
|
"aorczyk/pf-recorder": { "tags": [ "Utilities" ] },
|
|
762
|
-
"4tronix/theta": { "tags": [ "Robotics" ] }
|
|
762
|
+
"4tronix/theta": { "tags": [ "Robotics" ] },
|
|
763
|
+
"bsiever/microbit-pxt-blehid": {},
|
|
764
|
+
"dfrobot/pxt-dfrobot_environment_science": {},
|
|
765
|
+
"ekkai/aicococam": {},
|
|
766
|
+
"elecfreaks/pxt-xgo": {}
|
|
763
767
|
},
|
|
764
768
|
"upgrades": {
|
|
765
769
|
"tinkertanker/pxt-iot-environment-kit": "min:v4.2.1",
|
|
@@ -842,4 +846,4 @@
|
|
|
842
846
|
"electronManifest": {
|
|
843
847
|
"latest": "v4.0.11"
|
|
844
848
|
}
|
|
845
|
-
}
|
|
849
|
+
}
|