pxt-common-packages 10.4.9 → 11.0.1

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.
@@ -938,9 +938,15 @@ declare namespace pxsim.input {
938
938
  }
939
939
  declare namespace pxsim {
940
940
  interface MicrophoneBoard {
941
- microphoneState: AnalogSensorState;
941
+ microphoneState: MicrophoneState;
942
942
  }
943
- function microphoneState(): AnalogSensorState;
943
+ class MicrophoneState extends AnalogSensorState {
944
+ onSoundRegistered: boolean;
945
+ soundLevelRequested: boolean;
946
+ private pingUsed;
947
+ pingSoundLevel: () => void;
948
+ }
949
+ function microphoneState(): MicrophoneState;
944
950
  }
945
951
  declare namespace pxsim.music {
946
952
  function playInstructions(b: RefBuffer): Promise<void>;
@@ -3181,6 +3181,27 @@ var pxsim;
3181
3181
  })(pxsim || (pxsim = {}));
3182
3182
  var pxsim;
3183
3183
  (function (pxsim) {
3184
+ class MicrophoneState extends pxsim.AnalogSensorState {
3185
+ constructor() {
3186
+ super(...arguments);
3187
+ this.onSoundRegistered = false;
3188
+ this.soundLevelRequested = false;
3189
+ this.pingSoundLevel = () => {
3190
+ if (this.onSoundRegistered) {
3191
+ return;
3192
+ }
3193
+ this.soundLevelRequested = true;
3194
+ pxsim.runtime.queueDisplayUpdate();
3195
+ clearTimeout(this.pingUsed);
3196
+ this.pingUsed = setTimeout(() => {
3197
+ this.soundLevelRequested = false;
3198
+ pxsim.runtime.queueDisplayUpdate();
3199
+ this.pingUsed = undefined;
3200
+ }, 100);
3201
+ };
3202
+ }
3203
+ }
3204
+ pxsim.MicrophoneState = MicrophoneState;
3184
3205
  function microphoneState() {
3185
3206
  return pxsim.board().microphoneState;
3186
3207
  }
@@ -1,6 +1,27 @@
1
1
  namespace pxsim {
2
2
  export interface MicrophoneBoard {
3
- microphoneState: AnalogSensorState;
3
+ microphoneState: MicrophoneState;
4
+ }
5
+
6
+ export class MicrophoneState extends AnalogSensorState {
7
+ public onSoundRegistered: boolean = false;
8
+ public soundLevelRequested: boolean = false;
9
+ private pingUsed: ReturnType<typeof setTimeout>;
10
+
11
+ public pingSoundLevel = () => {
12
+ if (this.onSoundRegistered) {
13
+ return;
14
+ }
15
+ this.soundLevelRequested = true;
16
+ runtime.queueDisplayUpdate();
17
+ clearTimeout(this.pingUsed);
18
+ this.pingUsed = setTimeout(() => {
19
+ this.soundLevelRequested = false;
20
+ runtime.queueDisplayUpdate();
21
+ this.pingUsed = undefined;
22
+ }, 100);
23
+ }
24
+
4
25
  }
5
26
 
6
27
  export function microphoneState() {
@@ -395,7 +395,7 @@ namespace radio {
395
395
  function getMaxStringLength(packetType: number) {
396
396
  switch (packetType) {
397
397
  case PACKET_TYPE_STRING:
398
- return MAX_PAYLOAD_LENGTH - 2;
398
+ return MAX_PAYLOAD_LENGTH - 1;
399
399
  case PACKET_TYPE_VALUE:
400
400
  case PACKET_TYPE_DOUBLE_VALUE:
401
401
  return MAX_FIELD_DOUBLE_NAME_LENGTH;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pxt-common-packages",
3
- "version": "10.4.9",
3
+ "version": "11.0.1",
4
4
  "description": "Microsoft MakeCode (PXT) common packages",
5
5
  "keywords": [
6
6
  "MakeCode",