pxt-microbit 5.1.33 → 5.1.35
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/common-sim.d.ts +8 -2
- package/built/common-sim.js +21 -0
- package/built/editor.js +14 -9
- package/built/sim.d.ts +9 -3
- package/built/sim.js +27 -5
- package/built/target.js +1 -1
- package/built/target.json +1 -1
- package/built/targetlight.json +1 -1
- package/built/theme.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 +1 -1
- package/built/web/semantic.css +1 -1
- package/docs/device/usb/webusb.md +2 -2
- package/docs/tours/editor-tour.md +12 -0
- package/package.json +3 -3
- package/pxtarget.json +4 -1
package/built/common-sim.d.ts
CHANGED
|
@@ -938,9 +938,15 @@ declare namespace pxsim.input {
|
|
|
938
938
|
}
|
|
939
939
|
declare namespace pxsim {
|
|
940
940
|
interface MicrophoneBoard {
|
|
941
|
-
microphoneState:
|
|
941
|
+
microphoneState: MicrophoneState;
|
|
942
942
|
}
|
|
943
|
-
|
|
943
|
+
class MicrophoneState extends AnalogSensorState {
|
|
944
|
+
onSoundRegistered: boolean;
|
|
945
|
+
soundLevelRequested: boolean;
|
|
946
|
+
private pingUsed;
|
|
947
|
+
pingSoundLevel: () => void;
|
|
948
|
+
}
|
|
949
|
+
function microphoneState(): MicrophoneState;
|
|
944
950
|
}
|
|
945
951
|
declare namespace pxsim.music {
|
|
946
952
|
function playInstructions(b: RefBuffer): Promise<void>;
|
package/built/common-sim.js
CHANGED
|
@@ -3181,6 +3181,27 @@ var pxsim;
|
|
|
3181
3181
|
})(pxsim || (pxsim = {}));
|
|
3182
3182
|
var pxsim;
|
|
3183
3183
|
(function (pxsim) {
|
|
3184
|
+
class MicrophoneState extends pxsim.AnalogSensorState {
|
|
3185
|
+
constructor() {
|
|
3186
|
+
super(...arguments);
|
|
3187
|
+
this.onSoundRegistered = false;
|
|
3188
|
+
this.soundLevelRequested = false;
|
|
3189
|
+
this.pingSoundLevel = () => {
|
|
3190
|
+
if (this.onSoundRegistered) {
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
this.soundLevelRequested = true;
|
|
3194
|
+
pxsim.runtime.queueDisplayUpdate();
|
|
3195
|
+
clearTimeout(this.pingUsed);
|
|
3196
|
+
this.pingUsed = setTimeout(() => {
|
|
3197
|
+
this.soundLevelRequested = false;
|
|
3198
|
+
pxsim.runtime.queueDisplayUpdate();
|
|
3199
|
+
this.pingUsed = undefined;
|
|
3200
|
+
}, 100);
|
|
3201
|
+
};
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
pxsim.MicrophoneState = MicrophoneState;
|
|
3184
3205
|
function microphoneState() {
|
|
3185
3206
|
return pxsim.board().microphoneState;
|
|
3186
3207
|
}
|
package/built/editor.js
CHANGED
|
@@ -3476,7 +3476,7 @@ class DAPWrapper {
|
|
|
3476
3476
|
return this.stopReadersAsync()
|
|
3477
3477
|
.then(() => this.io.disconnectAsync());
|
|
3478
3478
|
}
|
|
3479
|
-
reflashAsync(resp) {
|
|
3479
|
+
reflashAsync(resp, progressCallback) {
|
|
3480
3480
|
var _a, _b;
|
|
3481
3481
|
pxt.tickEvent("hid.flash.start");
|
|
3482
3482
|
log("reflash");
|
|
@@ -3496,7 +3496,7 @@ class DAPWrapper {
|
|
|
3496
3496
|
// shortcut, do a full flash
|
|
3497
3497
|
if (uicr != 0 || this.forceFullFlash) {
|
|
3498
3498
|
pxt.tickEvent("hid.flash.uicrfail");
|
|
3499
|
-
return this.fullVendorCommandFlashAsync(resp);
|
|
3499
|
+
return this.fullVendorCommandFlashAsync(resp, progressCallback);
|
|
3500
3500
|
}
|
|
3501
3501
|
// check flash checksums
|
|
3502
3502
|
return this.computeFlashChecksum(resp)
|
|
@@ -3504,9 +3504,9 @@ class DAPWrapper {
|
|
|
3504
3504
|
pxt.tickEvent("hid.flash.checksum", { quick: chk.quick ? 1 : 0, changed: chk.changed ? chk.changed.length : 0 });
|
|
3505
3505
|
// let's do a quick flash!
|
|
3506
3506
|
if (chk.quick)
|
|
3507
|
-
return this.quickHidFlashAsync(chk.changed);
|
|
3507
|
+
return this.quickHidFlashAsync(chk.changed, progressCallback);
|
|
3508
3508
|
else
|
|
3509
|
-
return this.fullVendorCommandFlashAsync(resp);
|
|
3509
|
+
return this.fullVendorCommandFlashAsync(resp, progressCallback);
|
|
3510
3510
|
});
|
|
3511
3511
|
})
|
|
3512
3512
|
.then(() => this.checkStateAsync(true))
|
|
@@ -3548,9 +3548,10 @@ class DAPWrapper {
|
|
|
3548
3548
|
dapCmdNums(...nums) {
|
|
3549
3549
|
return this.dapCmd(new Uint8Array(nums));
|
|
3550
3550
|
}
|
|
3551
|
-
fullVendorCommandFlashAsync(resp) {
|
|
3551
|
+
fullVendorCommandFlashAsync(resp, progressCallback) {
|
|
3552
3552
|
log("full flash");
|
|
3553
3553
|
pxt.tickEvent("hid.flash.full.start");
|
|
3554
|
+
const start = Date.now();
|
|
3554
3555
|
const chunkSize = 62;
|
|
3555
3556
|
let sentPages = 0;
|
|
3556
3557
|
return pxt.Util.promiseTimeout(FULL_FLASH_TIMEOUT, Promise.resolve()
|
|
@@ -3572,8 +3573,10 @@ class DAPWrapper {
|
|
|
3572
3573
|
cmdData[0] = 0x8C; /* DAPLinkFlash.WRITE */
|
|
3573
3574
|
cmdData[1] = nextPageData.length;
|
|
3574
3575
|
cmdData.set(nextPageData, 2);
|
|
3575
|
-
if (sentPages % 128 == 0) // reduce logging
|
|
3576
|
+
if (sentPages % 128 == 0) { // reduce logging
|
|
3577
|
+
progressCallback(offset / hexUint8.length);
|
|
3576
3578
|
log(`next page ${sentPages}: [${offset.toString(16)}, ${end.toString(16)}] (${Math.ceil((hexUint8.length - end) / 1000)}kb left)`);
|
|
3579
|
+
}
|
|
3577
3580
|
return this.dapCmd(cmdData)
|
|
3578
3581
|
.then(() => {
|
|
3579
3582
|
this.checkAborted();
|
|
@@ -3596,7 +3599,7 @@ class DAPWrapper {
|
|
|
3596
3599
|
})
|
|
3597
3600
|
.then((res) => {
|
|
3598
3601
|
log(`daplinkreset: ${pxt.U.toHex(res)}`);
|
|
3599
|
-
log(`full flash done`);
|
|
3602
|
+
log(`full flash done after ${Date.now() - start}ms`);
|
|
3600
3603
|
pxt.tickEvent("hid.flash.full.success");
|
|
3601
3604
|
}), timeoutMessage).catch((e) => {
|
|
3602
3605
|
log(`error: abort`);
|
|
@@ -3660,9 +3663,10 @@ class DAPWrapper {
|
|
|
3660
3663
|
};
|
|
3661
3664
|
});
|
|
3662
3665
|
}
|
|
3663
|
-
quickHidFlashAsync(changed) {
|
|
3666
|
+
quickHidFlashAsync(changed, progressCallback) {
|
|
3664
3667
|
log("quick flash");
|
|
3665
3668
|
pxt.tickEvent("hid.flash.quick.start");
|
|
3669
|
+
const start = Date.now();
|
|
3666
3670
|
const runFlash = (b, dataAddr) => {
|
|
3667
3671
|
const cmd = this.cortexM.prepareCommand();
|
|
3668
3672
|
cmd.halt();
|
|
@@ -3693,6 +3697,7 @@ class DAPWrapper {
|
|
|
3693
3697
|
return Promise.resolve();
|
|
3694
3698
|
}
|
|
3695
3699
|
log(`about to write at 0x${b.targetAddr.toString(16)}`);
|
|
3700
|
+
progressCallback(i / changed.length);
|
|
3696
3701
|
let writeBl = Promise.resolve();
|
|
3697
3702
|
let thisAddr = (i & 1) ? dataAddr : dataAddr + this.pageSize;
|
|
3698
3703
|
let nextAddr = (i & 1) ? dataAddr + this.pageSize : dataAddr;
|
|
@@ -3721,7 +3726,7 @@ class DAPWrapper {
|
|
|
3721
3726
|
});
|
|
3722
3727
|
}))
|
|
3723
3728
|
.then(() => {
|
|
3724
|
-
log(
|
|
3729
|
+
log(`quick flash done after ${Date.now() - start}ms`);
|
|
3725
3730
|
return this.cortexM.reset(false);
|
|
3726
3731
|
})
|
|
3727
3732
|
.then(() => {
|
package/built/sim.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare namespace pxsim {
|
|
|
18
18
|
lightSensorState: LightSensorState;
|
|
19
19
|
buttonPairState: ButtonPairState;
|
|
20
20
|
radioState: RadioState;
|
|
21
|
-
microphoneState:
|
|
21
|
+
microphoneState: MicrophoneState;
|
|
22
22
|
recordingState: RecordingState;
|
|
23
23
|
lightState: pxt.Map<CommonNeoPixelState>;
|
|
24
24
|
fileSystem: FileSystemState;
|
|
@@ -898,9 +898,15 @@ declare namespace pxsim {
|
|
|
898
898
|
}
|
|
899
899
|
declare namespace pxsim {
|
|
900
900
|
interface MicrophoneBoard {
|
|
901
|
-
microphoneState:
|
|
901
|
+
microphoneState: MicrophoneState;
|
|
902
902
|
}
|
|
903
|
-
|
|
903
|
+
class MicrophoneState extends AnalogSensorState {
|
|
904
|
+
onSoundRegistered: boolean;
|
|
905
|
+
soundLevelRequested: boolean;
|
|
906
|
+
private pingUsed;
|
|
907
|
+
pingSoundLevel: () => void;
|
|
908
|
+
}
|
|
909
|
+
function microphoneState(): MicrophoneState;
|
|
904
910
|
}
|
|
905
911
|
declare namespace pxsim {
|
|
906
912
|
enum NeoPixelMode {
|
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.
|
|
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);
|
|
@@ -1822,6 +1822,7 @@ var pxsim;
|
|
|
1822
1822
|
if (!b)
|
|
1823
1823
|
return 0;
|
|
1824
1824
|
b.setUsed();
|
|
1825
|
+
b.pingSoundLevel();
|
|
1825
1826
|
return b.getLevel();
|
|
1826
1827
|
}
|
|
1827
1828
|
input.soundLevel = soundLevel;
|
|
@@ -1830,6 +1831,7 @@ var pxsim;
|
|
|
1830
1831
|
if (!b)
|
|
1831
1832
|
return;
|
|
1832
1833
|
b.setUsed();
|
|
1834
|
+
b.onSoundRegistered = true;
|
|
1833
1835
|
pxsim.pxtcore.registerWithDal(b.id, sound, body);
|
|
1834
1836
|
}
|
|
1835
1837
|
input.onSound = onSound;
|
|
@@ -1837,7 +1839,6 @@ var pxsim;
|
|
|
1837
1839
|
const b = pxsim.microphoneState();
|
|
1838
1840
|
if (!b)
|
|
1839
1841
|
return;
|
|
1840
|
-
b.setUsed();
|
|
1841
1842
|
if (sound === 2 /* SoundThreshold.Loud */)
|
|
1842
1843
|
b.setHighThreshold(threshold);
|
|
1843
1844
|
else
|
|
@@ -2305,6 +2306,7 @@ var pxsim;
|
|
|
2305
2306
|
function stopRecorder(b) {
|
|
2306
2307
|
b.recordingState.recorder.stop();
|
|
2307
2308
|
b.recordingState.currentlyRecording = false;
|
|
2309
|
+
pxsim.runtime.queueDisplayUpdate();
|
|
2308
2310
|
if (b.recordingState.stream.active) {
|
|
2309
2311
|
b.recordingState.stream.getAudioTracks().forEach(track => {
|
|
2310
2312
|
track.stop();
|
|
@@ -2336,7 +2338,6 @@ var pxsim;
|
|
|
2336
2338
|
pxsim.runtime.queueDisplayUpdate();
|
|
2337
2339
|
b.recordingState.recordTimeoutID = setTimeout(() => {
|
|
2338
2340
|
stopRecorder(b);
|
|
2339
|
-
pxsim.runtime.queueDisplayUpdate();
|
|
2340
2341
|
}, 5000);
|
|
2341
2342
|
b.recordingState.recorder.ondataavailable = (e) => {
|
|
2342
2343
|
b.recordingState.chunks.push(e.data);
|
|
@@ -3201,11 +3202,11 @@ path.sim-board {
|
|
|
3201
3202
|
return;
|
|
3202
3203
|
let theme = this.props.theme;
|
|
3203
3204
|
if (this.microphoneLed) {
|
|
3204
|
-
if (b.recordingState.currentlyRecording) {
|
|
3205
|
+
if (b.recordingState.currentlyRecording || b.microphoneState.soundLevelRequested) {
|
|
3205
3206
|
pxsim.svg.fills([this.microphoneLed], theme.ledOn);
|
|
3206
3207
|
pxsim.svg.filter(this.microphoneLed, `url(#ledglow)`);
|
|
3207
3208
|
}
|
|
3208
|
-
else if (!b.microphoneState.
|
|
3209
|
+
else if (!(b.microphoneState.onSoundRegistered || b.microphoneState.soundLevelRequested)) {
|
|
3209
3210
|
pxsim.svg.fills([this.microphoneLed], theme.ledOff);
|
|
3210
3211
|
pxsim.svg.filter(this.microphoneLed, `url(#none)`);
|
|
3211
3212
|
}
|
|
@@ -4427,6 +4428,27 @@ var pxsim;
|
|
|
4427
4428
|
})(pxsim || (pxsim = {}));
|
|
4428
4429
|
var pxsim;
|
|
4429
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;
|
|
4430
4452
|
function microphoneState() {
|
|
4431
4453
|
return pxsim.board().microphoneState;
|
|
4432
4454
|
}
|