Compare commits

..

11 Commits

Author SHA1 Message Date
7a9c2e0fe4 0.2.116 2016-05-12 22:23:46 -07:00
9656c1159a Bump pxt-core to 0.2.125 2016-05-12 22:23:45 -07:00
801117d6b0 remove head from simulator 2016-05-12 22:23:23 -07:00
c084bff334 remove logo in simulator 2016-05-12 21:56:22 -07:00
18bf35f179 updated camp 2016-05-12 13:56:03 -07:00
7e7dc91947 updated camp 2016-05-12 13:50:27 -07:00
da79f643dc 0.2.115 2016-05-12 13:41:34 -07:00
ea10cde3eb added camp 2016-05-12 13:41:15 -07:00
0a60b0ee37 0.2.114 2016-05-12 12:37:57 -07:00
b4bc985068 upgraded to lancaster 2.0.0.rc3 (core 0.1.9)
added radio.send/receive string
2016-05-12 12:35:40 -07:00
78f9af5bc2 0.2.113 2016-05-11 12:05:13 -07:00
14 changed files with 317 additions and 175 deletions

171
docs/camp.md Normal file
View File

@ -0,0 +1,171 @@
# Getting started
Are you ready to build cool BBC micro:bit programs? For each challenge, reorder the blocks to recreate the program.
* If you haven't done so, open [https://m.pxt.io](/) and create a new **Blocks Editor** project
## Basic
### Show leds
Use the blocks below to draw a figure on the screen. You can redo the smiley face or try something else!
```shuffle
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
```
To transfer your code to the BBC micro:bit,
* connect your micro:bit to the computer using the USB cable
* click on **Download**
* drag&drop the **.hex** file into the **MICROBIT** drive
* wait till the yellow light is done blinking!
### Show animation Forever
Show one image after the other to create an animation.,
Reorder the blocks to make the micro:bit show a happy, then unhappy face.
```shuffle
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
`)
```
### Repeat forever
Use the ``forever`` block to repeat your code and have a continuous animation.
Unsuffle the blocks to create a happy, unhappy animation.... or changes the image to make it your own!
```shuffle
basic.forever(() => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
`)
});
```
### Your turn now!
Use the blocks ``show leds`` and ``forever``
to create your own custom awesome animation!
## Inputs
### Button A and B
Unshuffle the blocks so that the micro:bit shows "YES" when button A is pressed, and "NO" when B is pressed.
The key idea is that all the blocks nested under `on button ... pressed` will run when that button is pressed.
```blocks
input.onButtonPressed(Button.A, () => {
basic.showString("AAAAA");
});
```
Try to unshuffle those blocks:
```shuffle
input.onButtonPressed(Button.A, () => {
basic.showString("YES");
});
input.onButtonPressed(Button.B, () => {
basic.showString("NO");
});
```
### Shake
Using the data from the **accelerometer**, it is possible to detect that the BBC micro:bit is being shaken.
Unshuffle the code to display a frownie when shaken.
```shuffle
input.onGesture(Gesture.Shake, () => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #`);
});
```
### Tilting
Aside from shake, it is also possible to detect tilt left and right, logo up and down or face up and down.
Let's build a rock paper scissors game where you turn the micro:bit left to display paper, right to display scissors and down to display rock.
Unshuffle and try this code on the micro:bit itself!
```shuffle
input.onGesture(Gesture.TiltLeft, () => {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #`);
});
input.onGesture(Gesture.LogoDown, () => {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .`);
});
input.onGesture(Gesture.TiltRight, () => {
basic.showLeds(`
# # . . #
# # . # .
. . # . .
# # . # .
# # . . #`);
});
```
### Pins
It is possible to use the pins (big metal bar at the bottom of the board) as button. Hold the ``GND`` button with one hand and press the ``0`` pin
(called ``P0``) with the other hand to trigger a pin pressed.
Unshuffle the blocks to display a smiley when pin ``P0`` is pressed.
```shuffle
input.onPinPressed(TouchPin.P0, () => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .`);
});
```
### Your turn now!
Use the scree, buttons, gestures, pins to create a fun game using the micro:bit.

View File

@ -43,7 +43,7 @@ namespace radio {
*/ */
//% help=radio/send-number //% help=radio/send-number
//% weight=60 //% weight=60
//% blockId=radio_datagram_send block="send number %MESSAGE" blockGap=8 //% blockId=radio_datagram_send block="send number %value" blockGap=8
void sendNumber(int value) { void sendNumber(int value) {
if (radioEnable() != MICROBIT_OK) return; if (radioEnable() != MICROBIT_OK) return;
uint32_t t = system_timer_current_time(); uint32_t t = system_timer_current_time();
@ -60,7 +60,7 @@ namespace radio {
*/ */
//% help=radio/send-value //% help=radio/send-value
//% weight=59 //% weight=59
//% blockId=radio_datagram_send_value block="send|value %name|= %value" //% blockId=radio_datagram_send_value block="send|value %name|= %value" blockGap=8
void sendValue(StringData* name, int value) { void sendValue(StringData* name, int value) {
if (radioEnable() != MICROBIT_OK) return; if (radioEnable() != MICROBIT_OK) return;
@ -81,6 +81,22 @@ namespace radio {
uBit.radio.datagram.send(buf, 13 + len); uBit.radio.datagram.send(buf, 13 + len);
} }
/**
* Broadcasts a number over radio to any connected micro:bit in the group.
*/
//% help=radio/send-string
//% weight=58
//% blockId=radio_datagram_send_string block="send string %msg"
void sendString(StringData* msg) {
if (radioEnable() != MICROBIT_OK) return;
ManagedString s(msg);
if (s.length() > MICROBIT_RADIO_MAX_PACKET_SIZE)
s = s.substring(0, MICROBIT_RADIO_MAX_PACKET_SIZE);
uBit.radio.datagram.send(s);
}
/** /**
* Reads a value sent with `stream value` and writes it * Reads a value sent with `stream value` and writes it
* to the serial stream as JSON * to the serial stream as JSON
@ -159,7 +175,19 @@ namespace radio {
packet = uBit.radio.datagram.recv(); packet = uBit.radio.datagram.recv();
return receivedNumberAt(0); return receivedNumberAt(0);
} }
/**
* Reads the next packet as a string and returns it.
*/
//% blockId=radio_datagram_receive_string block="receive string" blockGap=8
//% weight=44
//% help=radio/receive-string
StringData* receiveString() {
if (radioEnable() != MICROBIT_OK) return ManagedString().leakData();
packet = uBit.radio.datagram.recv();
return ManagedString(packet).leakData();
}
/** /**
* Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator. * Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.
* namespace=radio * namespace=radio

View File

@ -10,7 +10,7 @@ declare namespace radio {
*/ */
//% help=radio/send-number //% help=radio/send-number
//% weight=60 //% weight=60
//% blockId=radio_datagram_send block="send number %MESSAGE" blockGap=8 shim=radio::sendNumber //% blockId=radio_datagram_send block="send number %value" blockGap=8 shim=radio::sendNumber
function sendNumber(value: number): void; function sendNumber(value: number): void;
/** /**
@ -21,9 +21,17 @@ declare namespace radio {
*/ */
//% help=radio/send-value //% help=radio/send-value
//% weight=59 //% weight=59
//% blockId=radio_datagram_send_value block="send|value %name|= %value" shim=radio::sendValue //% blockId=radio_datagram_send_value block="send|value %name|= %value" blockGap=8 shim=radio::sendValue
function sendValue(name: string, value: number): void; function sendValue(name: string, value: number): void;
/**
* Broadcasts a number over radio to any connected micro:bit in the group.
*/
//% help=radio/send-string
//% weight=58
//% blockId=radio_datagram_send_string block="send string %msg" shim=radio::sendString
function sendString(msg: string): void;
/** /**
* Reads a value sent with `stream value` and writes it * Reads a value sent with `stream value` and writes it
* to the serial stream as JSON * to the serial stream as JSON
@ -58,6 +66,14 @@ declare namespace radio {
//% blockId=radio_datagram_receive block="receive number" blockGap=8 shim=radio::receiveNumber //% blockId=radio_datagram_receive block="receive number" blockGap=8 shim=radio::receiveNumber
function receiveNumber(): number; function receiveNumber(): number;
/**
* Reads the next packet as a string and returns it.
*/
//% blockId=radio_datagram_receive_string block="receive string" blockGap=8
//% weight=44
//% help=radio/receive-string shim=radio::receiveString
function receiveString(): string;
/** /**
* Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator. * Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.
* namespace=radio * namespace=radio

View File

@ -86,7 +86,7 @@ declare const enum DAL {
MICROBIT_DFU_HISTOGRAM_HEIGHT = 5, MICROBIT_DFU_HISTOGRAM_HEIGHT = 5,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitEventService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitEventService.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 20, MICROBIT_IO_PIN_SERVICE_PINCOUNT = 19,
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10, MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h
MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20, MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20,
@ -208,6 +208,7 @@ declare const enum DAL {
MMA8653_SAMPLE_RANGES = 3, MMA8653_SAMPLE_RANGES = 3,
MMA8653_SAMPLE_RATES = 8, MMA8653_SAMPLE_RATES = 8,
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1, MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1,
MICROBIT_ACCELEROMETER_EVT_NONE = 0,
MICROBIT_ACCELEROMETER_EVT_TILT_UP = 1, MICROBIT_ACCELEROMETER_EVT_TILT_UP = 1,
MICROBIT_ACCELEROMETER_EVT_TILT_DOWN = 2, MICROBIT_ACCELEROMETER_EVT_TILT_DOWN = 2,
MICROBIT_ACCELEROMETER_EVT_TILT_LEFT = 3, MICROBIT_ACCELEROMETER_EVT_TILT_LEFT = 3,
@ -229,18 +230,6 @@ declare const enum DAL {
MICROBIT_ACCELEROMETER_GESTURE_DAMPING = 10, MICROBIT_ACCELEROMETER_GESTURE_DAMPING = 10,
MICROBIT_ACCELEROMETER_SHAKE_DAMPING = 10, MICROBIT_ACCELEROMETER_SHAKE_DAMPING = 10,
MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4, MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4,
GESTURE_NONE = 0,
GESTURE_UP = 1,
GESTURE_DOWN = 2,
GESTURE_LEFT = 3,
GESTURE_RIGHT = 4,
GESTURE_FACE_UP = 5,
GESTURE_FACE_DOWN = 6,
GESTURE_FREEFALL = 7,
GESTURE_3G = 8,
GESTURE_6G = 9,
GESTURE_8G = 10,
GESTURE_SHAKE = 11,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitButton.h // built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitButton.h
MICROBIT_BUTTON_EVT_DOWN = 1, MICROBIT_BUTTON_EVT_DOWN = 1,
MICROBIT_BUTTON_EVT_UP = 2, MICROBIT_BUTTON_EVT_UP = 2,
@ -343,14 +332,22 @@ declare const enum DAL {
IO_STATUS_ANALOG_IN = 0x04, IO_STATUS_ANALOG_IN = 0x04,
IO_STATUS_ANALOG_OUT = 0x08, IO_STATUS_ANALOG_OUT = 0x08,
IO_STATUS_TOUCH_IN = 0x10, IO_STATUS_TOUCH_IN = 0x10,
IO_STATUS_EVENTBUS_ENABLED = 0x80, IO_STATUS_EVENT_ON_EDGE = 0x20,
IO_STATUS_EVENT_PULSE_ON_EDGE = 0x40,
MICROBIT_PIN_MAX_OUTPUT = 1023, MICROBIT_PIN_MAX_OUTPUT = 1023,
MICROBIT_PIN_MAX_SERVO_RANGE = 180, MICROBIT_PIN_MAX_SERVO_RANGE = 180,
MICROBIT_PIN_DEFAULT_SERVO_RANGE = 2000, MICROBIT_PIN_DEFAULT_SERVO_RANGE = 2000,
MICROBIT_PIN_DEFAULT_SERVO_CENTER = 1500, MICROBIT_PIN_DEFAULT_SERVO_CENTER = 1500,
MICROBIT_PIN_EVENT_NONE = 0,
MICROBIT_PIN_EVENT_ON_EDGE = 1,
MICROBIT_PIN_EVENT_ON_PULSE = 2,
MICROBIT_PIN_EVENT_ON_TOUCH = 3,
MICROBIT_PIN_EVT_RISE = 2,
MICROBIT_PIN_EVT_FALL = 3,
MICROBIT_PIN_EVT_PULSE_HI = 4,
MICROBIT_PIN_EVT_PULSE_LO = 5,
PIN_CAPABILITY_DIGITAL = 0x01, PIN_CAPABILITY_DIGITAL = 0x01,
PIN_CAPABILITY_ANALOG = 0x02, PIN_CAPABILITY_ANALOG = 0x02,
PIN_CAPABILITY_TOUCH = 0x04,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadio.h // built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadio.h
MICROBIT_RADIO_STATUS_INITIALISED = 0x0001, MICROBIT_RADIO_STATUS_INITIALISED = 0x0001,
MICROBIT_RADIO_BASE_ADDRESS = 0x75626974, MICROBIT_RADIO_BASE_ADDRESS = 0x75626974,
@ -388,6 +385,7 @@ declare const enum DAL {
MICROBIT_THERMOMETER_PERIOD = 1000, MICROBIT_THERMOMETER_PERIOD = 1000,
MICROBIT_THERMOMETER_EVT_UPDATE = 1, MICROBIT_THERMOMETER_EVT_UPDATE = 1,
MICROBIT_THERMOMETER_ADDED_TO_IDLE = 2, MICROBIT_THERMOMETER_ADDED_TO_IDLE = 2,
// built/yt/yotta_modules/microbit-dal/inc//drivers/TimedInterruptIn.h
// built/yt/yotta_modules/microbit-dal/inc//platform/yotta_cfg_mappings.h // built/yt/yotta_modules/microbit-dal/inc//platform/yotta_cfg_mappings.h
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedString.h // built/yt/yotta_modules/microbit-dal/inc//types/ManagedString.h
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedType.h // built/yt/yotta_modules/microbit-dal/inc//types/ManagedType.h

View File

@ -69,42 +69,42 @@ declare namespace basic {
* Raised when shaken * Raised when shaken
*/ */
//% block=shake //% block=shake
Shake = 11, // GESTURE_SHAKE Shake = 11, // MICROBIT_ACCELEROMETER_EVT_SHAKE
/** /**
* Raised when the logo is upward and the screen is vertical * Raised when the logo is upward and the screen is vertical
*/ */
//% block="logo up" //% block="logo up"
LogoUp = 1, // GESTURE_UP LogoUp = 1, // MICROBIT_ACCELEROMETER_EVT_TILT_UP
/** /**
* Raised when the logo is downward and the screen is vertical * Raised when the logo is downward and the screen is vertical
*/ */
//% block="logo down" //% block="logo down"
LogoDown = 2, // GESTURE_DOWN LogoDown = 2, // MICROBIT_ACCELEROMETER_EVT_TILT_DOWN
/** /**
* Raised when the screen is pointing down and the board is horizontal * Raised when the screen is pointing down and the board is horizontal
*/ */
//% block="screen up" //% block="screen up"
ScreenUp = 5, // GESTURE_FACE_UP ScreenUp = 5, // MICROBIT_ACCELEROMETER_EVT_FACE_UP
/** /**
* Raised when the screen is pointing up and the board is horizontal * Raised when the screen is pointing up and the board is horizontal
*/ */
//% block="screen down" //% block="screen down"
ScreenDown = 6, // GESTURE_FACE_DOWN ScreenDown = 6, // MICROBIT_ACCELEROMETER_EVT_FACE_DOWN
/** /**
* Raised when the screen is pointing left * Raised when the screen is pointing left
*/ */
//% block="tilt left" //% block="tilt left"
TiltLeft = 3, // GESTURE_LEFT TiltLeft = 3, // MICROBIT_ACCELEROMETER_EVT_TILT_LEFT
/** /**
* Raised when the screen is pointing right * Raised when the screen is pointing right
*/ */
//% block="tilt right" //% block="tilt right"
TiltRight = 4, // GESTURE_RIGHT TiltRight = 4, // MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT
/** /**
* Raised when the board is falling! * Raised when the board is falling!
*/ */
//% block="free fall" //% block="free fall"
FreeFall = 7, // GESTURE_FREEFALL FreeFall = 7, // MICROBIT_ACCELEROMETER_EVT_FREEFALL
} }
declare namespace input { declare namespace input {
} }
@ -281,7 +281,5 @@ declare namespace serial {
Int32BE = 10, Int32BE = 10,
// UInt32, // UInt32,
} }
declare namespace storage {
}
// Auto-generated. Do not edit. Really. // Auto-generated. Do not edit. Really.

View File

@ -59,42 +59,42 @@ enum class Gesture {
* Raised when shaken * Raised when shaken
*/ */
//% block=shake //% block=shake
Shake = GESTURE_SHAKE, Shake = MICROBIT_ACCELEROMETER_EVT_SHAKE,
/** /**
* Raised when the logo is upward and the screen is vertical * Raised when the logo is upward and the screen is vertical
*/ */
//% block="logo up" //% block="logo up"
LogoUp = GESTURE_UP, LogoUp = MICROBIT_ACCELEROMETER_EVT_TILT_UP,
/** /**
* Raised when the logo is downward and the screen is vertical * Raised when the logo is downward and the screen is vertical
*/ */
//% block="logo down" //% block="logo down"
LogoDown = GESTURE_DOWN, LogoDown = MICROBIT_ACCELEROMETER_EVT_TILT_DOWN,
/** /**
* Raised when the screen is pointing down and the board is horizontal * Raised when the screen is pointing down and the board is horizontal
*/ */
//% block="screen up" //% block="screen up"
ScreenUp = GESTURE_FACE_UP, ScreenUp = MICROBIT_ACCELEROMETER_EVT_FACE_UP,
/** /**
* Raised when the screen is pointing up and the board is horizontal * Raised when the screen is pointing up and the board is horizontal
*/ */
//% block="screen down" //% block="screen down"
ScreenDown = GESTURE_FACE_DOWN, ScreenDown = MICROBIT_ACCELEROMETER_EVT_FACE_DOWN,
/** /**
* Raised when the screen is pointing left * Raised when the screen is pointing left
*/ */
//% block="tilt left" //% block="tilt left"
TiltLeft = GESTURE_LEFT, TiltLeft = MICROBIT_ACCELEROMETER_EVT_TILT_LEFT,
/** /**
* Raised when the screen is pointing right * Raised when the screen is pointing right
*/ */
//% block="tilt right" //% block="tilt right"
TiltRight = GESTURE_RIGHT, TiltRight = MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT,
/** /**
* Raised when the board is falling! * Raised when the board is falling!
*/ */
//% block="free fall" //% block="free fall"
FreeFall = GESTURE_FREEFALL FreeFall = MICROBIT_ACCELEROMETER_EVT_FREEFALL
}; };
//% color=300 weight=99 //% color=300 weight=99

View File

@ -26,8 +26,7 @@
"pins.ts", "pins.ts",
"serial.cpp", "serial.cpp",
"serial.ts", "serial.ts",
"buffer.cpp", "buffer.cpp"
"storage.cpp"
], ],
"public": true, "public": true,
"dependencies": {}, "dependencies": {},

