pxt-common-packages 10.3.12 → 10.3.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.
Files changed (37) hide show
  1. package/built/common-sim.js +4 -2
  2. package/libs/azureiot/built/debug/binary.js +461 -461
  3. package/libs/color/built/debug/binary.js +8 -8
  4. package/libs/color-sensor/built/debug/binary.js +8 -8
  5. package/libs/controller/built/debug/binary.js +8417 -8204
  6. package/libs/controller---none/built/debug/binary.js +8396 -8183
  7. package/libs/datalogger/built/debug/binary.js +63 -63
  8. package/libs/edge-connector/built/debug/binary.js +8 -8
  9. package/libs/esp32/built/debug/binary.js +462 -462
  10. package/libs/game/_locales/game-jsdoc-strings.json +2 -2
  11. package/libs/game/_locales/game-strings.json +1 -1
  12. package/libs/game/built/debug/binary.js +8303 -8090
  13. package/libs/game/controller.ts +24 -0
  14. package/libs/game/game.ts +9 -2
  15. package/libs/game/scene.ts +1 -0
  16. package/libs/game/sim/multiplayer.ts +5 -2
  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/mixer/instrument.ts +7 -0
  22. package/libs/mixer/melody.ts +1 -0
  23. package/libs/mqtt/built/debug/binary.js +176 -176
  24. package/libs/net/built/debug/binary.js +176 -176
  25. package/libs/net-game/built/debug/binary.js +10110 -9897
  26. package/libs/palette/built/debug/binary.js +8302 -8089
  27. package/libs/pixel/built/debug/binary.js +8 -8
  28. package/libs/power/built/debug/binary.js +8 -8
  29. package/libs/proximity/built/debug/binary.js +8 -8
  30. package/libs/radio/built/debug/binary.js +8 -8
  31. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  32. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  33. package/libs/screen/built/debug/binary.js +50 -50
  34. package/libs/servo/built/debug/binary.js +8 -8
  35. package/libs/sprite-scaling/built/debug/binary.js +8302 -8089
  36. package/libs/storyboard/built/debug/binary.js +8302 -8089
  37. package/package.json +1 -1
