pxt-common-packages 10.3.3 → 10.3.5

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 (42) hide show
  1. package/built/common-sim.d.ts +12 -0
  2. package/built/common-sim.js +24 -0
  3. package/libs/azureiot/built/debug/binary.js +461 -461
  4. package/libs/color/built/debug/binary.js +8 -8
  5. package/libs/color-sensor/built/debug/binary.js +8 -8
  6. package/libs/controller/built/debug/binary.js +6980 -6980
  7. package/libs/controller---none/built/debug/binary.js +6960 -6960
  8. package/libs/datalogger/built/debug/binary.js +63 -63
  9. package/libs/edge-connector/built/debug/binary.js +8 -8
  10. package/libs/esp32/built/debug/binary.js +462 -462
  11. package/libs/game/built/debug/binary.js +6895 -6895
  12. package/libs/game/multiplayer.cpp +3 -0
  13. package/libs/game/multiplayer.ts +45 -0
  14. package/libs/game/sim/multiplayer.ts +32 -0
  15. package/libs/lcd/built/debug/binary.js +8 -8
  16. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  17. package/libs/lora/built/debug/binary.js +8 -8
  18. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  19. package/libs/mqtt/built/debug/binary.js +176 -176
  20. package/libs/multiplayer/README.md +4 -0
  21. package/libs/multiplayer/docs/.gitkeep +0 -0
  22. package/libs/multiplayer/fieldEditors.ts +23 -0
  23. package/libs/multiplayer/images.ts +303 -0
  24. package/libs/multiplayer/mp.ts +643 -0
  25. package/libs/multiplayer/pxt.json +19 -0
  26. package/libs/multiplayer/stateKind.ts +14 -0
  27. package/libs/multiplayer/targetoverrides.ts +1 -0
  28. package/libs/multiplayer/test.ts +0 -0
  29. package/libs/net/built/debug/binary.js +176 -176
  30. package/libs/net-game/built/debug/binary.js +8488 -8488
  31. package/libs/palette/built/debug/binary.js +6898 -6898
  32. package/libs/pixel/built/debug/binary.js +8 -8
  33. package/libs/power/built/debug/binary.js +8 -8
  34. package/libs/proximity/built/debug/binary.js +8 -8
  35. package/libs/radio/built/debug/binary.js +8 -8
  36. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  37. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  38. package/libs/screen/built/debug/binary.js +50 -50
  39. package/libs/servo/built/debug/binary.js +8 -8
  40. package/libs/sprite-scaling/built/debug/binary.js +6898 -6898
  41. package/libs/storyboard/built/debug/binary.js +6898 -6898
  42. package/package.json +1 -1
@@ -4,6 +4,9 @@ namespace multiplayer {
4
4
  //%
5
5
  void postImage(Image_ im) {
6
6
  }
7
+ //%
8
+ void postIcon(int type, int icon, Image_ im) {
9
+ }
7
10
 
8
11
  //%
9
12
  void setOrigin(String origin) {
@@ -1,10 +1,18 @@
1
1
  namespace multiplayer {
2
+ enum IconType {
3
+ Player = 0,
4
+ Reaction = 1,
5
+ }
6
+
2
7
  //% shim=multiplayer::getCurrentImage
3
8
  declare function getCurrentImage(): Image;
4
9
 
5
10
  //% shim=multiplayer::postImage
6
11
  declare function postImage(im: Image): void;
7
12
 
13
+ //% shim=multiplayer::postIcon
14
+ declare function postIcon(type: IconType, slot: number, im: Image): void;
15
+
8
16
  //% shim=multiplayer::setOrigin
9
17
  declare function setOrigin(origin: string): void;
10
18
 
@@ -34,4 +42,41 @@ namespace multiplayer {
34
42
  })
35
43
  }
36
44
  }
45
+
46
+ export function postPresenceIcon(slot: number, im: Image, implicit?: boolean) {
47
+ initIconState();
48
+ if (slot < 1 || slot > 4)
49
+ return;
50
+
51
+ const presenceSetExplicitly = explicitlySetIcons[IconType.Player];
52
+ if (implicit && presenceSetExplicitly[slot])
53
+ return;
54
+ if (!implicit)
55
+ presenceSetExplicitly[slot] = true;
56
+
57
+ postIcon(IconType.Player, slot, im);
58
+ }
59
+
60
+ export function postReactionIcon(slot: number, im: Image, implicit?: boolean) {
61
+ initIconState();
62
+ if (slot < 1 || slot > 6)
63
+ return;
64
+
65
+ const reactionsSetExplicitly = explicitlySetIcons[IconType.Reaction];
66
+ if (implicit && reactionsSetExplicitly[slot])
67
+ return;
68
+ if (!implicit)
69
+ reactionsSetExplicitly[slot] = true;
70
+
71
+ postIcon(IconType.Reaction, slot, im);
72
+ }
73
+
74
+ let explicitlySetIcons: boolean[][];
75
+ function initIconState() {
76
+ if (explicitlySetIcons)
77
+ return;
78
+ explicitlySetIcons = [];
79
+ explicitlySetIcons[IconType.Player] = [];
80
+ explicitlySetIcons[IconType.Reaction] = [];
81
+ }
37
82
  }
