pxt-microbit 8.1.13 → 8.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/block-tests.js +1 -1
- package/built/sim-strings.json +1 -1
- package/built/sim.js +101 -58
- package/built/target.js +1 -1
- package/built/target.json +1 -1
- package/built/targetlight.js +1 -1
- package/built/targetlight.json +1 -1
- package/built/web/react-common-authcode.css +2 -2
- package/built/web/react-common-multiplayer.css +2 -2
- package/built/web/react-common-skillmap.css +2 -2
- package/built/web/rtlreact-common-authcode.css +2 -2
- package/built/web/rtlreact-common-multiplayer.css +2 -2
- package/built/web/rtlreact-common-skillmap.css +2 -2
- package/built/web/rtlsemantic.css +2 -2
- package/built/web/semantic.css +2 -2
- package/package.json +2 -2
package/built/sim.js
CHANGED
|
@@ -4255,29 +4255,33 @@ path.sim-board {
|
|
|
4255
4255
|
"P12", "P2", "P13", "P14", "P15", "P16", "P17", "P18", "P19", "P20",
|
|
4256
4256
|
"GND0", "GND", "+3v3", "GND1"
|
|
4257
4257
|
];
|
|
4258
|
+
// title is currently unused.
|
|
4258
4259
|
const pinTitles = [
|
|
4259
|
-
"P0, ANALOG IN",
|
|
4260
|
-
"P1, ANALOG IN",
|
|
4261
|
-
"P2, ANALOG IN",
|
|
4262
|
-
"P3, ANALOG IN, LED Col 1",
|
|
4263
|
-
"P4, ANALOG IN, LED Col 2",
|
|
4264
|
-
"P5, BUTTON A",
|
|
4265
|
-
"P6, LED Col 9",
|
|
4266
|
-
"P7, LED Col 8",
|
|
4267
|
-
"P8",
|
|
4268
|
-
"P9, LED Col 7",
|
|
4269
|
-
"P10, ANALOG IN, LED Col 3",
|
|
4270
|
-
"P11, BUTTON B",
|
|
4271
|
-
"P12, RESERVED ACCESSIBILITY",
|
|
4272
|
-
"P13, SPI - SCK",
|
|
4273
|
-
"P14, SPI - MISO",
|
|
4274
|
-
"P15, SPI - MOSI",
|
|
4275
|
-
"P16, SPI - Chip Select",
|
|
4276
|
-
"P17, +3v3",
|
|
4277
|
-
"P18, +3v3",
|
|
4278
|
-
"P19, I2C - SCL",
|
|
4279
|
-
"P20, I2C - SDA",
|
|
4280
|
-
"GND", "GND"
|
|
4260
|
+
{ title: "P0, ANALOG IN", ariaLabel: pxsim.localization.lf("Pin 0") },
|
|
4261
|
+
{ title: "P1, ANALOG IN", ariaLabel: pxsim.localization.lf("Pin 1") },
|
|
4262
|
+
{ title: "P2, ANALOG IN", ariaLabel: pxsim.localization.lf("Pin 2") },
|
|
4263
|
+
{ title: "P3, ANALOG IN, LED Col 1", ariaLabel: pxsim.localization.lf("Pin 3") },
|
|
4264
|
+
{ title: "P4, ANALOG IN, LED Col 2", ariaLabel: pxsim.localization.lf("Pin 4") },
|
|
4265
|
+
{ title: "P5, BUTTON A", ariaLabel: pxsim.localization.lf("Pin 5") },
|
|
4266
|
+
{ title: "P6, LED Col 9", ariaLabel: pxsim.localization.lf("Pin 6") },
|
|
4267
|
+
{ title: "P7, LED Col 8", ariaLabel: pxsim.localization.lf("Pin 7") },
|
|
4268
|
+
{ title: "P8", ariaLabel: pxsim.localization.lf("Pin 8") },
|
|
4269
|
+
{ title: "P9, LED Col 7", ariaLabel: pxsim.localization.lf("Pin 9") },
|
|
4270
|
+
{ title: "P10, ANALOG IN, LED Col 3", ariaLabel: pxsim.localization.lf("Pin 10") },
|
|
4271
|
+
{ title: "P11, BUTTON B", ariaLabel: pxsim.localization.lf("Pin 11") },
|
|
4272
|
+
{ title: "P12, RESERVED ACCESSIBILITY", ariaLabel: pxsim.localization.lf("Pin 12") },
|
|
4273
|
+
{ title: "P13, SPI - SCK", ariaLabel: pxsim.localization.lf("Pin 13") },
|
|
4274
|
+
{ title: "P14, SPI - MISO", ariaLabel: pxsim.localization.lf("Pin 14") },
|
|
4275
|
+
{ title: "P15, SPI - MOSI", ariaLabel: pxsim.localization.lf("Pin 15") },
|
|
4276
|
+
{ title: "P16, SPI - Chip Select", ariaLabel: pxsim.localization.lf("Pin 16") },
|
|
4277
|
+
{ title: "P17, +3v3", ariaLabel: pxsim.localization.lf("Pin 3V") },
|
|
4278
|
+
{ title: "P18, +3v3", ariaLabel: pxsim.localization.lf("Pin 3V") },
|
|
4279
|
+
{ title: "P19, I2C - SCL", ariaLabel: pxsim.localization.lf("Pin 19") },
|
|
4280
|
+
{ title: "P20, I2C - SDA", ariaLabel: pxsim.localization.lf("Pin 20") },
|
|
4281
|
+
{ title: "GND", ariaLabel: pxsim.localization.lf("Pin GND") },
|
|
4282
|
+
{ title: "GND", ariaLabel: pxsim.localization.lf("Pin GND") },
|
|
4283
|
+
{ title: "+3v3", ariaLabel: pxsim.localization.lf("Pin 3V") },
|
|
4284
|
+
{ title: "GND", ariaLabel: pxsim.localization.lf("Pin GND") },
|
|
4281
4285
|
];
|
|
4282
4286
|
const MB_WIDTH = 500;
|
|
4283
4287
|
const MB_HEIGHT = 408;
|
|
@@ -4505,7 +4509,7 @@ path.sim-board {
|
|
|
4505
4509
|
pxsim.svg.fill(this.shakeButton, this.props.theme.virtualButtonUp);
|
|
4506
4510
|
this.board.accelerometerState.shake();
|
|
4507
4511
|
});
|
|
4508
|
-
pxsim.accessibility.setAria(this.shakeButton, "button", "Shake
|
|
4512
|
+
pxsim.accessibility.setAria(this.shakeButton, "button", pxsim.localization.lf("Shake"));
|
|
4509
4513
|
this.shakeText = pxsim.svg.child(this.g, "text", { x: 420, y: 122, class: "sim-text-small", "aria-hidden": true });
|
|
4510
4514
|
this.shakeText.textContent = "SHAKE";
|
|
4511
4515
|
}
|
|
@@ -4545,19 +4549,23 @@ path.sim-board {
|
|
|
4545
4549
|
}
|
|
4546
4550
|
}
|
|
4547
4551
|
updatePin(pin, index) {
|
|
4552
|
+
var _a, _b;
|
|
4548
4553
|
if (!pin)
|
|
4549
4554
|
return;
|
|
4550
4555
|
let text = this.pinTexts[index];
|
|
4551
4556
|
let v = "";
|
|
4557
|
+
let ariaValueNow;
|
|
4552
4558
|
if (pin.mode & pxsim.PinFlags.Analog) {
|
|
4553
4559
|
v = Math.floor(100 - (pin.value || 0) / 1023 * 100) + "%";
|
|
4554
4560
|
if (text)
|
|
4555
4561
|
text.textContent = (pin.period ? "~" : "") + (pin.value || 0) + "";
|
|
4562
|
+
ariaValueNow = (_a = pin.value) !== null && _a !== void 0 ? _a : 0;
|
|
4556
4563
|
}
|
|
4557
4564
|
else if (pin.mode & pxsim.PinFlags.Digital) {
|
|
4558
4565
|
v = pin.value > 0 ? "0%" : "100%";
|
|
4559
4566
|
if (text)
|
|
4560
4567
|
text.textContent = pin.value > 0 ? "1" : "0";
|
|
4568
|
+
ariaValueNow = pin.value > 0 ? 1 : 0;
|
|
4561
4569
|
}
|
|
4562
4570
|
else if (pin.mode & pxsim.PinFlags.Touch) {
|
|
4563
4571
|
v = pin.touched ? "0%" : "100%";
|
|
@@ -4573,11 +4581,37 @@ path.sim-board {
|
|
|
4573
4581
|
pxsim.svg.setGradientValue(this.pinGradients[index], v);
|
|
4574
4582
|
if (pin.mode !== pxsim.PinFlags.Unused) {
|
|
4575
4583
|
pxsim.accessibility.makeFocusable(this.pins[index]);
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4584
|
+
if (pin.mode & pxsim.PinFlags.Touch) {
|
|
4585
|
+
this.pins[index].setAttribute("role", "button");
|
|
4586
|
+
this.pins[index].ariaLabel = this.pins[index].firstChild.textContent;
|
|
4587
|
+
this.pins[index].removeAttribute("aria-valuemin");
|
|
4588
|
+
this.pins[index].removeAttribute("aria-valuemax");
|
|
4589
|
+
this.pins[index].removeAttribute("aria-orientation");
|
|
4590
|
+
this.pins[index].removeAttribute("aria-valuenow");
|
|
4591
|
+
this.pins[index].removeAttribute("aria-valuetext");
|
|
4592
|
+
this.pins[index].removeAttribute("aria-readonly");
|
|
4593
|
+
}
|
|
4594
|
+
else {
|
|
4595
|
+
this.pins[index].setAttribute("role", "slider");
|
|
4596
|
+
this.pins[index].ariaLabel = this.pins[index].firstChild.textContent;
|
|
4597
|
+
this.pins[index].setAttribute("aria-valuemin", "0");
|
|
4598
|
+
this.pins[index].setAttribute("aria-valuemax", pin.mode & pxsim.PinFlags.Analog ? "1023" : "1");
|
|
4599
|
+
this.pins[index].setAttribute("aria-orientation", "vertical");
|
|
4600
|
+
this.pins[index].setAttribute("aria-valuenow", (_b = ariaValueNow.toString()) !== null && _b !== void 0 ? _b : "");
|
|
4601
|
+
// Check that the text content isn't just a plain int and only set aria-valuetext if required.
|
|
4602
|
+
if ((text === null || text === void 0 ? void 0 : text.textContent) && (text === null || text === void 0 ? void 0 : text.textContent) !== parseInt(text === null || text === void 0 ? void 0 : text.textContent).toString()) {
|
|
4603
|
+
this.pins[index].setAttribute("aria-valuetext", text.textContent);
|
|
4604
|
+
}
|
|
4605
|
+
else {
|
|
4606
|
+
this.pins[index].removeAttribute("aria-valuetext");
|
|
4607
|
+
}
|
|
4608
|
+
if (pin.mode & pxsim.PinFlags.Input) {
|
|
4609
|
+
this.pins[index].removeAttribute("aria-readonly");
|
|
4610
|
+
}
|
|
4611
|
+
else {
|
|
4612
|
+
this.pins[index].setAttribute("aria-readonly", "true");
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4581
4615
|
}
|
|
4582
4616
|
}
|
|
4583
4617
|
updateTemperature() {
|
|
@@ -4615,7 +4649,7 @@ path.sim-board {
|
|
|
4615
4649
|
}
|
|
4616
4650
|
});
|
|
4617
4651
|
pxsim.accessibility.makeFocusable(this.thermometer);
|
|
4618
|
-
pxsim.accessibility.setAria(this.thermometer, "slider", pxsim.localization.lf("
|
|
4652
|
+
pxsim.accessibility.setAria(this.thermometer, "slider", pxsim.localization.lf("Temperature"));
|
|
4619
4653
|
this.thermometer.setAttribute("aria-valuemin", "-5");
|
|
4620
4654
|
this.thermometer.setAttribute("aria-valuemax", "50");
|
|
4621
4655
|
this.thermometer.setAttribute("aria-orientation", "vertical");
|
|
@@ -4734,6 +4768,7 @@ path.sim-board {
|
|
|
4734
4768
|
}
|
|
4735
4769
|
}
|
|
4736
4770
|
flashAntenna() {
|
|
4771
|
+
var _a;
|
|
4737
4772
|
if (!this.antennaInitialized) {
|
|
4738
4773
|
this.antenna.style.visibility = "visible";
|
|
4739
4774
|
this.antennaInitialized = true;
|
|
@@ -4764,11 +4799,12 @@ path.sim-board {
|
|
|
4764
4799
|
pxsim.svg.buttonEvents(this.antenna.children[1], mouseEventHandler, mouseEventHandler, mouseEventHandler, () => { });
|
|
4765
4800
|
this.antenna.addEventListener('keydown', keyboardEventHandler);
|
|
4766
4801
|
pxsim.accessibility.makeFocusable(this.antenna);
|
|
4767
|
-
pxsim.accessibility.setAria(this.antenna, "slider", "
|
|
4802
|
+
pxsim.accessibility.setAria(this.antenna, "slider", pxsim.localization.lf("Received Signal Strength Indicator"));
|
|
4803
|
+
;
|
|
4768
4804
|
this.antenna.setAttribute("aria-valuemin", `${valueMin}`);
|
|
4769
4805
|
this.antenna.setAttribute("aria-valuemax", `${valueMax}`);
|
|
4770
4806
|
this.antenna.setAttribute("aria-orientation", "horizontal");
|
|
4771
|
-
this.antenna.setAttribute("aria-valuenow",
|
|
4807
|
+
this.antenna.setAttribute("aria-valuenow", ((_a = this.board.radioState.datagram.rssi) !== null && _a !== void 0 ? _a : -75).toString());
|
|
4772
4808
|
}
|
|
4773
4809
|
let now = Date.now();
|
|
4774
4810
|
if (now - this.lastAntennaFlash > 200) {
|
|
@@ -4840,7 +4876,7 @@ path.sim-board {
|
|
|
4840
4876
|
this.props.runtime.environmentGlobals[pxsim.localization.lf("lightLevel")] = state.lightSensorState.lightLevel;
|
|
4841
4877
|
this.updateTheme();
|
|
4842
4878
|
pxsim.accessibility.makeFocusable(this.lightLevelButton);
|
|
4843
|
-
pxsim.accessibility.setAria(this.lightLevelButton, "slider", "Light level");
|
|
4879
|
+
pxsim.accessibility.setAria(this.lightLevelButton, "slider", pxsim.localization.lf("Light level"));
|
|
4844
4880
|
this.lightLevelButton.setAttribute("aria-valuemin", "0");
|
|
4845
4881
|
this.lightLevelButton.setAttribute("aria-valuemax", "255");
|
|
4846
4882
|
this.lightLevelButton.setAttribute("aria-orientation", "vertical");
|
|
@@ -5077,7 +5113,7 @@ path.sim-board {
|
|
|
5077
5113
|
this.pins = pinDrawOrder.reduce((pins, pinName) => {
|
|
5078
5114
|
const simPinIndex = pinNames.indexOf(pinName);
|
|
5079
5115
|
const newPin = drawList[simPinIndex]();
|
|
5080
|
-
pxsim.svg.hydrate(newPin, { title: pinTitles[simPinIndex] });
|
|
5116
|
+
pxsim.svg.hydrate(newPin, { title: pinTitles[simPinIndex].ariaLabel });
|
|
5081
5117
|
pins[simPinIndex] = newPin;
|
|
5082
5118
|
return pins;
|
|
5083
5119
|
}, new Array(pinDrawOrder.length));
|
|
@@ -5183,8 +5219,7 @@ path.sim-board {
|
|
|
5183
5219
|
this.microphoneLed = pxsim.svg.path(microg, "sim-led sim-mic", "M 352.852 71 C 351.315 71 350.07 72.248 350.07 73.784 V 79.056 C 350.07 80.594 351.316 81.838 352.852 81.838 C 354.387 81.838 355.634 80.593 355.634 79.056 V 73.784 C 355.634 72.248 354.387 71 352.852 71 Z M 346.743 79.981 C 346.743 82.84 348.853 85.062 351.501 85.658 V 87.095 H 348.448 V 89.329 H 357.366 V 87.095 H 354.306 V 85.658 C 356.954 85.064 359.071 82.842 359.071 79.981 H 357.057 C 357.057 82.174 355.168 83.81 352.905 83.81 C 350.64 83.81 348.757 82.173 348.757 79.981 Z");
|
|
5184
5220
|
pxsim.svg.fills([this.microphoneLed], this.props.theme.ledOff);
|
|
5185
5221
|
// ring
|
|
5186
|
-
|
|
5187
|
-
pxsim.svg.title(microhole, pxsim.localization.lf("microphone (micro:bit v2 needed)"));
|
|
5222
|
+
pxsim.svg.child(this.g, "circle", { cx: 336, cy: 86, r: 3, stroke: "gold", strokeWidth: "1px" });
|
|
5188
5223
|
this.updateMicrophone();
|
|
5189
5224
|
this.updateTheme();
|
|
5190
5225
|
}
|
|
@@ -5288,10 +5323,11 @@ path.sim-board {
|
|
|
5288
5323
|
let state = this.board;
|
|
5289
5324
|
let pin = state.edgeConnectorState.pins[index];
|
|
5290
5325
|
let svgpin = this.pins[index];
|
|
5291
|
-
if (pin.mode & pxsim.PinFlags.Input) {
|
|
5326
|
+
if (pin.mode & pxsim.PinFlags.Input && !(pin.mode & pxsim.PinFlags.Touch)) {
|
|
5292
5327
|
let cursor = pxsim.svg.cursorPoint(pt, this.element, ev);
|
|
5293
|
-
let
|
|
5294
|
-
|
|
5328
|
+
let maxValue = pin.mode & pxsim.PinFlags.Analog ? 1023 : 1;
|
|
5329
|
+
let v = (400 - cursor.y) / 40 * maxValue;
|
|
5330
|
+
pin.value = Math.max(0, Math.min(maxValue, Math.floor(v)));
|
|
5295
5331
|
}
|
|
5296
5332
|
this.updatePin(pin, index);
|
|
5297
5333
|
},
|
|
@@ -5301,10 +5337,11 @@ path.sim-board {
|
|
|
5301
5337
|
let pin = state.edgeConnectorState.pins[index];
|
|
5302
5338
|
let svgpin = this.pins[index];
|
|
5303
5339
|
pxsim.U.addClass(svgpin, "touched");
|
|
5304
|
-
if (pin.mode & pxsim.PinFlags.Input) {
|
|
5340
|
+
if (pin.mode & pxsim.PinFlags.Input && !(pin.mode & pxsim.PinFlags.Touch)) {
|
|
5305
5341
|
let cursor = pxsim.svg.cursorPoint(pt, this.element, ev);
|
|
5306
|
-
let
|
|
5307
|
-
|
|
5342
|
+
let maxValue = pin.mode & pxsim.PinFlags.Analog ? 1023 : 1;
|
|
5343
|
+
let v = (400 - cursor.y) / 40 * maxValue;
|
|
5344
|
+
pin.value = Math.max(0, Math.min(maxValue, Math.floor(v)));
|
|
5308
5345
|
}
|
|
5309
5346
|
this.updatePin(pin, index);
|
|
5310
5347
|
},
|
|
@@ -5319,23 +5356,11 @@ path.sim-board {
|
|
|
5319
5356
|
},
|
|
5320
5357
|
// keydown
|
|
5321
5358
|
(ev) => {
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
if (
|
|
5326
|
-
|
|
5327
|
-
pin.value -= 10;
|
|
5328
|
-
if (pin.value < 0) {
|
|
5329
|
-
pin.value = 1023;
|
|
5330
|
-
}
|
|
5331
|
-
this.updatePin(pin, index);
|
|
5332
|
-
}
|
|
5333
|
-
else if (charCode === 38 || charCode === 39) { // Up/Right arrow
|
|
5334
|
-
ev.preventDefault();
|
|
5335
|
-
pin.value += 10;
|
|
5336
|
-
if (pin.value > 1023) {
|
|
5337
|
-
pin.value = 0;
|
|
5338
|
-
}
|
|
5359
|
+
const state = this.board;
|
|
5360
|
+
const pin = state.edgeConnectorState.pins[index];
|
|
5361
|
+
const value = pinKeyHandler(ev, pin.value, 0, pin.mode & pxsim.PinFlags.Analog ? 1023 : 1, pin.mode);
|
|
5362
|
+
if (value !== undefined) {
|
|
5363
|
+
pin.value = value;
|
|
5339
5364
|
this.updatePin(pin, index);
|
|
5340
5365
|
}
|
|
5341
5366
|
});
|
|
@@ -5522,6 +5547,24 @@ path.sim-board {
|
|
|
5522
5547
|
}
|
|
5523
5548
|
return undefined;
|
|
5524
5549
|
};
|
|
5550
|
+
const pinKeyHandler = (e, currentValue, min, max, pinMode) => {
|
|
5551
|
+
const key = e.key;
|
|
5552
|
+
if (isHandledKey(key)) {
|
|
5553
|
+
if (!(pinMode & pxsim.PinFlags.Input)) {
|
|
5554
|
+
e.preventDefault();
|
|
5555
|
+
pxsim.accessibility.setLiveContent(pxsim.localization.lf("This pin is read-only"));
|
|
5556
|
+
return undefined;
|
|
5557
|
+
}
|
|
5558
|
+
if (pinMode & pxsim.PinFlags.Touch) {
|
|
5559
|
+
// The pin is in touch mode and has button markup, not a slider.
|
|
5560
|
+
e.preventDefault();
|
|
5561
|
+
return undefined;
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5564
|
+
// The pin value for a digital pin may be higher than 1 depending on how its value was set.
|
|
5565
|
+
const currentValueClamped = Math.min(max, currentValue);
|
|
5566
|
+
return commonKeyHandler(e, currentValueClamped, min, max);
|
|
5567
|
+
};
|
|
5525
5568
|
})(visuals = pxsim.visuals || (pxsim.visuals = {}));
|
|
5526
5569
|
})(pxsim || (pxsim = {}));
|
|
5527
5570
|
var pxsim;
|