pxt-microbit 5.1.32 → 5.1.34

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 (42) hide show
  1. package/built/block-tests.js +1 -1
  2. package/built/common-sim.d.ts +8 -2
  3. package/built/common-sim.js +21 -0
  4. package/built/editor.js +8 -1
  5. package/built/sim.d.ts +9 -3
  6. package/built/sim.js +30 -5
  7. package/built/target.js +1 -1
  8. package/built/target.json +1 -1
  9. package/built/targetlight.json +1 -1
  10. package/built/theme.json +1 -1
  11. package/built/web/react-common-authcode.css +1 -1
  12. package/built/web/react-common-multiplayer.css +1 -1
  13. package/built/web/react-common-skillmap.css +1 -1
  14. package/built/web/rtlreact-common-authcode.css +1 -1
  15. package/built/web/rtlreact-common-multiplayer.css +1 -1
  16. package/built/web/rtlreact-common-skillmap.css +1 -1
  17. package/built/web/rtlsemantic.css +1 -1
  18. package/built/web/semantic.css +1 -1
  19. package/docs/projects/7-seconds.md +5 -1
  20. package/docs/projects/coin-flipper.md +9 -5
  21. package/docs/projects/compass.md +27 -23
  22. package/docs/projects/dice.md +9 -5
  23. package/docs/projects/flashing-heart.md +4 -0
  24. package/docs/projects/hot-potato.md +4 -0
  25. package/docs/projects/level.md +3 -0
  26. package/docs/projects/love-meter.md +13 -9
  27. package/docs/projects/micro-chat.md +7 -3
  28. package/docs/projects/name-tag.md +9 -5
  29. package/docs/projects/plot-acceleration.md +4 -0
  30. package/docs/projects/rock-paper-scissors-v2.md +5 -1
  31. package/docs/projects/rock-paper-scissors.md +11 -7
  32. package/docs/projects/smiley-buttons.md +11 -8
  33. package/docs/projects/stopwatch.md +5 -1
  34. package/docs/projects/v2-blow-away.md +28 -88
  35. package/docs/projects/v2-cat-napping.md +51 -72
  36. package/docs/projects/v2-clap-lights.md +16 -50
  37. package/docs/projects/v2-countdown.md +15 -47
  38. package/docs/projects/v2-morse-chat.md +55 -60
  39. package/docs/projects/v2-pet-hamster.md +16 -50
  40. package/docs/tours/editor-tour.md +12 -0
  41. package/package.json +3 -3
  42. package/pxtarget.json +3 -1
package/built/sim.js CHANGED
@@ -70,7 +70,7 @@ var pxsim;
70
70
  ID_RADIO: 9 /* MICROBIT_ID_RADIO */,
71
71
  RADIO_EVT_DATAGRAM: 1 /* MICROBIT_RADIO_EVT_DATAGRAM */
72
72
  });
73
- this.builtinParts["microphone"] = this.microphoneState = new pxsim.AnalogSensorState(3001 /* DEVICE_ID_MICROPHONE */, 0, 255, 86, 165);
73
+ this.builtinParts["microphone"] = this.microphoneState = new pxsim.MicrophoneState(3001 /* DEVICE_ID_MICROPHONE */, 0, 255, 86, 165);
74
74
  this.builtinParts["recording"] = this.recordingState = new pxsim.RecordingState();
75
75
  this.builtinParts["accelerometer"] = this.accelerometerState = new pxsim.AccelerometerState(pxsim.runtime);
76
76
  this.builtinParts["serial"] = this.serialState = new pxsim.SerialState(pxsim.runtime, this);
@@ -133,6 +133,9 @@ var pxsim;
133
133
  }), opts);
134
134
  document.body.innerHTML = ""; // clear children
135
135
  document.body.appendChild(this.view = this.viewHost.getView());
136
+ if (msg.theme === "mbcodal") {
137
+ this.ensureHardwareVersion(2);
138
+ }
136
139
  return Promise.resolve();
137
140
  }