@@ -16,6 +16,25 @@ namespace pxsim.multiplayer {
16
16
  } as pxsim.MultiplayerImageMessage);
17
17
  }
18
18
 
19
+ export function postIcon(iconType: IconType, slot: number, im: pxsim.RefImage) {
20
+ if (getMultiplayerState().origin !== "server")
21
+ return;
22
+ if (im._width * im._height > 64 * 64) {
23
+ // setting 64x64 as max size for icon for now
24
+ return;
25
+ }
26
+ const asBuf = pxsim.image.toBuffer(im);
27
+ const sb = board() as ScreenBoard;
28
+ const screenState = sb && sb.screenState;
29
+ getMultiplayerState().send({
30
+ content: "Icon",
31
+ slot: slot,
32
+ icon: asBuf,
33
+ iconType: iconType,
34
+ palette: screenState.paletteToUint8Array(),
35
+ } as pxsim.MultiplayerIconMessage);
36
+ }
37
+
19
38
 
20
39
  export function getCurrentImage(): pxsim.RefImage {
21
40
  return getMultiplayerState().backgroundImage;
@@ -56,6 +75,19 @@ namespace pxsim {
56
75
  palette: Uint8Array;
57
76
  }
58
77
 
78
+ export enum IconType {
79
+ Player = 0,
80
+ Reaction = 1,
81
+ }
82
+ export interface MultiplayerIconMessage extends SimulatorMultiplayerMessage {
83
+ content: "Icon";
84
+ icon: RefBuffer;
85
+ slot: number;
86
+ iconType: IconType;
87
+ // 48bytes, [r0,g0,b0,r1,g1,b1,...]
88
+ palette: Uint8Array;
89
+ }
90
+
59
91
  export interface MultiplayerButtonEvent extends SimulatorMultiplayerMessage {
60
92
  content: "Button";
61
93
  button: number; // pxsim.Key.A, ...
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48572(s) {
59
+ function _main___P48577(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___48815 = (undefined);
70
- globals._pollEventQueue___48828 = (undefined);
69
+ globals._intervals___48820 = (undefined);
70
+ globals._pollEventQueue___48833 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48572.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48572.continuations = [ ]
75
+ _main___P48577.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48577.continuations = [ ]
77
77
 
78
- function _main___P48572_mk(s) {
78
+ function _main___P48577_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48572, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48577, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P48572_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48572
91
+ return _main___P48577
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P98048(s) {
59
+ function _main___P98063(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___98291 = (undefined);
70
- globals._pollEventQueue___98304 = (undefined);
69
+ globals._intervals___98306 = (undefined);
70
+ globals._pollEventQueue___98319 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P98048.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P98048.continuations = [ ]
75
+ _main___P98063.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P98063.continuations = [ ]
77
77
 
78
- function _main___P98048_mk(s) {
78
+ function _main___P98063_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P98048, depth: s.depth + 1,
81
+ parent: s, fn: _main___P98063, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P98048_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P98048
91
+ return _main___P98063
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P59874(s) {
59
+ function _main___P59879(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___60117 = (undefined);
70
- globals._pollEventQueue___60130 = (undefined);
69
+ globals._intervals___60122 = (undefined);
70
+ globals._pollEventQueue___60135 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P59874.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P59874.continuations = [ ]
75
+ _main___P59879.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P59879.continuations = [ ]
77
77
 
78
- function _main___P59874_mk(s) {
78
+ function _main___P59879_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P59874, depth: s.depth + 1,
81
+ parent: s, fn: _main___P59879, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P59874_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P59874
91
+ return _main___P59879
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P190524(s) {
59
+ function _main___P190559(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___190767 = (undefined);
70
- globals._pollEventQueue___190780 = (undefined);
69
+ globals._intervals___190802 = (undefined);
70
+ globals._pollEventQueue___190815 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P190524.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P190524.continuations = [ ]
75
+ _main___P190559.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P190559.continuations = [ ]
77
77
 
78
- function _main___P190524_mk(s) {
78
+ function _main___P190559_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P190524, depth: s.depth + 1,
81
+ parent: s, fn: _main___P190559, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P190524_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P190524
91
+ return _main___P190559
92
92
  })