pxt-common-packages 9.3.9 → 9.3.13

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 (39) hide show
  1. package/built/common-sim.d.ts +2 -0
  2. package/built/common-sim.js +38 -0
  3. package/libs/azureiot/azureiot.ts +4 -4
  4. package/libs/azureiot/built/debug/binary.js +469 -464
  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---vm/vm.cpp +75 -2
  10. package/libs/datalogger/built/debug/binary.js +63 -63
  11. package/libs/edge-connector/built/debug/binary.js +8 -8
  12. package/libs/esp32/built/debug/binary.js +470 -465
  13. package/libs/game/built/debug/binary.js +6470 -6470
  14. package/libs/lcd/built/debug/binary.js +8 -8
  15. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  16. package/libs/lora/built/debug/binary.js +8 -8
  17. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  18. package/libs/mqtt/built/debug/binary.js +176 -176
  19. package/libs/mqtt/mqtt.ts +9 -2
  20. package/libs/net/built/debug/binary.js +176 -176
  21. package/libs/net/controller.ts +15 -1
  22. package/libs/net-game/built/debug/binary.js +8236 -8171
  23. package/libs/palette/built/debug/binary.js +6469 -6469
  24. package/libs/pixel/built/debug/binary.js +8 -8
  25. package/libs/power/built/debug/binary.js +8 -8
  26. package/libs/proximity/built/debug/binary.js +8 -8
  27. package/libs/radio/built/debug/binary.js +8 -8
  28. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  29. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  30. package/libs/screen/_locales/screen-jsdoc-strings.json +1 -0
  31. package/libs/screen/built/debug/binary.js +50 -50
  32. package/libs/screen/image.cpp +45 -0
  33. package/libs/screen/image.ts +26 -0
  34. package/libs/screen/sim/image.ts +42 -0
  35. package/libs/servo/built/debug/binary.js +8 -8
  36. package/libs/storyboard/built/debug/binary.js +6469 -6469
  37. package/libs/wifi---esp32/controller.ts +2 -3
  38. package/libs/wifi---esp32/socket.cpp +4 -2
  39. 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,44 @@ 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 xSrcStep = ((wSrc << 16) / wDst) | 0;
3922
+ const ySrcStep = ((hSrc << 16) / hDst) | 0;
3923
+ const xDstClip = Math.abs(Math.min(0, xDst));
3924
+ const yDstClip = Math.abs(Math.min(0, yDst));
3925
+ const xDstStart = xDst + xDstClip;
3926
+ const yDstStart = yDst + yDstClip;
3927
+ const xDstEnd = Math.min(dst._width, xDst + wDst);
3928
+ const yDstEnd = Math.min(dst._height, yDst + hDst);
3929
+ const xSrcStart = Math.max(0, (xSrc << 16) + xDstClip * xSrcStep);
3930
+ const ySrcStart = Math.max(0, (ySrc << 16) + yDstClip * ySrcStep);
3931
+ const xSrcEnd = Math.min(src._width, xSrc + wSrc) << 16;
3932
+ const ySrcEnd = Math.min(src._height, ySrc + hSrc) << 16;
3933
+ for (let yDstCur = yDstStart, ySrcCur = ySrcStart; yDstCur < yDstEnd && ySrcCur < ySrcEnd; ++yDstCur, ySrcCur += ySrcStep) {
3934
+ const ySrcCurI = ySrcCur >> 16;
3935
+ for (let xDstCur = xDstStart, xSrcCur = xSrcStart; xDstCur < xDstEnd && xSrcCur < xSrcEnd; ++xDstCur, xSrcCur += xSrcStep) {
3936
+ const xSrcCurI = xSrcCur >> 16;
3937
+ const cSrc = getPixel(src, xSrcCurI, ySrcCurI);
3938
+ if (!transparent || cSrc) {
3939
+ setPixel(dst, xDstCur, yDstCur, cSrc);
3940
+ }
3941
+ }
3942
+ }
3943
+ }
3944
+ ImageMethods.blit = blit;
3907
3945
  })(ImageMethods = pxsim.ImageMethods || (pxsim.ImageMethods = {}));
3908
3946
  })(pxsim || (pxsim = {}));
3909
3947
  (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 {