View File

@ -597,37 +597,4 @@ declare interface Buffer {
write(dstOffset: number, src: Buffer): void; write(dstOffset: number, src: Buffer): void;
} }
/**
* This allows reading and writing of small blocks of data to FLASH memory.
*/
//% weight=10 color=#cc6600
declare namespace storage {
/**
* Writes the key and buffer pair into FLASH. This operation is rather costly as all the key/value pairs
* have to be rewritten as well.
*/
//% shim=storage::putBuffer
function putBuffer(key: string, buffer: Buffer): void;
/**
* Gets the buffer at the given key if any. If no key is available, empty buffer is returned.
*/
//% shim=storage::getBuffer
function getBuffer(key: string): Buffer;
/**
* Removes an entry identified by the key.
*/
//% shim=storage::remove
function remove(key: string): void;
/**
* The number of entries in the key value store
*/
//% shim=storage::size
function size(): number;
}
// Auto-generated. Do not edit. Really. // Auto-generated. Do not edit. Really.

View File

@ -1,43 +0,0 @@
#include "ksbit.h"
/**
* This allows reading and writing of small blocks of data to FLASH memory.
*/
//% weight=10 color=#cc6600
namespace storage {
/**
* Writes the key and buffer pair into FLASH. This operation is rather costly as all the key/value pairs
* have to be rewritten as well.
*/
//%
void putBuffer(StringData* key, Buffer buffer) {
uBit.storage.put(ManagedString(key), ManagedBuffer(buffer).getBytes());
}
/**
* Gets the buffer at the given key if any. If no key is available, empty buffer is returned.
*/
//%
Buffer getBuffer(StringData* key) {
KeyValuePair* pv = uBit.storage.get(ManagedString(key));
if (pv == NULL) return ManagedBuffer().leakData();
return ManagedBuffer(pv->value, sizeof(pv->value)).leakData();
}
/**
* Removes an entry identified by the key.
*/
//%
void remove(StringData * key) {
uBit.storage.remove(ManagedString(key));
}
/**
* The number of entries in the key value store
*/
//%
int size() {
return uBit.storage.size();
}
}

