pxt-microbit 4.1.11 → 4.1.14
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 +16 -2
- package/built/common-sim.js +141 -23
- package/built/hexcache/{77bf628097cfa081fbde884794a216b621827ef66ce3beeee76691a64a8f2f84.hex → 8c2af07216a4f42b7aab203d0803cddece3fc4a4acc89db14ece4cf8719f892a.hex} +7631 -7617
- package/built/hexcache/becf72e02ed99aecb1bc9054dce656fb3379778d5ec7f16a4715d4addf05f02c.hex +20253 -0
- package/built/hexcache/{5f77c6b19fd0775b3c9f06534d4d55b43bba44d755df21a7ea304a6b4bc8c33d.hex → e0299da5faaab98fb510ca4acee742931a972910e45a66c7f50990e8326810f4.hex} +10771 -10759
- package/built/hexcache/f90d36a5042a5d2c5770f6f83317c0a89c8141ad426d5da91dea991b5516e699.hex +14853 -0
- package/built/sim.d.ts +7 -0
- package/built/sim.js +87 -24
- package/built/target.js +252 -56
- package/built/target.json +252 -56
- package/built/targetlight.json +6 -6
- package/built/theme.json +1 -1
- package/built/web/react-common-authcode.css +6038 -0
- package/built/web/react-common-skillmap.css +1 -1
- package/built/web/rtlreact-common-skillmap.css +1 -1
- package/built/web/rtlsemantic.css +3 -3
- package/built/web/semantic.css +3 -3
- package/docs/extensions.md +20 -4
- package/package.json +3 -3
- package/pxtarget.json +2 -2
- package/targetconfig.json +10 -6
- package/built/hexcache/167b21509d45dcf8aa9ac0e8dee0ad14c23cfa41fd75bbf9d0bb839519ac56b1.hex +0 -14849
- package/built/hexcache/f091c776e3c7f7fdaae7df4b89e0390e843a916f5a561903fa6188993a5bffe1.hex +0 -20247
package/built/common-sim.d.ts
CHANGED
|
@@ -882,6 +882,8 @@ declare namespace pxsim.radio {
|
|
|
882
882
|
function sendRawPacket(buf: RefBuffer): void;
|
|
883
883
|
function readRawPacket(): RefBuffer;
|
|
884
884
|
function onDataReceived(handler: RefAction): void;
|
|
885
|
+
function off(): void;
|
|
886
|
+
function on(): void;
|
|
885
887
|
}
|
|
886
888
|
declare namespace pxsim {
|
|
887
889
|
interface RadioBoard extends EventBusBoard {
|
|
@@ -924,12 +926,15 @@ declare namespace pxsim {
|
|
|
924
926
|
datagram: RadioDatagram;
|
|
925
927
|
groupId: number;
|
|
926
928
|
band: number;
|
|
929
|
+
enable: boolean;
|
|
927
930
|
constructor(runtime: Runtime, board: BaseBoard, dal: RadioDAL);
|
|
928
931
|
private handleMessage;
|
|
929
932
|
setGroup(id: number): void;
|
|
930
933
|
setTransmitPower(power: number): void;
|
|
931
934
|
setTransmitSerialNumber(sn: boolean): void;
|
|
932
935
|
setFrequencyBand(band: number): void;
|
|
936
|
+
off(): void;
|
|
937
|
+
on(): void;
|
|
933
938
|
raiseEvent(id: number, eventid: number): void;
|
|
934
939
|
receivePacket(packet: SimulatorRadioPacketMessage): void;
|
|
935
940
|
}
|
|
@@ -1007,8 +1012,8 @@ declare namespace pxsim.ImageMethods {
|
|
|
1007
1012
|
function _fillCircle(img: RefImage, cxy: number, r: number, c: number): void;
|
|
1008
1013
|
function _blitRow(img: RefImage, xy: number, from: RefImage, xh: number): void;
|
|
1009
1014
|
function blitRow(img: RefImage, x: number, y: number, from: RefImage, fromX: number, fromH: number): void;
|
|
1010
|
-
function _blit(img: RefImage, src: RefImage, args: RefCollection):
|
|
1011
|
-
function blit(dst: RefImage, src: RefImage, args: RefCollection):
|
|
1015
|
+
function _blit(img: RefImage, src: RefImage, args: RefCollection): boolean;
|
|
1016
|
+
function blit(dst: RefImage, src: RefImage, args: RefCollection): boolean;
|
|
1012
1017
|
}
|
|
1013
1018
|
declare namespace pxsim.image {
|
|
1014
1019
|
function byteHeight(h: number, bpp: number): number;
|
|
@@ -1119,6 +1124,14 @@ declare namespace pxsim.input {
|
|
|
1119
1124
|
function onSwitchMoved(direction: number, body: RefAction): void;
|
|
1120
1125
|
function switchRight(): boolean;
|
|
1121
1126
|
}
|
|
1127
|
+
declare namespace pxsim.tts {
|
|
1128
|
+
function _getLanguageCode(): string;
|
|
1129
|
+
function _speakAsync(text: string, pitch?: number, rate?: number, volume?: number, language?: string, onStart?: RefAction, onBoundary?: RefAction): Promise<void>;
|
|
1130
|
+
function _pause(): void;
|
|
1131
|
+
function _isPaused(): boolean;
|
|
1132
|
+
function _resume(): void;
|
|
1133
|
+
function _cancel(): void;
|
|
1134
|
+
}
|
|
1122
1135
|
declare namespace pxsim {
|
|
1123
1136
|
interface TemperatureBoard extends CommonBoard {
|
|
1124
1137
|
thermometerState: AnalogSensorState;
|
|
@@ -1220,6 +1233,7 @@ declare namespace pxsim._wifi {
|
|
|
1220
1233
|
export function socketClose(fd: int32): int32;
|
|
1221
1234
|
export function eventID(): int32;
|
|
1222
1235
|
export function scanStart(): void;
|
|
1236
|
+
export function startLoginServer(): void;
|
|
1223
1237
|
export function scanResults(): RefBuffer;
|
|
1224
1238
|
export function connect(ssid: string, pass: string): int32;
|
|
1225
1239
|
export function disconnect(): int32;
|
package/built/common-sim.js
CHANGED
|
@@ -3119,11 +3119,13 @@ var pxsim;
|
|
|
3119
3119
|
function sendRawPacket(buf) {
|
|
3120
3120
|
let cb = pxsim.getResume();
|
|
3121
3121
|
const state = pxsim.getRadioState();
|
|
3122
|
-
state.
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3122
|
+
if (state.enable) {
|
|
3123
|
+
state.datagram.send({
|
|
3124
|
+
type: 0,
|
|
3125
|
+
groupId: state.groupId,
|
|
3126
|
+
bufferData: buf.data
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3127
3129
|
setTimeout(cb, 1);
|
|
3128
3130
|
}
|
|
3129
3131
|
radio.sendRawPacket = sendRawPacket;
|
|
@@ -3147,6 +3149,16 @@ var pxsim;
|
|
|
3147
3149
|
state.datagram.onReceived(handler);
|
|
3148
3150
|
}
|
|
3149
3151
|
radio.onDataReceived = onDataReceived;
|
|
3152
|
+
function off() {
|
|
3153
|
+
const state = pxsim.getRadioState();
|
|
3154
|
+
state.off();
|
|
3155
|
+
}
|
|
3156
|
+
radio.off = off;
|
|
3157
|
+
function on() {
|
|
3158
|
+
const state = pxsim.getRadioState();
|
|
3159
|
+
state.on();
|
|
3160
|
+
}
|
|
3161
|
+
radio.on = on;
|
|
3150
3162
|
})(radio = pxsim.radio || (pxsim.radio = {}));
|
|
3151
3163
|
})(pxsim || (pxsim = {}));
|
|
3152
3164
|
var pxsim;
|
|
@@ -3215,6 +3227,7 @@ var pxsim;
|
|
|
3215
3227
|
this.power = 6; // default value
|
|
3216
3228
|
this.groupId = 0;
|
|
3217
3229
|
this.band = 7; // https://github.com/lancaster-university/microbit-dal/blob/master/inc/core/MicroBitConfig.h#L320
|
|
3230
|
+
this.enable = true;
|
|
3218
3231
|
this.board.addMessageListener(this.handleMessage.bind(this));
|
|
3219
3232
|
}
|
|
3220
3233
|
handleMessage(msg) {
|
|
@@ -3224,34 +3237,51 @@ var pxsim;
|
|
|
3224
3237
|
}
|
|
3225
3238
|
}
|
|
3226
3239
|
setGroup(id) {
|
|
3227
|
-
this.
|
|
3240
|
+
if (this.enable) {
|
|
3241
|
+
this.groupId = id & 0xff; // byte only
|
|
3242
|
+
}
|
|
3228
3243
|
}
|
|
3229
3244
|
setTransmitPower(power) {
|
|
3230
|
-
|
|
3231
|
-
|
|
3245
|
+
if (this.enable) {
|
|
3246
|
+
power = power | 0;
|
|
3247
|
+
this.power = Math.max(0, Math.min(7, power));
|
|
3248
|
+
}
|
|
3232
3249
|
}
|
|
3233
3250
|
setTransmitSerialNumber(sn) {
|
|
3234
3251
|
this.transmitSerialNumber = !!sn;
|
|
3235
3252
|
}
|
|
3236
3253
|
setFrequencyBand(band) {
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3254
|
+
if (this.enable) {
|
|
3255
|
+
band = band | 0;
|
|
3256
|
+
if (band < 0 || band > 83)
|
|
3257
|
+
return;
|
|
3258
|
+
this.band = band;
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
off() {
|
|
3262
|
+
this.enable = false;
|
|
3263
|
+
}
|
|
3264
|
+
on() {
|
|
3265
|
+
this.enable = true;
|
|
3241
3266
|
}
|
|
3242
3267
|
raiseEvent(id, eventid) {
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3268
|
+
if (this.enable) {
|
|
3269
|
+
pxsim.Runtime.postMessage({
|
|
3270
|
+
type: "eventbus",
|
|
3271
|
+
broadcast: true,
|
|
3272
|
+
id,
|
|
3273
|
+
eventid,
|
|
3274
|
+
power: this.power,
|
|
3275
|
+
group: this.groupId
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3251
3278
|
}
|
|
3252
3279
|
receivePacket(packet) {
|
|
3253
|
-
if (this.
|
|
3254
|
-
this.
|
|
3280
|
+
if (this.enable) {
|
|
3281
|
+
if (this.groupId == packet.payload.groupId) {
|
|
3282
|
+
this.datagram.queue(packet);
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3255
3285
|
}
|
|
3256
3286
|
}
|
|
3257
3287
|
pxsim.RadioState = RadioState;
|
|
@@ -3905,7 +3935,7 @@ var pxsim;
|
|
|
3905
3935
|
}
|
|
3906
3936
|
ImageMethods.blitRow = blitRow;
|
|
3907
3937
|
function _blit(img, src, args) {
|
|
3908
|
-
blit(img, src, args);
|
|
3938
|
+
return blit(img, src, args);
|
|
3909
3939
|
}
|
|
3910
3940
|
ImageMethods._blit = _blit;
|
|
3911
3941
|
function blit(dst, src, args) {
|
|
@@ -3918,6 +3948,7 @@ var pxsim;
|
|
|
3918
3948
|
const wSrc = args.getAt(6);
|
|
3919
3949
|
const hSrc = args.getAt(7);
|
|
3920
3950
|
const transparent = args.getAt(8);
|
|
3951
|
+
const check = args.getAt(9);
|
|
3921
3952
|
const xSrcStep = ((wSrc << 16) / wDst) | 0;
|
|
3922
3953
|
const ySrcStep = ((hSrc << 16) / hDst) | 0;
|
|
3923
3954
|
const xDstClip = Math.abs(Math.min(0, xDst));
|
|
@@ -3930,16 +3961,26 @@ var pxsim;
|
|
|
3930
3961
|
const ySrcStart = Math.max(0, (ySrc << 16) + yDstClip * ySrcStep);
|
|
3931
3962
|
const xSrcEnd = Math.min(src._width, xSrc + wSrc) << 16;
|
|
3932
3963
|
const ySrcEnd = Math.min(src._height, ySrc + hSrc) << 16;
|
|
3964
|
+
if (!check)
|
|
3965
|
+
dst.makeWritable();
|
|
3933
3966
|
for (let yDstCur = yDstStart, ySrcCur = ySrcStart; yDstCur < yDstEnd && ySrcCur < ySrcEnd; ++yDstCur, ySrcCur += ySrcStep) {
|
|
3934
3967
|
const ySrcCurI = ySrcCur >> 16;
|
|
3935
3968
|
for (let xDstCur = xDstStart, xSrcCur = xSrcStart; xDstCur < xDstEnd && xSrcCur < xSrcEnd; ++xDstCur, xSrcCur += xSrcStep) {
|
|
3936
3969
|
const xSrcCurI = xSrcCur >> 16;
|
|
3937
3970
|
const cSrc = getPixel(src, xSrcCurI, ySrcCurI);
|
|
3971
|
+
if (check && cSrc) {
|
|
3972
|
+
const cDst = getPixel(dst, xDstCur, yDstCur);
|
|
3973
|
+
if (cDst) {
|
|
3974
|
+
return true;
|
|
3975
|
+
}
|
|
3976
|
+
continue;
|
|
3977
|
+
}
|
|
3938
3978
|
if (!transparent || cSrc) {
|
|
3939
3979
|
setPixel(dst, xDstCur, yDstCur, cSrc);
|
|
3940
3980
|
}
|
|
3941
3981
|
}
|
|
3942
3982
|
}
|
|
3983
|
+
return false;
|
|
3943
3984
|
}
|
|
3944
3985
|
ImageMethods.blit = blit;
|
|
3945
3986
|
})(ImageMethods = pxsim.ImageMethods || (pxsim.ImageMethods = {}));
|
|
@@ -4568,6 +4609,80 @@ var pxsim;
|
|
|
4568
4609
|
})(input = pxsim.input || (pxsim.input = {}));
|
|
4569
4610
|
})(pxsim || (pxsim = {}));
|
|
4570
4611
|
var pxsim;
|
|
4612
|
+
(function (pxsim) {
|
|
4613
|
+
var tts;
|
|
4614
|
+
(function (tts) {
|
|
4615
|
+
function _getLanguageCode() {
|
|
4616
|
+
return window.navigator.language;
|
|
4617
|
+
}
|
|
4618
|
+
tts._getLanguageCode = _getLanguageCode;
|
|
4619
|
+
function _speakAsync(text, pitch, rate, volume, language, onStart, onBoundary) {
|
|
4620
|
+
return new Promise((resolve, reject) => {
|
|
4621
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
4622
|
+
utterance.voice = getVoiceForLanguage(language || _getLanguageCode());
|
|
4623
|
+
if (pitch != undefined)
|
|
4624
|
+
utterance.pitch = pitch;
|
|
4625
|
+
if (rate != undefined)
|
|
4626
|
+
utterance.rate = rate;
|
|
4627
|
+
if (volume != undefined)
|
|
4628
|
+
utterance.volume = volume;
|
|
4629
|
+
utterance.onend = () => resolve();
|
|
4630
|
+
utterance.onerror = reject;
|
|
4631
|
+
if (onStart) {
|
|
4632
|
+
utterance.onstart = () => pxsim.runtime.runFiberAsync(onStart);
|
|
4633
|
+
}
|
|
4634
|
+
if (onBoundary) {
|
|
4635
|
+
utterance.onboundary = event => {
|
|
4636
|
+
const offset = event.charIndex;
|
|
4637
|
+
const nextWord = text.substring(offset).split(/\s/).shift();
|
|
4638
|
+
pxsim.runtime.runFiberAsync(onBoundary, offset, nextWord, text);
|
|
4639
|
+
};
|
|
4640
|
+
}
|
|
4641
|
+
speechSynthesis.speak(utterance);
|
|
4642
|
+
});
|
|
4643
|
+
}
|
|
4644
|
+
tts._speakAsync = _speakAsync;
|
|
4645
|
+
function _pause() {
|
|
4646
|
+
speechSynthesis.pause();
|
|
4647
|
+
}
|
|
4648
|
+
tts._pause = _pause;
|
|
4649
|
+
function _isPaused() {
|
|
4650
|
+
return speechSynthesis.paused;
|
|
4651
|
+
}
|
|
4652
|
+
tts._isPaused = _isPaused;
|
|
4653
|
+
function _resume() {
|
|
4654
|
+
speechSynthesis.resume();
|
|
4655
|
+
}
|
|
4656
|
+
tts._resume = _resume;
|
|
4657
|
+
function _cancel() {
|
|
4658
|
+
speechSynthesis.cancel();
|
|
4659
|
+
}
|
|
4660
|
+
tts._cancel = _cancel;
|
|
4661
|
+
function getVoiceForLanguage(language) {
|
|
4662
|
+
language = language.toLowerCase();
|
|
4663
|
+
const generalCode = language.substring(0, 2);
|
|
4664
|
+
let bestMatch;
|
|
4665
|
+
let bestNonlocalMatch;
|
|
4666
|
+
for (const voice of speechSynthesis.getVoices()) {
|
|
4667
|
+
const current = voice.lang.toLowerCase();
|
|
4668
|
+
if (current === language) {
|
|
4669
|
+
if (voice.localService)
|
|
4670
|
+
return voice;
|
|
4671
|
+
else
|
|
4672
|
+
bestNonlocalMatch = voice;
|
|
4673
|
+
}
|
|
4674
|
+
else if (current.substring(0, 2) === generalCode) {
|
|
4675
|
+
if (!bestMatch && voice.localService)
|
|
4676
|
+
bestMatch = voice;
|
|
4677
|
+
if (!bestNonlocalMatch && !voice.localService)
|
|
4678
|
+
bestNonlocalMatch = voice;
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
return bestMatch || bestNonlocalMatch || (language !== "en-us" ? getVoiceForLanguage("en-US") : undefined);
|
|
4682
|
+
}
|
|
4683
|
+
})(tts = pxsim.tts || (pxsim.tts = {}));
|
|
4684
|
+
})(pxsim || (pxsim = {}));
|
|
4685
|
+
var pxsim;
|
|
4571
4686
|
(function (pxsim) {
|
|
4572
4687
|
function thermometerState() {
|
|
4573
4688
|
return pxsim.board().thermometerState;
|
|
@@ -4967,6 +5082,9 @@ var pxsim;
|
|
|
4967
5082
|
_raiseEvent(1 /* ScanDone */);
|
|
4968
5083
|
}
|
|
4969
5084
|
_wifi.scanStart = scanStart;
|
|
5085
|
+
function startLoginServer() {
|
|
5086
|
+
}
|
|
5087
|
+
_wifi.startLoginServer = startLoginServer;
|
|
4970
5088
|
function scanResults() {
|
|
4971
5089
|
const b = new Uint8Array(7);
|
|
4972
5090
|
b[0] = -20; // rssi
|