@@ -13,6 +13,30 @@ enum ControllerEvent {
13
13
  //% blockGap=8
14
14
  namespace controller {
15
15
  let _players: Controller[];
16
+ game.addScenePopHandler(() => {
17
+ const stateWhenPushed = game.currentScene().controllerConnectionState;
18
+ if (!stateWhenPushed)
19
+ return;
20
+ for (let i = 0; i < stateWhenPushed.length; i++) {
21
+ const p = _players[i];
22
+ if (p && (!!stateWhenPushed[i] != !!p.connected)) {
23
+ // connection state changed while in another scene; raise the event.
24
+ control.raiseEvent(
25
+ p.id,
26
+ p.connected ? ControllerEvent.Connected : ControllerEvent.Disconnected
27
+ );
28
+ }
29
+ }
30
+
31
+ })
32
+ game.addScenePushHandler(oldScene => {
33
+ oldScene.controllerConnectionState = [];
34
+ for (let i = 0; i < _players.length; i++) {
35
+ if (_players[i]) {
36
+ oldScene.controllerConnectionState[i] = _players[i].connected;
37
+ }
38
+ }
39
+ })
16
40
 
17
41
  function addController(ctrl: Controller) {
18
42
  if (!_players) {
package/libs/game/game.ts CHANGED
@@ -248,7 +248,7 @@ namespace game {
248
248
  * @param win whether the sound should play on a win (true) or lose (false)
249
249
  * @param effect
250
250
  */
251
- //% blockId=game_setgameoversound
251
+ //% blockId=game_setgameoverplayable
252
252
  //% block="use $sound looping $looping for $win"
253
253
  //% sound.shadow=music_melody_playable
254
254
  //% sound.defl=music.powerUp
@@ -260,12 +260,19 @@ namespace game {
260
260
  //% weight=80
261
261
  //% blockGap=8
262
262
  //% help=game/set-game-over-sound
263
- export function setGameOverSound(win: boolean, sound: music.Playable, looping: boolean) {
263
+ export function setGameOverPlayable(win: boolean, sound: music.Playable, looping: boolean) {
264
264
  init();
265
265
  const goc = game.gameOverConfig();
266
266
  goc.setSound(win, sound, looping, true);
267
267
  }
268
268
 
269
+ // Legacy api. Older extensions may still use this.
270
+ export function setGameOverSound(win: boolean, sound: music.Melody) {
271
+ init();
272
+ const goc = game.gameOverConfig();
273
+ goc.setSound(win, music.melodyPlayable(sound), false, true);
274
+ }
275
+
269
276
  /**
270
277
  * Set the message that displays when the game is over
271
278
  * @param win whether the message should show on a win (true) or lose (false)
@@ -94,6 +94,7 @@ namespace scene {
94
94
  gameForeverHandlers: GameForeverHandler[];
95
95
  particleSources: particles.ParticleSource[];
96
96
  controlledSprites: controller.ControlledSprite[][];
97
+ controllerConnectionState: boolean[]
97
98
  followingSprites: sprites.FollowingSprite[];
98
99
  buttonEventHandlers: controller.ButtonEventHandlerState[];
99
100
 
@@ -17,11 +17,14 @@ namespace pxsim.multiplayer {
17
17
  }
18
18
 
19
19
  export function postIcon(iconType: IconType, slot: number, im: pxsim.RefImage) {
20
- if (im._width * im._height > 64 * 64) {
20
+ if (im && (im._width * im._height > 64 * 64)) {
21
21
  // setting 64x64 as max size for icon for now
22
22
  return;
23
23
  }
24
- const asBuf = pxsim.image.toBuffer(im);
24
+
25
+ // treat empty icon as undefined
26
+ const asBuf = (im && im.data.some(pixel => pixel != 0))
27
+ ? pxsim.image.toBuffer(im) : undefined;
25
28
  const sb = board() as ScreenBoard;
26
29
  const screenState = sb && sb.screenState;
27
30
  getMultiplayerState().send({
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48755(s) {
59
+ function _main___P48823(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___48998 = (undefined);
70
- globals._pollEventQueue___49011 = (undefined);
69
+ globals._intervals___49066 = (undefined);
70
+ globals._pollEventQueue___49079 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48755.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48755.continuations = [ ]
75
+ _main___P48823.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48823.continuations = [ ]
77
77
 
78
- function _main___P48755_mk(s) {
78
+ function _main___P48823_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48755, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48823, 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___P48755_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48755
91
+ return _main___P48823
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___P98597(s) {
59
+ function _main___P98801(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___98840 = (undefined);
70
- globals._pollEventQueue___98853 = (undefined);
69
+ globals._intervals___99044 = (undefined);
70
+ globals._pollEventQueue___99057 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P98597.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P98597.continuations = [ ]
75
+ _main___P98801.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P98801.continuations = [ ]
77
77
 
78
- function _main___P98597_mk(s) {
78
+ function _main___P98801_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P98597, depth: s.depth + 1,
81
+ parent: s, fn: _main___P98801, 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___P98597_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P98597
91
+ return _main___P98801
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___P60057(s) {
59
+ function _main___P60125(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___60300 = (undefined);
70
- globals._pollEventQueue___60313 = (undefined);
69
+ globals._intervals___60368 = (undefined);
70
+ globals._pollEventQueue___60381 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P60057.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P60057.continuations = [ ]
75
+ _main___P60125.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P60125.continuations = [ ]
77
77
 
78
- function _main___P60057_mk(s) {
78
+ function _main___P60125_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P60057, depth: s.depth + 1,
81
+ parent: s, fn: _main___P60125, 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___P60057_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P60057
91
+ return _main___P60125
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___P191805(s) {
59
+ function _main___P192281(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___192048 = (undefined);
70
- globals._pollEventQueue___192061 = (undefined);
69
+ globals._intervals___192524 = (undefined);
70
+ globals._pollEventQueue___192537 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P191805.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P191805.continuations = [ ]
75
+ _main___P192281.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P192281.continuations = [ ]
77
77
 
78
- function _main___P191805_mk(s) {
78
+ function _main___P192281_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P191805, depth: s.depth + 1,
81
+ parent: s, fn: _main___P192281, 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___P191805_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P191805
91
+ return _main___P192281
92
92
  })
@@ -811,4 +811,11 @@ namespace music.sequencer {
811
811
  // Use cosine to smooth out the value somewhat
812
812
  return Math.cos(((time / 1000) * lfo.frequency) * 2 * Math.PI) * lfo.amplitude
813
813
  }
814
+
815
+ export function _stopAllSongs() {
816
+ if (currentSequencer) {
817
+ currentSequencer.stop();
818
+ currentSequencer = undefined;
819
+ }
820
+ }
814
821
  }
@@ -184,6 +184,7 @@ namespace music {
184
184
  Melody.stopAll();
185
185
  stopPlaying();
186
186
  _stopPlayables();
187
+ sequencer._stopAllSongs();
187
188
  }
188
189
 
189
190
  //% fixedInstances