adds "parts" annotations...

...to libs/microbit and libs/microbit-bluetooth
This commit is contained in:
darzu
2016-08-22 08:48:48 -07:00
parent 47401e947c
commit 8b46698f50
9 changed files with 165 additions and 49 deletions

View File

@ -32,6 +32,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-io-pin-service
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
//% parts="bluetooth"
void startIOPinService() {
new MicroBitIOPinService(*uBit.ble, uBit.io);
}
@ -41,6 +42,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
//% parts="bluetooth"
void startLEDService() {
new MicroBitLEDService(*uBit.ble, uBit.display);
}
@ -50,6 +52,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
//% parts="bluetooth"
void startTemperatureService() {
new MicroBitTemperatureService(*uBit.ble, uBit.thermometer);
}
@ -59,6 +62,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
//% parts="bluetooth"
void startMagnetometerService() {
new MicroBitMagnetometerService(*uBit.ble, uBit.compass);
}
@ -68,6 +72,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
//% parts="bluetooth"
void startAccelerometerService() {
new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
}
@ -77,6 +82,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
//% parts="bluetooth"
void startButtonService() {
new MicroBitButtonService(*uBit.ble);
}
@ -86,6 +92,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-uart-service
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8
//% parts="bluetooth"
void startUartService() {
if (uart) return;
// 61 octet buffer size is 3 x (MTU - 3) + 1
@ -99,6 +106,7 @@ namespace bluetooth {
*/
//% help=bluetooth/uart-write
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8
//% parts="bluetooth"
void uartWrite(StringData *data) {
startUartService();
uart->send(ManagedString(data));
@ -109,6 +117,7 @@ namespace bluetooth {
*/
//% help=bluetooth/uart-read
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8
//% parts="bluetooth"
StringData* uartRead(StringData *del) {
startUartService();
return uart->readUntil(ManagedString(del)).leakData();
@ -119,6 +128,7 @@ namespace bluetooth {
*/
//% blockId="bluetooth_uart_delimiter_conv" block="%del"
//% weight=1
//% parts="bluetooth"
StringData* delimiters(Delimiters del) {
ManagedString c("\n\n,$:.#"[max(0, min(6, (int)del))]);
return c.leakData();
@ -129,6 +139,7 @@ namespace bluetooth {
*/
//% help=bluetooth/on-bluetooth-connected weight=20
//% blockId=bluetooth_on_connected block="on bluetooth connected" blockGap=8
//% parts="bluetooth"
void onBluetoothConnected(Action body) {
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, body);
}
@ -139,6 +150,7 @@ namespace bluetooth {
*/
//% help=bluetooth/on-bluetooth-disconnected weight=19
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected"
//% parts="bluetooth"
void onBluetoothDisconnected(Action body) {
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body);
}

View File

@ -11,70 +11,80 @@ declare namespace bluetooth {
* Starts the Bluetooth IO pin service.
*/
//% help=bluetooth/start-io-pin-service
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8 shim=bluetooth::startIOPinService
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startIOPinService
function startIOPinService(): void;
/**
* Starts the Bluetooth LED service
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8 shim=bluetooth::startLEDService
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startLEDService
function startLEDService(): void;
/**
* Starts the Bluetooth temperature service
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8 shim=bluetooth::startTemperatureService
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startTemperatureService
function startTemperatureService(): void;
/**
* Starts the Bluetooth magnetometer service
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8 shim=bluetooth::startMagnetometerService
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startMagnetometerService
function startMagnetometerService(): void;
/**
* Starts the Bluetooth accelerometer service
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8 shim=bluetooth::startAccelerometerService
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startAccelerometerService
function startAccelerometerService(): void;
/**
* Starts the Bluetooth button service
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8 shim=bluetooth::startButtonService
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startButtonService
function startButtonService(): void;
/**
* Starts the Bluetooth UART service
*/
//% help=bluetooth/start-uart-service
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8 shim=bluetooth::startUartService
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startUartService
function startUartService(): void;
/**
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
*/
//% help=bluetooth/uart-write
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8 shim=bluetooth::uartWrite
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8
//% parts="bluetooth" shim=bluetooth::uartWrite
function uartWrite(data: string): void;
/**
* Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.
*/
//% help=bluetooth/uart-read
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8 shim=bluetooth::uartRead
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8
//% parts="bluetooth" shim=bluetooth::uartRead
function uartRead(del: string): string;
/**
* Returns the delimiter corresponding string
*/
//% blockId="bluetooth_uart_delimiter_conv" block="%del"
//% weight=1 shim=bluetooth::delimiters
//% weight=1
//% parts="bluetooth" shim=bluetooth::delimiters
function delimiters(del: Delimiters): string;
/**
@ -82,7 +92,8 @@ declare namespace bluetooth {
* @param body Code to run when a Bluetooth connection is established
*/
//% help=bluetooth/on-bluetooth-connected weight=20
//% blockId=bluetooth_on_connected block="on bluetooth connected" blockGap=8 shim=bluetooth::onBluetoothConnected
//% blockId=bluetooth_on_connected block="on bluetooth connected" blockGap=8
//% parts="bluetooth" shim=bluetooth::onBluetoothConnected
function onBluetoothConnected(body: () => void): void;
/**
@ -90,7 +101,8 @@ declare namespace bluetooth {
* @param body Code to run when a Bluetooth connection is lost
*/
//% help=bluetooth/on-bluetooth-disconnected weight=19
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected" shim=bluetooth::onBluetoothDisconnected
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected"
//% parts="bluetooth" shim=bluetooth::onBluetoothDisconnected
function onBluetoothDisconnected(body: () => void): void;
}