138
141
  tryGetNeopixelState(pinId) {
@@ -1819,6 +1822,7 @@ var pxsim;
1819
1822
  if (!b)
1820
1823
  return 0;
1821
1824
  b.setUsed();
1825
+ b.pingSoundLevel();
1822
1826
  return b.getLevel();
1823
1827
  }
1824
1828
  input.soundLevel = soundLevel;
@@ -1827,6 +1831,7 @@ var pxsim;
1827
1831
  if (!b)
1828
1832
  return;
1829
1833
  b.setUsed();
1834
+ b.onSoundRegistered = true;
1830
1835
  pxsim.pxtcore.registerWithDal(b.id, sound, body);
1831
1836
  }
1832
1837
  input.onSound = onSound;
@@ -1834,7 +1839,6 @@ var pxsim;
1834
1839
  const b = pxsim.microphoneState();
1835
1840
  if (!b)
1836
1841
  return;
1837
- b.setUsed();
1838
1842
  if (sound === 2 /* SoundThreshold.Loud */)
1839
1843
  b.setHighThreshold(threshold);
1840
1844
  else
@@ -2302,6 +2306,7 @@ var pxsim;
2302
2306
  function stopRecorder(b) {
2303
2307
  b.recordingState.recorder.stop();
2304
2308
  b.recordingState.currentlyRecording = false;
2309
+ pxsim.runtime.queueDisplayUpdate();
2305
2310
  if (b.recordingState.stream.active) {
2306
2311
  b.recordingState.stream.getAudioTracks().forEach(track => {
2307
2312
  track.stop();
@@ -2333,7 +2338,6 @@ var pxsim;
2333
2338
  pxsim.runtime.queueDisplayUpdate();
2334
2339
  b.recordingState.recordTimeoutID = setTimeout(() => {
2335
2340
  stopRecorder(b);
2336
- pxsim.runtime.queueDisplayUpdate();
2337
2341
  }, 5000);
2338
2342
  b.recordingState.recorder.ondataavailable = (e) => {
2339
2343
  b.recordingState.chunks.push(e.data);
@@ -3198,11 +3202,11 @@ path.sim-board {
3198
3202
  return;
3199
3203
  let theme = this.props.theme;
3200
3204
  if (this.microphoneLed) {
3201
- if (b.recordingState.currentlyRecording) {
3205
+ if (b.recordingState.currentlyRecording || b.microphoneState.soundLevelRequested) {
3202
3206
  pxsim.svg.fills([this.microphoneLed], theme.ledOn);
3203
3207
  pxsim.svg.filter(this.microphoneLed, `url(#ledglow)`);
3204
3208
  }
3205
- else if (!b.microphoneState.sensorUsed) {
3209
+ else if (!(b.microphoneState.onSoundRegistered || b.microphoneState.soundLevelRequested)) {
3206
3210
  pxsim.svg.fills([this.microphoneLed], theme.ledOff);
3207
3211
  pxsim.svg.filter(this.microphoneLed, `url(#none)`);
3208
3212
  }
@@ -4424,6 +4428,27 @@ var pxsim;
4424
4428
  })(pxsim || (pxsim = {}));
4425
4429
  var pxsim;
4426
4430
  (function (pxsim) {
4431
+ class MicrophoneState extends pxsim.AnalogSensorState {
4432
+ constructor() {
4433
+ super(...arguments);
4434
+ this.onSoundRegistered = false;
4435
+ this.soundLevelRequested = false;
4436
+ this.pingSoundLevel = () => {
4437
+ if (this.onSoundRegistered) {
4438
+ return;
4439
+ }
4440
+ this.soundLevelRequested = true;
4441
+ pxsim.runtime.queueDisplayUpdate();
4442
+ clearTimeout(this.pingUsed);
4443
+ this.pingUsed = setTimeout(() => {
4444
+ this.soundLevelRequested = false;
4445
+ pxsim.runtime.queueDisplayUpdate();
4446
+ this.pingUsed = undefined;
4447
+ }, 100);
4448
+ };
4449
+ }
4450
+ }
4451
+ pxsim.MicrophoneState = MicrophoneState;
4427
4452
  function microphoneState() {
4428
4453
  return pxsim.board().microphoneState;
4429
4454
  }