support for exposing device name
This commit is contained in:
@ -155,4 +155,12 @@ namespace control {
|
||||
void onEvent(int src, int value, Action handler) {
|
||||
registerWithDal(src, value, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a friendly name for the device derived from the its serial number
|
||||
*/
|
||||
//% blockId="control_device_name" block="device name" weight=10
|
||||
StringData* deviceName() {
|
||||
return ManagedString(microbit_friendly_name()).leakData();
|
||||
}
|
||||
}
|
||||
|
6
libs/microbit/shims.d.ts
vendored
6
libs/microbit/shims.d.ts
vendored
@ -342,6 +342,12 @@ declare namespace control {
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value"
|
||||
//% blockExternalInputs=1 shim=control::onEvent
|
||||
function onEvent(src: number, value: number, handler: () => void): void;
|
||||
|
||||
/**
|
||||
* Gets a friendly name for the device derived from the its serial number
|
||||
*/
|
||||
//% blockId="control_device_name" block="device name" weight=10 shim=control::deviceName
|
||||
function deviceName(): string;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user