pxt-common-packages 9.3.8 → 9.3.12

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 (41) hide show
  1. package/built/common-sim.d.ts +2 -0
  2. package/built/common-sim.js +36 -0
  3. package/libs/azureiot/azureiot.ts +4 -4
  4. package/libs/azureiot/built/debug/binary.js +461 -461
  5. package/libs/color/built/debug/binary.js +8 -8
  6. package/libs/color-sensor/built/debug/binary.js +8 -8
  7. package/libs/controller/built/debug/binary.js +6551 -6551
  8. package/libs/controller---none/built/debug/binary.js +6531 -6531
  9. package/libs/core---esp32/pxt.h +2 -0
  10. package/libs/core---esp32/usb.cpp +43 -18
  11. package/libs/core---esp32/worker.cpp +8 -0
  12. package/libs/core---vm/vm.cpp +75 -2
  13. package/libs/datalogger/built/debug/binary.js +63 -63
  14. package/libs/edge-connector/built/debug/binary.js +8 -8
  15. package/libs/esp32/built/debug/binary.js +462 -462
  16. package/libs/game/built/debug/binary.js +6470 -6470
  17. package/libs/lcd/built/debug/binary.js +8 -8
  18. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  19. package/libs/lora/built/debug/binary.js +8 -8
  20. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  21. package/libs/mqtt/built/debug/binary.js +176 -176
  22. package/libs/mqtt/mqtt.ts +10 -4
  23. package/libs/net/built/debug/binary.js +176 -176
  24. package/libs/net-game/built/debug/binary.js +8049 -8049
  25. package/libs/palette/built/debug/binary.js +6469 -6469
  26. package/libs/pixel/built/debug/binary.js +8 -8
  27. package/libs/power/built/debug/binary.js +8 -8
  28. package/libs/proximity/built/debug/binary.js +8 -8
  29. package/libs/radio/built/debug/binary.js +8 -8
  30. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  31. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  32. package/libs/screen/_locales/screen-jsdoc-strings.json +1 -0
  33. package/libs/screen/built/debug/binary.js +50 -50
  34. package/libs/screen/image.cpp +43 -0
  35. package/libs/screen/image.ts +26 -0
  36. package/libs/screen/sim/image.ts +40 -0
  37. package/libs/servo/built/debug/binary.js +8 -8
  38. package/libs/storyboard/built/debug/binary.js +6469 -6469
  39. package/libs/wifi---esp32/controller.ts +2 -3
  40. package/libs/wifi---esp32/socket.cpp +4 -2
  41. package/package.json +1 -1
@@ -1007,6 +1007,8 @@ declare namespace pxsim.ImageMethods {
1007
1007
  function _fillCircle(img: RefImage, cxy: number, r: number, c: number): void;
1008
1008
  function _blitRow(img: RefImage, xy: number, from: RefImage, xh: number): void;
1009
1009
  function blitRow(img: RefImage, x: number, y: number, from: RefImage, fromX: number, fromH: number): void;
1010
+ function _blit(img: RefImage, src: RefImage, args: RefCollection): void;
1011
+ function blit(dst: RefImage, src: RefImage, args: RefCollection): void;
1010
1012
  }
1011
1013
  declare namespace pxsim.image {
1012
1014
  function byteHeight(h: number, bpp: number): number;
@@ -3904,6 +3904,42 @@ var pxsim;
3904
3904
  }
3905
3905
  }
3906
3906
  ImageMethods.blitRow = blitRow;
3907
+ function _blit(img, src, args) {
3908
+ blit(img, src, args);
3909
+ }
3910
+ ImageMethods._blit = _blit;
3911
+ function blit(dst, src, args) {
3912
+ const xDst = args.getAt(0);
3913
+ const yDst = args.getAt(1);
3914
+ const wDst = args.getAt(2);
3915
+ const hDst = args.getAt(3);
3916
+ const xSrc = args.getAt(4);
3917
+ const ySrc = args.getAt(5);
3918
+ const wSrc = args.getAt(6);
3919
+ const hSrc = args.getAt(7);
3920
+ const transparent = args.getAt(8);
3921
+ const xDstStart = Math.max(0, xDst);
3922
+ const yDstStart = Math.max(0, yDst);
3923
+ const xDstEnd = Math.min(dst._width, xDst + wDst);
3924
+ const yDstEnd = Math.min(dst._height, yDst + hDst);
3925
+ const xSrcStart = Math.max(0, xSrc) << 16;
3926
+ const ySrcStart = Math.max(0, ySrc) << 16;
3927
+ const xSrcEnd = Math.min(src._width, xSrc + wSrc) << 16;
3928
+ const ySrcEnd = Math.min(src._height, ySrc + hSrc) << 16;
3929
+ const xSrcStep = ((wSrc << 16) / wDst) | 0;
3930
+ const ySrcStep = ((hSrc << 16) / hDst) | 0;
3931
+ for (let yDstCur = yDstStart, ySrcCur = ySrcStart; yDstCur < yDstEnd && ySrcCur < ySrcEnd; ++yDstCur, ySrcCur += ySrcStep) {
3932
+ const ySrcCurI = ySrcCur >> 16;
3933
+ for (let xDstCur = xDstStart, xSrcCur = xSrcStart; xDstCur < xDstEnd && xSrcCur < xSrcEnd; ++xDstCur, xSrcCur += xSrcStep) {
3934
+ const xSrcCurI = xSrcCur >> 16;
3935
+ const cSrc = getPixel(src, xSrcCurI, ySrcCurI);
3936
+ if (!transparent || cSrc) {
3937
+ setPixel(dst, xDstCur, yDstCur, cSrc);
3938
+ }
3939
+ }
3940
+ }
3941
+ }
3942
+ ImageMethods.blit = blit;
3907
3943
  })(ImageMethods = pxsim.ImageMethods || (pxsim.ImageMethods = {}));
3908
3944
  })(pxsim || (pxsim = {}));
3909
3945
  (function (pxsim) {
@@ -17,6 +17,7 @@ namespace azureiot {
17
17
  let _messageBusId: number;
18
18
  let _receiveHandler: (msg: Json, sysProps: SMap<string>) => void;
19
19
  let _methodHandlers: SMap<(msg: Json) => Json>;
20
+ let twinRespHandlers: SMap<(status: number, body: any) => void>
20
21
 
21
22
  function log(msg: string) {
22
23
  console.add(logPriority, "azureiot: " + msg);
@@ -156,7 +157,6 @@ namespace azureiot {
156
157
  }
157
158
  catch {
158
159
  // just ignore errors disconnecting
159
- _mqttClient = undefined
160
160
  }
161
161
  }
162
162
  }
@@ -320,16 +320,16 @@ namespace azureiot {
320
320
  c.publish('$iothub/methods/res/' + status + "/?$rid=" + props["$rid"], JSON.stringify(resp))
321
321
  }
322
322
 
323
- let twinRespHandlers: SMap<(status: number, body: any) => void>
324
-
325
323
  // $iothub/twin/res/{status}/?$rid={request id}
326
324
  function twinResponse(msg: mqtt.IMessage) {
327
325
  const args = parseTopicArgs(msg.topic)
328
326
  const h = twinRespHandlers[args["$rid"]]
329
327
  const status = parseInt(msg.topic.slice(17))
330
328
  // log(`twin resp: ${status} ${msg.content.toHex()} ${msg.content.toString()}`)
331
- if (h)
329
+ if (h) {
330
+ delete twinRespHandlers[args["$rid"]]
332
331
  h(status, JSON.parse(msg.content.toString() || "{}"))
332
+ }
333
333
  }
334
334
 
335
335
  export class ValueAwaiter {