pxt-common-packages 9.5.2 → 9.5.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.
- package/built/common-sim.d.ts +5 -0
- package/built/common-sim.js +52 -22
- package/libs/controller/built/debug/binary.js +9 -9
- package/libs/controller---none/built/debug/binary.js +9 -9
- package/libs/game/built/debug/binary.js +9 -9
- package/libs/game/docs/reference/sprites/sprite/follow.md +66 -0
- package/libs/game/docs/reference/sprites/sprite/set-bounce-on-wall.md +2 -2
- package/libs/game/scenes.ts +0 -1
- package/libs/game/sprite.ts +1 -0
- package/libs/game/tilemap.ts +6 -5
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/net-game/built/debug/binary.js +9 -9
- package/libs/palette/built/debug/binary.js +9 -9
- package/libs/radio/_locales/radio-jsdoc-strings.json +2 -0
- package/libs/radio/_locales/radio-strings.json +4 -1
- package/libs/radio/radio.cpp +56 -3
- package/libs/radio/radio.ts +13 -2
- package/libs/radio/shims.d.ts +16 -1
- package/libs/radio/sim/radio.ts +18 -5
- package/libs/radio/sim/state.ts +37 -17
- package/libs/radio-broadcast/_locales/radio-broadcast-strings.json +2 -1
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/radio-broadcast.ts +2 -0
- package/libs/sprite-scaling/built/debug/binary.js +6782 -6782
- package/libs/storyboard/built/debug/binary.js +9 -9
- package/package.json +1 -1
|
@@ -27260,7 +27260,7 @@ switch (step) {
|
|
|
27260
27260
|
return leave(s, r0)
|
|
27261
27261
|
default: oops()
|
|
27262
27262
|
} } }
|
|
27263
|
-
tiles_TileMap_isOnWall__P171489.info = {"start":
|
|
27263
|
+
tiles_TileMap_isOnWall__P171489.info = {"start":16837,"length":627,"line":534,"column":8,"endLine":551,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
|
|
27264
27264
|
|
|
27265
27265
|
function tiles_TileMap_isOnWall__P171489_mk(s) {
|
|
27266
27266
|
checkStack(s.depth);
|
|
@@ -27350,7 +27350,7 @@ switch (step) {
|
|
|
27350
27350
|
return leave(s, r0)
|
|
27351
27351
|
default: oops()
|
|
27352
27352
|
} } }
|
|
27353
|
-
tiles_TileMap_isObstacle__P171487.info = {"start":
|
|
27353
|
+
tiles_TileMap_isObstacle__P171487.info = {"start":16196,"length":211,"line":515,"column":8,"endLine":520,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
|
|
27354
27354
|
|
|
27355
27355
|
function tiles_TileMap_isObstacle__P171487_mk(s) {
|
|
27356
27356
|
checkStack(s.depth);
|
|
@@ -29004,7 +29004,7 @@ switch (step) {
|
|
|
29004
29004
|
return leave(s, r0)
|
|
29005
29005
|
default: oops()
|
|
29006
29006
|
} } }
|
|
29007
|
-
tiles_getTileImage__P171501.info = {"start":
|
|
29007
|
+
tiles_getTileImage__P171501.info = {"start":21828,"length":207,"line":673,"column":4,"endLine":677,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
|
|
29008
29008
|
|
|
29009
29009
|
function tiles_getTileImage__P171501_mk(s) {
|
|
29010
29010
|
checkStack(s.depth);
|
|
@@ -29145,7 +29145,7 @@ switch (step) {
|
|
|
29145
29145
|
return leave(s, r0)
|
|
29146
29146
|
default: oops()
|
|
29147
29147
|
} } }
|
|
29148
|
-
tiles_TileMap_getTileIndex__P171479.info = {"start":
|
|
29148
|
+
tiles_TileMap_getTileIndex__P171479.info = {"start":11155,"length":105,"line":384,"column":8,"endLine":386,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
|
|
29149
29149
|
|
|
29150
29150
|
function tiles_TileMap_getTileIndex__P171479_mk(s) {
|
|
29151
29151
|
checkStack(s.depth);
|
|
@@ -29265,7 +29265,7 @@ switch (step) {
|
|
|
29265
29265
|
return leave(s, r0)
|
|
29266
29266
|
default: oops()
|
|
29267
29267
|
} } }
|
|
29268
|
-
tiles_TileMap_getTileImage__P171490.info = {"start":
|
|
29268
|
+
tiles_TileMap_getTileImage__P171490.info = {"start":17474,"length":96,"line":553,"column":8,"endLine":555,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
|
|
29269
29269
|
|
|
29270
29270
|
function tiles_TileMap_getTileImage__P171490_mk(s) {
|
|
29271
29271
|
checkStack(s.depth);
|
|
@@ -29515,7 +29515,7 @@ switch (step) {
|
|
|
29515
29515
|
return leave(s, r0)
|
|
29516
29516
|
default: oops()
|
|
29517
29517
|
} } }
|
|
29518
|
-
tiles_TileMap_getTile__P171478.info = {"start":
|
|
29518
|
+
tiles_TileMap_getTile__P171478.info = {"start":11034,"length":111,"line":380,"column":8,"endLine":382,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
|
|
29519
29519
|
|
|
29520
29520
|
function tiles_TileMap_getTile__P171478_mk(s) {
|
|
29521
29521
|
checkStack(s.depth);
|
|
@@ -30139,7 +30139,7 @@ switch (step) {
|
|
|
30139
30139
|
return leave(s, r0)
|
|
30140
30140
|
default: oops()
|
|
30141
30141
|
} } }
|
|
30142
|
-
tiles_TileMap_getObstacle__P171488.info = {"start":
|
|
30142
|
+
tiles_TileMap_getObstacle__P171488.info = {"start":16417,"length":410,"line":522,"column":8,"endLine":532,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
|
|
30143
30143
|
|
|
30144
30144
|
function tiles_TileMap_getObstacle__P171488_mk(s) {
|
|
30145
30145
|
checkStack(s.depth);
|
|
@@ -35027,7 +35027,7 @@ switch (step) {
|
|
|
35027
35027
|
return leave(s, r0)
|
|
35028
35028
|
default: oops()
|
|
35029
35029
|
} } }
|
|
35030
|
-
Sprite_toString__P171170.info = {"start":
|
|
35030
|
+
Sprite_toString__P171170.info = {"start":37718,"length":93,"line":1170,"column":4,"endLine":1172,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
|
|
35031
35031
|
|
|
35032
35032
|
function Sprite_toString__P171170_mk(s) {
|
|
35033
35033
|
checkStack(s.depth);
|
|
@@ -36461,7 +36461,7 @@ switch (step) {
|
|
|
36461
36461
|
return leave(s, r0)
|
|
36462
36462
|
default: oops()
|
|
36463
36463
|
} } }
|
|
36464
|
-
tiles_TileMap_draw__P171486.info = {"start":
|
|
36464
|
+
tiles_TileMap_draw__P171486.info = {"start":13962,"length":2224,"line":458,"column":8,"endLine":513,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
|
|
36465
36465
|
|
|
36466
36466
|
function tiles_TileMap_draw__P171486_mk(s) {
|
|
36467
36467
|
checkStack(s.depth);
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
"radio": "Communicate data using radio packets",
|
|
3
3
|
"radio._packetProperty": "Gets a packet property.",
|
|
4
4
|
"radio._packetProperty|param|type": "the packet property type, eg: PacketProperty.time",
|
|
5
|
+
"radio.off": "Disables the radio for use as a multipoint sender/receiver.\nDisabling radio will help conserve battery power when it is not in use.",
|
|
6
|
+
"radio.on": "Initialises the radio for use as a multipoint sender/receiver\nOnly useful when the radio.off() is used beforehand.",
|
|
5
7
|
"radio.onDataReceived": "Used internally by the library.",
|
|
6
8
|
"radio.onReceivedBuffer": "Registers code to run when the radio receives a buffer.",
|
|
7
9
|
"radio.onReceivedNumber": "Registers code to run when the radio receives a number.",
|
|
@@ -18,5 +18,8 @@
|
|
|
18
18
|
"radio.setTransmitPower|block": "radio set transmit power %power",
|
|
19
19
|
"radio.setTransmitSerialNumber|block": "radio set transmit serial number %transmit",
|
|
20
20
|
"radio|block": "radio",
|
|
21
|
-
"{id:category}Radio": "Radio"
|
|
21
|
+
"{id:category}Radio": "Radio",
|
|
22
|
+
"{id:group}Group": "Group",
|
|
23
|
+
"{id:group}Receive": "Receive",
|
|
24
|
+
"{id:group}Send": "Send"
|
|
22
25
|
}
|
package/libs/radio/radio.cpp
CHANGED
|
@@ -73,28 +73,80 @@ CODAL_RADIO* getRadio() {
|
|
|
73
73
|
#endif // #else
|
|
74
74
|
|
|
75
75
|
bool radioEnabled = false;
|
|
76
|
+
bool init = false;
|
|
76
77
|
int radioEnable() {
|
|
77
78
|
#ifdef CODAL_RADIO
|
|
78
79
|
auto radio = getRadio();
|
|
79
80
|
if (NULL == radio)
|
|
80
81
|
return DEVICE_NOT_SUPPORTED;
|
|
81
82
|
|
|
83
|
+
if (init && !radioEnabled) {
|
|
84
|
+
//If radio was explicitly disabled from a call to off API
|
|
85
|
+
//We don't want to enable it here. User needs to call on API first.
|
|
86
|
+
return DEVICE_NOT_SUPPORTED;
|
|
87
|
+
}
|
|
88
|
+
|
|
82
89
|
int r = radio->enable();
|
|
83
90
|
if (r != DEVICE_OK) {
|
|
84
91
|
target_panic(43);
|
|
85
92
|
return r;
|
|
86
93
|
}
|
|
87
|
-
if (!
|
|
88
|
-
getRadio()->setGroup(pxt::programHash()
|
|
94
|
+
if (!init) {
|
|
95
|
+
getRadio()->setGroup(0); //Default group zero. This used to be pxt::programHash()
|
|
89
96
|
getRadio()->setTransmitPower(6); // start with high power by default
|
|
90
|
-
|
|
97
|
+
init = true;
|
|
91
98
|
}
|
|
99
|
+
radioEnabled = true;
|
|
92
100
|
return r;
|
|
93
101
|
#else
|
|
94
102
|
return DEVICE_NOT_SUPPORTED;
|
|
95
103
|
#endif
|
|
96
104
|
}
|
|
97
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Disables the radio for use as a multipoint sender/receiver.
|
|
108
|
+
* Disabling radio will help conserve battery power when it is not in use.
|
|
109
|
+
*/
|
|
110
|
+
//% help=radio/off
|
|
111
|
+
void off() {
|
|
112
|
+
#ifdef CODAL_RADIO
|
|
113
|
+
auto radio = getRadio();
|
|
114
|
+
if (NULL == radio)
|
|
115
|
+
return;
|
|
116
|
+
|
|
117
|
+
int r = radio->disable();
|
|
118
|
+
if (r != DEVICE_OK) {
|
|
119
|
+
target_panic(43);
|
|
120
|
+
} else {
|
|
121
|
+
radioEnabled = false;
|
|
122
|
+
}
|
|
123
|
+
#else
|
|
124
|
+
return;
|
|
125
|
+
#endif
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Initialises the radio for use as a multipoint sender/receiver
|
|
130
|
+
* Only useful when the radio.off() is used beforehand.
|
|
131
|
+
*/
|
|
132
|
+
//% help=radio/on
|
|
133
|
+
void on() {
|
|
134
|
+
#ifdef CODAL_RADIO
|
|
135
|
+
auto radio = getRadio();
|
|
136
|
+
if (NULL == radio)
|
|
137
|
+
return;
|
|
138
|
+
|
|
139
|
+
int r = radio->enable();
|
|
140
|
+
if (r != DEVICE_OK) {
|
|
141
|
+
target_panic(43);
|
|
142
|
+
} else {
|
|
143
|
+
radioEnabled = true;
|
|
144
|
+
}
|
|
145
|
+
#else
|
|
146
|
+
return;
|
|
147
|
+
#endif
|
|
148
|
+
}
|
|
149
|
+
|
|
98
150
|
/**
|
|
99
151
|
* Sends an event over radio to neigboring devices
|
|
100
152
|
*/
|
|
@@ -185,6 +237,7 @@ CODAL_RADIO* getRadio() {
|
|
|
185
237
|
//% weight=100
|
|
186
238
|
//% blockId=radio_set_group block="radio set group %ID"
|
|
187
239
|
//% id.min=0 id.max=255
|
|
240
|
+
//% group="Group"
|
|
188
241
|
void setGroup(int id) {
|
|
189
242
|
#ifdef CODAL_RADIO
|
|
190
243
|
if (radioEnable() != DEVICE_OK) return;
|
package/libs/radio/radio.ts
CHANGED
|
@@ -14,7 +14,7 @@ enum RadioPacketProperty {
|
|
|
14
14
|
/**
|
|
15
15
|
* Communicate data using radio packets
|
|
16
16
|
*/
|
|
17
|
-
//% color=#E3008C weight=96 icon="\uf012"
|
|
17
|
+
//% color=#E3008C weight=96 icon="\uf012" groups='["Group", "Broadcast", "Send", "Receive"]'
|
|
18
18
|
namespace radio {
|
|
19
19
|
|
|
20
20
|
// keep in sync with CODAL
|
|
@@ -95,6 +95,8 @@ namespace radio {
|
|
|
95
95
|
//% help=radio/on-received-number
|
|
96
96
|
//% blockId=radio_on_number_drag block="on radio received" blockGap=16
|
|
97
97
|
//% useLoc="radio.onDataPacketReceived" draggableParameters=reporter
|
|
98
|
+
//% group="Receive"
|
|
99
|
+
//% weight=20
|
|
98
100
|
export function onReceivedNumber(cb: (receivedNumber: number) => void) {
|
|
99
101
|
init();
|
|
100
102
|
onReceivedNumberHandler = cb;
|
|
@@ -106,6 +108,8 @@ namespace radio {
|
|
|
106
108
|
//% help=radio/on-received-value
|
|
107
109
|
//% blockId=radio_on_value_drag block="on radio received" blockGap=16
|
|
108
110
|
//% useLoc="radio.onDataPacketReceived" draggableParameters=reporter
|
|
111
|
+
//% group="Receive"
|
|
112
|
+
//% weight=19
|
|
109
113
|
export function onReceivedValue(cb: (name: string, value: number) => void) {
|
|
110
114
|
init();
|
|
111
115
|
onReceivedValueHandler = cb;
|
|
@@ -117,6 +121,8 @@ namespace radio {
|
|
|
117
121
|
//% help=radio/on-received-string
|
|
118
122
|
//% blockId=radio_on_string_drag block="on radio received" blockGap=16
|
|
119
123
|
//% useLoc="radio.onDataPacketReceived" draggableParameters=reporter
|
|
124
|
+
//% group="Receive"
|
|
125
|
+
//% weight=18
|
|
120
126
|
export function onReceivedString(cb: (receivedString: string) => void) {
|
|
121
127
|
init();
|
|
122
128
|
onReceivedStringHandler = cb;
|
|
@@ -138,8 +144,10 @@ namespace radio {
|
|
|
138
144
|
* @param type the type of property to retrieve from the last packet
|
|
139
145
|
*/
|
|
140
146
|
//% help=radio/received-packet
|
|
141
|
-
//%
|
|
147
|
+
//% blockGap=8
|
|
142
148
|
//% blockId=radio_received_packet block="received packet %type=radio_packet_property" blockGap=16
|
|
149
|
+
//% group="Receive"
|
|
150
|
+
//% weight=16
|
|
143
151
|
export function receivedPacket(type: number) {
|
|
144
152
|
if (lastPacket) {
|
|
145
153
|
switch (type) {
|
|
@@ -272,6 +280,7 @@ namespace radio {
|
|
|
272
280
|
//% help=radio/send-number
|
|
273
281
|
//% weight=60
|
|
274
282
|
//% blockId=radio_datagram_send block="radio send number %value" blockGap=8
|
|
283
|
+
//% group="Send"
|
|
275
284
|
export function sendNumber(value: number) {
|
|
276
285
|
let packet: RadioPacket;
|
|
277
286
|
|
|
@@ -296,6 +305,7 @@ namespace radio {
|
|
|
296
305
|
//% help=radio/send-value
|
|
297
306
|
//% weight=59
|
|
298
307
|
//% blockId=radio_datagram_send_value block="radio send|value %name|= %value" blockGap=8
|
|
308
|
+
//% group="Send"
|
|
299
309
|
export function sendValue(name: string, value: number) {
|
|
300
310
|
let packet: RadioPacket;
|
|
301
311
|
|
|
@@ -319,6 +329,7 @@ namespace radio {
|
|
|
319
329
|
//% weight=58
|
|
320
330
|
//% blockId=radio_datagram_send_string block="radio send string %msg"
|
|
321
331
|
//% msg.shadowOptions.toString=true
|
|
332
|
+
//% group="Send"
|
|
322
333
|
export function sendString(value: string) {
|
|
323
334
|
const packet = RadioPacket.mkPacket(PACKET_TYPE_STRING);
|
|
324
335
|
packet.stringPayload = value;
|
package/libs/radio/shims.d.ts
CHANGED
|
@@ -5,6 +5,20 @@
|
|
|
5
5
|
//% color=#E3008C weight=96 icon="\uf012"
|
|
6
6
|
declare namespace radio {
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Disables the radio for use as a multipoint sender/receiver.
|
|
10
|
+
* Disabling radio will help conserve battery power when it is not in use.
|
|
11
|
+
*/
|
|
12
|
+
//% help=radio/off shim=radio::off
|
|
13
|
+
function off(): void;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Initialises the radio for use as a multipoint sender/receiver
|
|
17
|
+
* Only useful when the radio.off() is used beforehand.
|
|
18
|
+
*/
|
|
19
|
+
//% help=radio/on shim=radio::on
|
|
20
|
+
function on(): void;
|
|
21
|
+
|
|
8
22
|
/**
|
|
9
23
|
* Sends an event over radio to neigboring devices
|
|
10
24
|
*/
|
|
@@ -44,7 +58,8 @@ declare namespace radio {
|
|
|
44
58
|
//% help=radio/set-group
|
|
45
59
|
//% weight=100
|
|
46
60
|
//% blockId=radio_set_group block="radio set group %ID"
|
|
47
|
-
//% id.min=0 id.max=255
|
|
61
|
+
//% id.min=0 id.max=255
|
|
62
|
+
//% group="Group" shim=radio::setGroup
|
|
48
63
|
function setGroup(id: int32): void;
|
|
49
64
|
|
|
50
65
|
/**
|
package/libs/radio/sim/radio.ts
CHANGED
|
@@ -22,11 +22,13 @@ namespace pxsim.radio {
|
|
|
22
22
|
export function sendRawPacket(buf: RefBuffer) {
|
|
23
23
|
let cb = getResume();
|
|
24
24
|
const state = pxsim.getRadioState();
|
|
25
|
-
state.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (state.enable) {
|
|
26
|
+
state.datagram.send({
|
|
27
|
+
type: 0,
|
|
28
|
+
groupId: state.groupId,
|
|
29
|
+
bufferData: buf.data
|
|
30
|
+
});
|
|
31
|
+
}
|
|
30
32
|
setTimeout(cb, 1);
|
|
31
33
|
}
|
|
32
34
|
|
|
@@ -50,4 +52,15 @@ namespace pxsim.radio {
|
|
|
50
52
|
const state = pxsim.getRadioState();
|
|
51
53
|
state.datagram.onReceived(handler);
|
|
52
54
|
}
|
|
55
|
+
|
|
56
|
+
export function off(){
|
|
57
|
+
const state = pxsim.getRadioState();
|
|
58
|
+
state.off();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function on(){
|
|
62
|
+
const state = pxsim.getRadioState();
|
|
63
|
+
state.on();
|
|
64
|
+
}
|
|
65
|
+
|
|
53
66
|
}
|
package/libs/radio/sim/state.ts
CHANGED
|
@@ -87,13 +87,14 @@ namespace pxsim {
|
|
|
87
87
|
datagram: RadioDatagram;
|
|
88
88
|
groupId: number;
|
|
89
89
|
band: number;
|
|
90
|
+
enable: boolean;
|
|
90
91
|
|
|
91
92
|
constructor(private readonly runtime: Runtime, private readonly board: BaseBoard, dal: RadioDAL) {
|
|
92
93
|
this.datagram = new RadioDatagram(runtime, dal);
|
|
93
94
|
this.power = 6; // default value
|
|
94
95
|
this.groupId = 0;
|
|
95
96
|
this.band = 7; // https://github.com/lancaster-university/microbit-dal/blob/master/inc/core/MicroBitConfig.h#L320
|
|
96
|
-
|
|
97
|
+
this.enable = true;
|
|
97
98
|
this.board.addMessageListener(this.handleMessage.bind(this))
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -105,12 +106,16 @@ namespace pxsim {
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
public setGroup(id: number) {
|
|
108
|
-
this.
|
|
109
|
+
if (this.enable) {
|
|
110
|
+
this.groupId = id & 0xff; // byte only
|
|
111
|
+
}
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
setTransmitPower(power: number) {
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
if (this.enable) {
|
|
116
|
+
power = power | 0;
|
|
117
|
+
this.power = Math.max(0, Math.min(7, power));
|
|
118
|
+
}
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
setTransmitSerialNumber(sn: boolean) {
|
|
@@ -118,25 +123,40 @@ namespace pxsim {
|
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
setFrequencyBand(band: number) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
if (this.enable) {
|
|
127
|
+
band = band | 0;
|
|
128
|
+
if (band < 0 || band > 83) return;
|
|
129
|
+
this.band = band;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
off() {
|
|
134
|
+
this.enable = false;
|
|
124
135
|
}
|
|
125
136
|
|
|
137
|
+
on() {
|
|
138
|
+
this.enable = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
126
141
|
raiseEvent(id: number, eventid: number) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
142
|
+
if (this.enable) {
|
|
143
|
+
Runtime.postMessage(<SimulatorEventBusMessage>{
|
|
144
|
+
type: "eventbus",
|
|
145
|
+
broadcast: true,
|
|
146
|
+
id,
|
|
147
|
+
eventid,
|
|
148
|
+
power: this.power,
|
|
149
|
+
group: this.groupId
|
|
150
|
+
})
|
|
151
|
+
}
|
|
135
152
|
}
|
|
136
153
|
|
|
137
154
|
receivePacket(packet: SimulatorRadioPacketMessage) {
|
|
138
|
-
if (this.
|
|
139
|
-
this.
|
|
155
|
+
if (this.enable) {
|
|
156
|
+
if (this.groupId == packet.payload.groupId) {
|
|
157
|
+
this.datagram.queue(packet)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
140
160
|
}
|
|
141
161
|
}
|
|
142
162
|
}
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P186885(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.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___187128 = (undefined);
|
|
70
|
+
globals._pollEventQueue___187141 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P186885.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"radio-broadcast.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P186885.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P186885_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P186885, 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___P186883_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P186885
|
|
92
92
|
})
|
|
@@ -21,6 +21,7 @@ namespace radio {
|
|
|
21
21
|
//% weight=200
|
|
22
22
|
//% blockGap=8
|
|
23
23
|
//% help=radio/send-message
|
|
24
|
+
//% group="Broadcast"
|
|
24
25
|
export function sendMessage(msg: number): void {
|
|
25
26
|
// 0 is MICROBIT_EVT_ANY, shifting by 1
|
|
26
27
|
radio.raiseEvent(BROADCAST_GENERAL_ID, msg + 1);
|
|
@@ -35,6 +36,7 @@ namespace radio {
|
|
|
35
36
|
//% msg.shadow=radioMessageCode draggableParameters
|
|
36
37
|
//% weight=199
|
|
37
38
|
//% help=radio/on-received-message
|
|
39
|
+
//% group="Broadcast"
|
|
38
40
|
export function onReceivedMessage(msg: number, handler: () => void) {
|
|
39
41
|
control.onEvent(BROADCAST_GENERAL_ID, msg + 1, handler);
|
|
40
42
|
}
|