View File

@ -1,6 +1,6 @@
{ {
"name": "pxt-microbit", "name": "pxt-microbit",
"version": "0.2.112", "version": "0.2.116",
"description": "BBC micro:bit target for PXT", "description": "BBC micro:bit target for PXT",
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7" "typescript": "^1.8.7"
}, },
"dependencies": { "dependencies": {
"pxt-core": "0.2.124" "pxt-core": "0.2.125"
} }
} }

View File

@ -63,7 +63,7 @@
"aspectRatio": 1.22 "aspectRatio": 1.22
}, },
"compileService": { "compileService": {
"gittag": "v0.1.8", "gittag": "v0.1.9",
"serviceId": "ws" "serviceId": "ws"
}, },
"serial": { "serial": {

View File

@ -457,6 +457,10 @@ namespace pxsim.radio {
board().radio.datagram.send([value]); board().radio.datagram.send([value]);
} }
export function sendString(msg: string): void {
board().radio.datagram.send(msg);
}
export function writeValueToSerial(): void { export function writeValueToSerial(): void {
let b = board(); let b = board();
let v = b.radio.datagram.recv().data[0]; let v = b.radio.datagram.recv().data[0];
@ -468,11 +472,23 @@ namespace pxsim.radio {
} }
export function receiveNumber(): number { export function receiveNumber(): number {
return board().radio.datagram.recv().data[0]; let buffer = board().radio.datagram.recv().data;
if (buffer instanceof Array) return buffer[0];
return 0;
}
export function receiveString(): string {
let buffer = board().radio.datagram.recv().data;
if (typeof buffer === "string") return <string>buffer;
return "";
} }
export function receivedNumberAt(index: number): number { export function receivedNumberAt(index: number): number {
return board().radio.datagram.lastReceived.data[index] || 0; let buffer = board().radio.datagram.recv().data;
if (buffer instanceof Array) return buffer[index] || 0;
return 0;
} }
export function receivedSignalStrength(): number { export function receivedSignalStrength(): number {

View File

@ -244,8 +244,9 @@ namespace pxsim.micro_bit {
let state = this.board; let state = this.board;
if (!state || !state.usesHeading) return; if (!state || !state.usesHeading) return;
if (!this.headInitialized) { if (!this.headInitialized) {
let p = this.head.firstChild.nextSibling as SVGPathElement; let p = svg.path(this.head, "sim-theme", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z");
p.setAttribute("d", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z"); this.logos.push(p);
this.updateTheme();
let pt = this.element.createSVGPoint(); let pt = this.element.createSVGPoint();
svg.buttonEvents( svg.buttonEvents(
this.head, this.head,
@ -253,13 +254,12 @@ namespace pxsim.micro_bit {
let cur = svg.cursorPoint(pt, this.element, ev); let cur = svg.cursorPoint(pt, this.element, ev);
state.heading = Math.floor(Math.atan2(cur.y - yc, cur.x - xc) * 180 / Math.PI + 90); state.heading = Math.floor(Math.atan2(cur.y - yc, cur.x - xc) * 180 / Math.PI + 90);
if (state.heading < 0) state.heading += 360; if (state.heading < 0) state.heading += 360;
console.log('heading: ' + state.heading)
this.updateHeading(); this.updateHeading();
}); });
this.headInitialized = true; this.headInitialized = true;
} }
let txt = state.heading.toString() + '°'; let txt = state.heading.toString() + "°";
if (txt != this.headText.textContent) { if (txt != this.headText.textContent) {
svg.rotateElement(this.head, xc, yc, state.heading + 180); svg.rotateElement(this.head, xc, yc, state.heading + 180);
this.headText.textContent = txt; this.headText.textContent = txt;
@ -273,7 +273,7 @@ namespace pxsim.micro_bit {
let now = Date.now(); let now = Date.now();
if (now - this.lastFlashTime > 150) { if (now - this.lastFlashTime > 150) {
this.lastFlashTime = now; this.lastFlashTime = now;
svg.animate(this.systemLed, 'sim-flash') svg.animate(this.systemLed, "sim-flash")
} }
} }
@ -452,6 +452,9 @@ svg.sim.grayscale {
animation-duration: 0.4s; animation-duration: 0.4s;
animation-timing-function: ease-in; animation-timing-function: ease-in;
} }
.sim-button-label {
fill:#fff;
}
@keyframes sim-flash-stroke-animation { @keyframes sim-flash-stroke-animation {
from { stroke: yellow; } from { stroke: yellow; }
@ -478,11 +481,11 @@ svg.sim.grayscale {
this.display = svg.path(this.g, "sim-display", "M333.8,310.3H165.9c-8.3,0-15-6.7-15-15V127.5c0-8.3,6.7-15,15-15h167.8c8.3,0,15,6.7,15,15v167.8C348.8,303.6,342.1,310.3,333.8,310.3z"); this.display = svg.path(this.g, "sim-display", "M333.8,310.3H165.9c-8.3,0-15-6.7-15-15V127.5c0-8.3,6.7-15,15-15h167.8c8.3,0,15,6.7,15,15v167.8C348.8,303.6,342.1,310.3,333.8,310.3z");
this.logos = []; this.logos = [];
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "115,56.7 173.1,0 115,0" })); //this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "115,56.7 173.1,0 115,0" }));
this.logos.push(svg.path(this.g, "sim-theme", "M114.2,0H25.9C12.1,2.1,0,13.3,0,27.7v83.9L114.2,0z")); //this.logos.push(svg.path(this.g, "sim-theme", "M114.2,0H25.9C12.1,2.1,0,13.3,0,27.7v83.9L114.2,0z"));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "173,27.9 202.5,0 173,0" })); //this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "173,27.9 202.5,0 173,0" }));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "54.1,242.4 54.1,274.1 22.4,274.1" })); //this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "54.1,242.4 54.1,274.1 22.4,274.1" }));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "446.2,164.6 446.2,132.8 477.9,132.8" })); //this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "446.2,164.6 446.2,132.8 477.9,132.8" }));
// leds // leds
this.leds = []; this.leds = [];
@ -501,9 +504,9 @@ svg.sim.grayscale {
// head // head
this.head = <SVGGElement>svg.child(this.g, "g", {}); this.head = <SVGGElement>svg.child(this.g, "g", {});
svg.child(this.head, "circle", { cx: 258, cy: 75, r: 100, fill: "transparent" }) svg.child(this.head, "circle", { cx: 258, cy: 75, r: 100, fill: "transparent" })
this.logos.push(svg.path(this.head, "sim-theme", "M269.9,50.2L269.9,50.2l-39.5,0v0c-14.1,0.1-24.6,10.7-24.6,24.8c0,13.9,10.4,24.4,24.3,24.7v0h39.6c14.2,0,24.8-10.6,24.8-24.7C294.5,61,284,50.3,269.9,50.2 M269.7,89.2L269.7,89.2l-39.3,0c-7.7-0.1-14-6.4-14-14.2c0-7.8,6.4-14.2,14.2-14.2h39.1c7.8,0,14.2,6.4,14.2,14.2C283.9,82.9,277.5,89.2,269.7,89.2")); //this.logos.push(svg.path(this.head, "sim-theme", "M269.9,50.2L269.9,50.2l-39.5,0v0c-14.1,0.1-24.6,10.7-24.6,24.8c0,13.9,10.4,24.4,24.3,24.7v0h39.6c14.2,0,24.8-10.6,24.8-24.7C294.5,61,284,50.3,269.9,50.2 M269.7,89.2L269.7,89.2l-39.3,0c-7.7-0.1-14-6.4-14-14.2c0-7.8,6.4-14.2,14.2-14.2h39.1c7.8,0,14.2,6.4,14.2,14.2C283.9,82.9,277.5,89.2,269.7,89.2"));
this.logos.push(svg.path(this.head, "sim-theme", "M230.6,69.7c-2.9,0-5.3,2.4-5.3,5.3c0,2.9,2.4,5.3,5.3,5.3c2.9,0,5.3-2.4,5.3-5.3C235.9,72.1,233.5,69.7,230.6,69.7")); //this.logos.push(svg.path(this.head, "sim-theme", "M230.6,69.7c-2.9,0-5.3,2.4-5.3,5.3c0,2.9,2.4,5.3,5.3,5.3c2.9,0,5.3-2.4,5.3-5.3C235.9,72.1,233.5,69.7,230.6,69.7"));
this.logos.push(svg.path(this.head, "sim-theme", "M269.7,80.3c2.9,0,5.3-2.4,5.3-5.3c0-2.9-2.4-5.3-5.3-5.3c-2.9,0-5.3,2.4-5.3,5.3C264.4,77.9,266.8,80.3,269.7,80.3")); //this.logos.push(svg.path(this.head, "sim-theme", "M269.7,80.3c2.9,0,5.3-2.4,5.3-5.3c0-2.9-2.4-5.3-5.3-5.3c-2.9,0-5.3,2.4-5.3,5.3C264.4,77.9,266.8,80.3,269.7,80.3"));
this.headText = <SVGTextElement>svg.child(this.g, "text", { x: 310, y: 100, class: "sim-text" }) this.headText = <SVGTextElement>svg.child(this.g, "text", { x: 310, y: 100, class: "sim-text" })
// https://www.microbit.co.uk/device/pins // https://www.microbit.co.uk/device/pins
@ -567,9 +570,10 @@ svg.sim.grayscale {
svg.path(this.g, "sim-label", "M35.7,376.4c0-2.8,2.1-5.1,5.5-5.1c3.3,0,5.5,2.4,5.5,5.1v4.7c0,2.8-2.2,5.1-5.5,5.1c-3.3,0-5.5-2.4-5.5-5.1V376.4zM43.3,376.4c0-1.3-0.8-2.3-2.2-2.3c-1.3,0-2.1,1.1-2.1,2.3v4.7c0,1.2,0.8,2.3,2.1,2.3c1.3,0,2.2-1.1,2.2-2.3V376.4z"); svg.path(this.g, "sim-label", "M35.7,376.4c0-2.8,2.1-5.1,5.5-5.1c3.3,0,5.5,2.4,5.5,5.1v4.7c0,2.8-2.2,5.1-5.5,5.1c-3.3,0-5.5-2.4-5.5-5.1V376.4zM43.3,376.4c0-1.3-0.8-2.3-2.2-2.3c-1.3,0-2.1,1.1-2.1,2.3v4.7c0,1.2,0.8,2.3,2.1,2.3c1.3,0,2.2-1.1,2.2-2.3V376.4z");
svg.path(this.g, "sim-label", "M136.2,374.1c2.8,0,3.4-0.8,3.4-2.5h2.9v14.3h-3.4v-9.5h-3V374.1z"); svg.path(this.g, "sim-label", "M136.2,374.1c2.8,0,3.4-0.8,3.4-2.5h2.9v14.3h-3.4v-9.5h-3V374.1z");
svg.path(this.g, "sim-label", "M248.6,378.5c1.7-1,3-1.7,3-3.1c0-1.1-0.7-1.6-1.6-1.6c-1,0-1.8,0.6-1.8,2.1h-3.3c0-2.6,1.8-4.6,5.1-4.6c2.6,0,4.9,1.3,4.9,4.3c0,2.4-2.3,3.9-3.8,4.7c-2,1.3-2.5,1.8-2.5,2.9h6.1v2.7h-10C244.8,381.2,246.4,379.9,248.6,378.5z"); svg.path(this.g, "sim-label", "M248.6,378.5c1.7-1,3-1.7,3-3.1c0-1.1-0.7-1.6-1.6-1.6c-1,0-1.8,0.6-1.8,2.1h-3.3c0-2.6,1.8-4.6,5.1-4.6c2.6,0,4.9,1.3,4.9,4.3c0,2.4-2.3,3.9-3.8,4.7c-2,1.3-2.5,1.8-2.5,2.9h6.1v2.7h-10C244.8,381.2,246.4,379.9,248.6,378.5z");
svg.path(this.g, "sim-label", "M48.1,270.9l-0.6-1.7h-5.1l-0.6,1.7h-3.5l5.1-14.3h3.1l5.2,14.3H48.1z M45,260.7l-1.8,5.9h3.5L45,260.7z");
svg.path(this.g, "sim-label", "M449.1,135.8h5.9c3.9,0,4.7,2.4,4.7,3.9c0,1.8-1.4,2.9-2.5,3.2c0.9,0,2.6,1.1,2.6,3.3c0,1.5-0.8,4-4.7,4h-6V135.8zM454.4,141.7c1.6,0,2-1,2-1.7c0-0.6-0.3-1.7-2-1.7h-2v3.4H454.4z M452.4,144.1v3.5h2.1c1.6,0,2-1,2-1.8c0-0.7-0.4-1.8-2-1.8H452.4z") svg.path(this.g, "sim-button-label", "M48.1,270.9l-0.6-1.7h-5.1l-0.6,1.7h-3.5l5.1-14.3h3.1l5.2,14.3H48.1z M45,260.7l-1.8,5.9h3.5L45,260.7z");
svg.path(this.g, "sim-button-label", "M449.1,135.8h5.9c3.9,0,4.7,2.4,4.7,3.9c0,1.8-1.4,2.9-2.5,3.2c0.9,0,2.6,1.1,2.6,3.3c0,1.5-0.8,4-4.7,4h-6V135.8zM454.4,141.7c1.6,0,2-1,2-1.7c0-0.6-0.3-1.7-2-1.7h-2v3.4H454.4z M452.4,144.1v3.5h2.1c1.6,0,2-1,2-1.8c0-0.7-0.4-1.8-2-1.8H452.4z")
svg.path(this.g, "sim-label", "M352.1,381.1c0,1.6,0.9,2.5,2.2,2.5c1.2,0,1.9-0.9,1.9-1.9c0-1.2-0.6-2-2.1-2h-1.3v-2.6h1.3c1.5,0,1.9-0.7,1.9-1.8c0-1.1-0.7-1.6-1.6-1.6c-1.4,0-1.8,0.8-1.8,2.1h-3.3c0-2.4,1.5-4.6,5.1-4.6c2.6,0,5,1.3,5,4c0,1.6-1,2.8-2.1,3.2c1.3,0.5,2.3,1.6,2.3,3.5c0,2.7-2.4,4.3-5.2,4.3c-3.5,0-5.5-2.1-5.5-5.1H352.1z") svg.path(this.g, "sim-label", "M352.1,381.1c0,1.6,0.9,2.5,2.2,2.5c1.2,0,1.9-0.9,1.9-1.9c0-1.2-0.6-2-2.1-2h-1.3v-2.6h1.3c1.5,0,1.9-0.7,1.9-1.8c0-1.1-0.7-1.6-1.6-1.6c-1.4,0-1.8,0.8-1.8,2.1h-3.3c0-2.4,1.5-4.6,5.1-4.6c2.6,0,5,1.3,5,4c0,1.6-1,2.8-2.1,3.2c1.3,0.5,2.3,1.6,2.3,3.5c0,2.7-2.4,4.3-5.2,4.3c-3.5,0-5.5-2.1-5.5-5.1H352.1z")
svg.path(this.g, "sim-label", "M368.5,385.9h-3.1l-5.1-14.3h3.5l3.1,10.1l3.1-10.1h3.6L368.5,385.9z") svg.path(this.g, "sim-label", "M368.5,385.9h-3.1l-5.1-14.3h3.5l3.1,10.1l3.1-10.1h3.6L368.5,385.9z")
svg.path(this.g, "sim-label", "M444.4,378.3h7.4v2.5h-1.5c-0.6,3.3-3,5.5-7.1,5.5c-4.8,0-7.5-3.5-7.5-7.5c0-3.9,2.8-7.5,7.5-7.5c3.8,0,6.4,2.3,6.6,5h-3.5c-0.2-1.1-1.4-2.2-3.1-2.2c-2.7,0-4.1,2.3-4.1,4.7c0,2.5,1.4,4.7,4.4,4.7c2,0,3.2-1.2,3.4-2.7h-2.5V378.3z") svg.path(this.g, "sim-label", "M444.4,378.3h7.4v2.5h-1.5c-0.6,3.3-3,5.5-7.1,5.5c-4.8,0-7.5-3.5-7.5-7.5c0-3.9,2.8-7.5,7.5-7.5c3.8,0,6.4,2.3,6.6,5h-3.5c-0.2-1.1-1.4-2.2-3.1-2.2c-2.7,0-4.1,2.3-4.1,4.7c0,2.5,1.4,4.7,4.4,4.7c2,0,3.2-1.2,3.4-2.7h-2.5V378.3z")

View File

@ -56,7 +56,7 @@ namespace pxsim {
} }
export interface PacketBuffer { export interface PacketBuffer {
data: number[]; data: number[] | string;
rssi?: number; rssi?: number;
} }
@ -77,10 +77,13 @@ namespace pxsim {
} }
} }
send(buffer: number[]) { send(buffer: number[] | string) {
if (buffer instanceof String) buffer = buffer.slice(0, 32);
else buffer = buffer.slice(0, 8);
Runtime.postMessage(<SimulatorRadioPacketMessage>{ Runtime.postMessage(<SimulatorRadioPacketMessage>{
type: 'radiopacket', type: "radiopacket",
data: buffer.slice(0, 8) data: buffer
}) })
} }
@ -128,21 +131,6 @@ namespace pxsim {
} }
} }
export enum BasicGesture {
GESTURE_NONE,
GESTURE_UP,
GESTURE_DOWN,
GESTURE_LEFT,
GESTURE_RIGHT,
GESTURE_FACE_UP,
GESTURE_FACE_DOWN,
GESTURE_FREEFALL,
GESTURE_3G,
GESTURE_6G,
GESTURE_8G,
GESTURE_SHAKE
};
interface AccelerometerSample { interface AccelerometerSample {
x: number; x: number;
y: number; y: number;
@ -196,8 +184,8 @@ namespace pxsim {
export class Accelerometer { export class Accelerometer {
private sigma: number = 0; // the number of ticks that the instantaneous gesture has been stable. private sigma: number = 0; // the number of ticks that the instantaneous gesture has been stable.
private lastGesture: BasicGesture = BasicGesture.GESTURE_NONE; // the last, stable gesture recorded. private lastGesture: number = 0; // the last, stable gesture recorded.
private currentGesture: BasicGesture = BasicGesture.GESTURE_NONE; // the instantaneous, unfiltered gesture detected. private currentGesture: number = 0 // the instantaneous, unfiltered gesture detected.
private sample: AccelerometerSample = { x: 0, y: 0, z: -1023 } private sample: AccelerometerSample = { x: 0, y: 0, z: -1023 }
private shake: ShakeHistory = { x: false, y: false, z: false, count: 0, shaken: 0, timer: 0 }; // State information needed to detect shake events. private shake: ShakeHistory = { x: false, y: false, z: false, count: 0, shaken: 0, timer: 0 }; // State information needed to detect shake events.
private pitch: number; private pitch: number;
@ -250,7 +238,7 @@ namespace pxsim {
* *
* @return A best guess of the current posture of the device, based on instantaneous data. * @return A best guess of the current posture of the device, based on instantaneous data.
*/ */
private instantaneousPosture(): BasicGesture { private instantaneousPosture(): number {
let force = this.instantaneousAccelerationSquared(); let force = this.instantaneousAccelerationSquared();
let shakeDetected = false; let shakeDetected = false;
@ -287,42 +275,42 @@ namespace pxsim {
} }
if (this.shake.shaken) if (this.shake.shaken)
return BasicGesture.GESTURE_SHAKE; return DAL.MICROBIT_ACCELEROMETER_EVT_SHAKE;
let sq = (n: number) => n * n let sq = (n: number) => n * n
if (force < sq(DAL.MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE)) if (force < sq(DAL.MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE))
return BasicGesture.GESTURE_FREEFALL; return DAL.MICROBIT_ACCELEROMETER_EVT_FREEFALL;
if (force > sq(DAL.MICROBIT_ACCELEROMETER_3G_TOLERANCE)) if (force > sq(DAL.MICROBIT_ACCELEROMETER_3G_TOLERANCE))
return BasicGesture.GESTURE_3G; return DAL.MICROBIT_ACCELEROMETER_EVT_3G;
if (force > sq(DAL.MICROBIT_ACCELEROMETER_6G_TOLERANCE)) if (force > sq(DAL.MICROBIT_ACCELEROMETER_6G_TOLERANCE))
return BasicGesture.GESTURE_6G; return DAL.MICROBIT_ACCELEROMETER_EVT_6G;
if (force > sq(DAL.MICROBIT_ACCELEROMETER_8G_TOLERANCE)) if (force > sq(DAL.MICROBIT_ACCELEROMETER_8G_TOLERANCE))
return BasicGesture.GESTURE_8G; return DAL.MICROBIT_ACCELEROMETER_EVT_8G;
// Determine our posture. // Determine our posture.
if (this.getX() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getX() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_LEFT; return DAL.MICROBIT_ACCELEROMETER_EVT_TILT_LEFT;
if (this.getX() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getX() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_RIGHT; return DAL.MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT;
if (this.getY() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getY() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_DOWN; return DAL.MICROBIT_ACCELEROMETER_EVT_TILT_DOWN;
if (this.getY() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getY() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_UP; return DAL.MICROBIT_ACCELEROMETER_EVT_TILT_UP;
if (this.getZ() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getZ() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_FACE_UP; return DAL.MICROBIT_ACCELEROMETER_EVT_FACE_UP;
if (this.getZ() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getZ() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_FACE_DOWN; return DAL.MICROBIT_ACCELEROMETER_EVT_FACE_DOWN;
return BasicGesture.GESTURE_NONE; return 0;
} }
updateGesture() { updateGesture() {
@ -578,16 +566,16 @@ namespace pxsim {
if (!runtime || runtime.dead) return; if (!runtime || runtime.dead) return;
switch (msg.type || "") { switch (msg.type || "") {
case 'eventbus': case "eventbus":
let ev = <SimulatorEventBusMessage>msg; let ev = <SimulatorEventBusMessage>msg;
this.bus.queue(ev.id, ev.eventid, ev.value); this.bus.queue(ev.id, ev.eventid, ev.value);
break; break;
case 'serial': case "serial":
this.serialIn.push((<SimulatorSerialMessage>msg).data || ''); this.serialIn.push((<SimulatorSerialMessage>msg).data || "");
break; break;
case 'radiopacket': case "radiopacket":
let packet = <SimulatorRadioPacketMessage>msg; let packet = <SimulatorRadioPacketMessage>msg;
this.radio.datagram.queue({ data: packet.data || [], rssi: packet.rssi || 0 }) this.radio.datagram.queue({ data: packet.data, rssi: packet.rssi || 0 })
break; break;
} }
} }