2.1.28, initiation update to PXT v5.28.24 (#54)

This commit is contained in:
Amerlander
2019-12-02 05:58:26 +01:00
committed by Peli de Halleux
parent 38a964516e
commit 5c114a0c57
1261 changed files with 50692 additions and 21604 deletions

View File

@ -25,22 +25,6 @@
"MesDeviceInfo.OrientationLandscape|block": "orientation landscape",
"MesDeviceInfo.OrientationPortrait|block": "orientation portrait",
"MesDeviceInfo.Shaken|block": "shaken",
"MesDpadButtonInfo.ADown|block": "A down",
"MesDpadButtonInfo.AUp|block": "A up",
"MesDpadButtonInfo.BDown|block": "B down",
"MesDpadButtonInfo.BUp|block": "B up",
"MesDpadButtonInfo.CDown|block": "C down",
"MesDpadButtonInfo.CUp|block": "C up",
"MesDpadButtonInfo.DDown|block": "D down",
"MesDpadButtonInfo.DUp|block": "D up",
"MesDpadButtonInfo._1Down|block": "1 down",
"MesDpadButtonInfo._1Up|block": "1 up",
"MesDpadButtonInfo._2Down|block": "2 down",
"MesDpadButtonInfo._2Up|block": "2 up",
"MesDpadButtonInfo._3Down|block": "3 down",
"MesDpadButtonInfo._3Up|block": "3 up",
"MesDpadButtonInfo._4Down|block": "4 down",
"MesDpadButtonInfo._4Up|block": "4 up",
"MesRemoteControlEvent.forward|block": "forward",
"MesRemoteControlEvent.nextTrack|block": "next track",
"MesRemoteControlEvent.pause|block": "pause",

View File

@ -85,102 +85,11 @@ enum class MesRemoteControlEvent {
volumeDown = MES_REMOTE_CONTROL_EVT_VOLUMEDOWN,
};
enum class MesDpadButtonInfo {
//% block="A down"
ADown = MES_DPAD_BUTTON_A_DOWN,
//% block="A up"
AUp = MES_DPAD_BUTTON_A_UP,
//% block="B down"
BDown = MES_DPAD_BUTTON_B_DOWN,
//% block="B up"
BUp = MES_DPAD_BUTTON_B_UP,
//% block="C down"
CDown = MES_DPAD_BUTTON_C_DOWN,
//% block="C up"
CUp = MES_DPAD_BUTTON_C_UP,
//% block="D down"
DDown = MES_DPAD_BUTTON_D_DOWN,
//% block="D up"
DUp = MES_DPAD_BUTTON_D_UP,
//% block="1 down"
_1Down = MES_DPAD_BUTTON_1_UP,
//% block="1 up"
_1Up = MES_DPAD_BUTTON_1_DOWN,
//% block="2 down"
_2Down = MES_DPAD_BUTTON_2_DOWN,
//% block="2 up"
_2Up = MES_DPAD_BUTTON_2_UP,
//% block="3 down"
_3Down = MES_DPAD_BUTTON_3_DOWN,
//% block="3 up"
_3Up = MES_DPAD_BUTTON_3_UP,
//% block="4 down"
_4Down = MES_DPAD_BUTTON_4_DOWN,
//% block="4 up"
_4Up = MES_DPAD_BUTTON_4_UP,
};
/**
* Control a phone with the BBC micro:bit via Bluetooth.
*/
//% color=156 weight=80
//% color=#008272 weight=80 icon="\uf10b"
namespace devices {
static void genEvent(int id, int event) {
MicroBitEvent e(id, event);
}
/**
* Sends a ``camera`` command to the parent device.
* @param event event description
*/
//% weight=30 help=devices/tell-camera-to
//% blockId=devices_camera icon="\uf030" block="tell camera to|%property" blockGap=8
void tellCameraTo(MesCameraEvent event) {
genEvent(MES_CAMERA_ID, (int)event);
}
/**
* Sends a ``remote control`` command to the parent device.
* @param event event description
*/
//% weight=29 help=devices/tell-remote-control-to
//% blockId=devices_remote_control block="tell remote control to|%property" blockGap=14 icon="\uf144"
void tellRemoteControlTo(MesRemoteControlEvent event) {
genEvent(MES_REMOTE_CONTROL_ID, (int)event);
}
/**
* Sends an ``alert`` command to the parent device.
* @param event event description
*/
//% weight=27 help=devices/raise-alert-to
//% blockId=devices_alert block="raise alert to|%property" icon="\uf0f3"
void raiseAlertTo(MesAlertEvent event) {
genEvent(MES_ALERTS_ID, (int)event);
}
/**
* Registers code to run when the device notifies about a particular event.
* @param event event description
* @param body code handler when event is triggered
*/
//% help=devices/on-notified weight=26
//% blockId=devices_device_info_event block="on notified|%event" icon="\uf10a"
void onNotified(MesDeviceInfo event, Action body) {
registerWithDal(MES_DEVICE_INFO_ID, (int)event, body);
}
/**
* Register code to run when the micro:bit receives a command from the paired gamepad.
* @param name button name
* @param body code to run when button is pressed
*/
//% help=devices/on-gamepad-button weight=40
//% weight=25
//% blockId=devices_gamepad_event block="on gamepad button|%NAME" icon="\uf11b"
void onGamepadButton(MesDpadButtonInfo name, Action body) {
registerWithDal(MES_DPAD_CONTROLLER_ID, (int)name, body);
}
static int _signalStrength = -1;
static void signalStrengthHandler(MicroBitEvent ev) {

55
libs/devices/devices.ts Normal file
View File

@ -0,0 +1,55 @@
namespace devices {
/**
* Sends a ``camera`` command to the parent device.
* @param event event description
*/
//% weight=30 help=devices/tell-camera-to
//% blockId=devices_camera icon="\uf030" block="tell camera to|%property" blockGap=8
export function tellCameraTo(event: MesCameraEvent) {
control.raiseEvent(DAL.MES_CAMERA_ID, event);
}
/**
* Sends a ``remote control`` command to the parent device.
* @param event event description
*/
//% weight=29 help=devices/tell-remote-control-to
//% blockId=devices_remote_control block="tell remote control to|%property" blockGap=14 icon="\uf144"
export function tellRemoteControlTo(event: MesRemoteControlEvent) {
control.raiseEvent(DAL.MES_REMOTE_CONTROL_ID, event);
}
/**
* Sends an ``alert`` command to the parent device.
* @param event event description
*/
//% weight=27 help=devices/raise-alert-to
//% blockId=devices_alert block="raise alert to|%property" icon="\uf0f3"
export function raiseAlertTo(event: MesAlertEvent) {
control.raiseEvent(DAL.MES_ALERTS_ID, event);
}
/**
* Registers code to run when the device notifies about a particular event.
* @param event event description
* @param body code handler when event is triggered
*/
//% help=devices/on-notified weight=26
//% blockId=devices_device_info_event block="on notified|%event" icon="\uf10a"
export function onNotified(event: MesDeviceInfo, body: () => void) {
control.onEvent(DAL.MES_DEVICE_INFO_ID, event, body);
}
/**
* Register code to run when the micro:bit receives a command from the paired gamepad.
* @param name button name
* @param body code to run when button is pressed
*/
//% help=devices/on-gamepad-button weight=40
//% weight=25
//% blockId=devices_gamepad_event block="on gamepad button|%NAME" icon="\uf11b"
export function onGamepadButton(name: MesDpadButtonInfo, body: () => void) {
control.onEvent(DAL.MES_DPAD_CONTROLLER_ID, name, body);
}
}

View File

@ -85,42 +85,6 @@
//% block="volume down"
volumeDown = 9, // MES_REMOTE_CONTROL_EVT_VOLUMEDOWN
}
declare const enum MesDpadButtonInfo {
//% block="A down"
ADown = 1, // MES_DPAD_BUTTON_A_DOWN
//% block="A up"
AUp = 2, // MES_DPAD_BUTTON_A_UP
//% block="B down"
BDown = 3, // MES_DPAD_BUTTON_B_DOWN
//% block="B up"
BUp = 4, // MES_DPAD_BUTTON_B_UP
//% block="C down"
CDown = 5, // MES_DPAD_BUTTON_C_DOWN
//% block="C up"
CUp = 6, // MES_DPAD_BUTTON_C_UP
//% block="D down"
DDown = 7, // MES_DPAD_BUTTON_D_DOWN
//% block="D up"
DUp = 8, // MES_DPAD_BUTTON_D_UP
//% block="1 down"
_1Down = 10, // MES_DPAD_BUTTON_1_UP
//% block="1 up"
_1Up = 9, // MES_DPAD_BUTTON_1_DOWN
//% block="2 down"
_2Down = 11, // MES_DPAD_BUTTON_2_DOWN
//% block="2 up"
_2Up = 12, // MES_DPAD_BUTTON_2_UP
//% block="3 down"
_3Down = 13, // MES_DPAD_BUTTON_3_DOWN
//% block="3 up"
_3Up = 14, // MES_DPAD_BUTTON_3_UP
//% block="4 down"
_4Down = 15, // MES_DPAD_BUTTON_4_DOWN
//% block="4 up"
_4Up = 16, // MES_DPAD_BUTTON_4_UP
}
declare namespace devices {
}

View File

@ -1,24 +1,18 @@
{
"name": "devices",
"description": "The BLE specific services",
"description": "BETA - Camera, remote control and other Bluetooth services. App required.",
"files": [
"README.md",
"enums.d.ts",
"shims.d.ts",
"devices.cpp"
"devices.cpp",
"devices.ts"
],
"icon": "./static/packages/devices/icon.png",
"public": true,
"dependencies": {
"core": "file:../core"
},
"yotta": {
"config": {
"microbit-dal": {
"bluetooth": {
"enabled": 1
}
}
}
"core": "file:../core",
"bluetooth": "file:../bluetooth"
},
"installedVersion": "ljipgq"
}

View File

@ -4,58 +4,15 @@
/**
* Control a phone with the BBC micro:bit via Bluetooth.
*/
//% color=156 weight=80
//% color=#008272 weight=80 icon="\uf10b"
declare namespace devices {
/**
* Sends a ``camera`` command to the parent device.
* @param event event description
*/
//% weight=30 help=devices/tell-camera-to
//% blockId=devices_camera icon="\uf030" block="tell camera to|%property" blockGap=8 shim=devices::tellCameraTo
function tellCameraTo(event: MesCameraEvent): void;
/**
* Sends a ``remote control`` command to the parent device.
* @param event event description
*/
//% weight=29 help=devices/tell-remote-control-to
//% blockId=devices_remote_control block="tell remote control to|%property" blockGap=14 icon="\uf144" shim=devices::tellRemoteControlTo
function tellRemoteControlTo(event: MesRemoteControlEvent): void;
/**
* Sends an ``alert`` command to the parent device.
* @param event event description
*/
//% weight=27 help=devices/raise-alert-to
//% blockId=devices_alert block="raise alert to|%property" icon="\uf0f3" shim=devices::raiseAlertTo
function raiseAlertTo(event: MesAlertEvent): void;
/**
* Registers code to run when the device notifies about a particular event.
* @param event event description
* @param body code handler when event is triggered
*/
//% help=devices/on-notified weight=26
//% blockId=devices_device_info_event block="on notified|%event" icon="\uf10a" shim=devices::onNotified
function onNotified(event: MesDeviceInfo, body: () => void): void;
/**
* Register code to run when the micro:bit receives a command from the paired gamepad.
* @param name button name
* @param body code to run when button is pressed
*/
//% help=devices/on-gamepad-button weight=40
//% weight=25
//% blockId=devices_gamepad_event block="on gamepad button|%NAME" icon="\uf11b" shim=devices::onGamepadButton
function onGamepadButton(name: MesDpadButtonInfo, body: () => void): void;
/**
* Returns the last signal strength reported by the paired device.
*/
//% help=devices/signal-strength weight=24
//% blockId=devices_signal_strength block="signal strength" blockGap=14 icon="\uf012" blockGap=14 shim=devices::signalStrength
function signalStrength(): number;
function signalStrength(): int32;
/**
* Registers code to run when the device notifies about a change of signal strength.