Generate enums from C++
This commit is contained in:
parent
400b9269ee
commit
70bd81d9c2
@ -1,5 +1,119 @@
|
||||
#include "BitVM.h"
|
||||
|
||||
/**
|
||||
* How to create the event.
|
||||
*/
|
||||
enum class EventCreationMode {
|
||||
/**
|
||||
* MicroBitEvent is initialised, and no further processing takes place.
|
||||
*/
|
||||
CreateOnly = CREATE_ONLY,
|
||||
/**
|
||||
* MicroBitEvent is initialised, and queued on the MicroBitMessageBus.
|
||||
*/
|
||||
CreateAndQueue = CREATE_AND_QUEUE,
|
||||
/**
|
||||
* MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).
|
||||
*/
|
||||
CreateAndFire = CREATE_AND_FIRE,
|
||||
};
|
||||
|
||||
// note the trailing '_' in names - otherwise we get conflict with the pre-processor
|
||||
// this trailing underscore is removed by enums.d.ts generation process
|
||||
|
||||
// TODO shouldn't these be renamed to something more sensible anyways?
|
||||
|
||||
enum EventBusSource {
|
||||
MICROBIT_ID_BUTTON_A_ = MICROBIT_ID_BUTTON_A,
|
||||
MICROBIT_ID_BUTTON_B_ = MICROBIT_ID_BUTTON_B,
|
||||
MICROBIT_ID_BUTTON_AB_ = MICROBIT_ID_BUTTON_AB,
|
||||
MICROBIT_ID_RADIO_ = MICROBIT_ID_RADIO,
|
||||
MICROBIT_ID_GESTURE_ = MICROBIT_ID_GESTURE,
|
||||
MICROBIT_ID_ACCELEROMETER_ = MICROBIT_ID_ACCELEROMETER,
|
||||
MICROBIT_ID_IO_P0_ = MICROBIT_ID_IO_P0,
|
||||
MICROBIT_ID_IO_P1_ = MICROBIT_ID_IO_P1,
|
||||
MICROBIT_ID_IO_P2_ = MICROBIT_ID_IO_P2,
|
||||
MICROBIT_ID_IO_P3_ = MICROBIT_ID_IO_P3,
|
||||
MICROBIT_ID_IO_P4_ = MICROBIT_ID_IO_P4,
|
||||
MICROBIT_ID_IO_P5_ = MICROBIT_ID_IO_P5,
|
||||
MICROBIT_ID_IO_P6_ = MICROBIT_ID_IO_P6,
|
||||
MICROBIT_ID_IO_P7_ = MICROBIT_ID_IO_P7,
|
||||
MICROBIT_ID_IO_P8_ = MICROBIT_ID_IO_P8,
|
||||
MICROBIT_ID_IO_P9_ = MICROBIT_ID_IO_P9,
|
||||
MICROBIT_ID_IO_P10_ = MICROBIT_ID_IO_P10,
|
||||
MICROBIT_ID_IO_P11_ = MICROBIT_ID_IO_P11,
|
||||
MICROBIT_ID_IO_P12_ = MICROBIT_ID_IO_P12,
|
||||
MICROBIT_ID_IO_P13_ = MICROBIT_ID_IO_P13,
|
||||
MICROBIT_ID_IO_P14_ = MICROBIT_ID_IO_P14,
|
||||
MICROBIT_ID_IO_P15_ = MICROBIT_ID_IO_P15,
|
||||
MICROBIT_ID_IO_P16_ = MICROBIT_ID_IO_P16,
|
||||
MICROBIT_ID_IO_P19_ = MICROBIT_ID_IO_P19,
|
||||
MICROBIT_ID_IO_P20_ = MICROBIT_ID_IO_P20,
|
||||
MES_DEVICE_INFO_ID_ = MES_DEVICE_INFO_ID,
|
||||
MES_SIGNAL_STRENGTH_ID_ = MES_SIGNAL_STRENGTH_ID,
|
||||
MES_DPAD_CONTROLLER_ID_ = MES_DPAD_CONTROLLER_ID,
|
||||
MES_BROADCAST_GENERAL_ID_ = MES_BROADCAST_GENERAL_ID,
|
||||
};
|
||||
|
||||
enum EventBusValue {
|
||||
MICROBIT_EVT_ANY_ = MICROBIT_EVT_ANY,
|
||||
MICROBIT_BUTTON_EVT_CLICK_ = MICROBIT_BUTTON_EVT_CLICK,
|
||||
MICROBIT_RADIO_EVT_DATAGRAM_ = MICROBIT_RADIO_EVT_DATAGRAM,
|
||||
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE_ = MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE,
|
||||
MES_ALERT_EVT_ALARM1_ = MES_ALERT_EVT_ALARM1,
|
||||
MES_ALERT_EVT_ALARM2_ = MES_ALERT_EVT_ALARM2,
|
||||
MES_ALERT_EVT_ALARM3_ = MES_ALERT_EVT_ALARM3,
|
||||
MES_ALERT_EVT_ALARM4_ = MES_ALERT_EVT_ALARM4,
|
||||
MES_ALERT_EVT_ALARM5_ = MES_ALERT_EVT_ALARM5,
|
||||
MES_ALERT_EVT_ALARM6_ = MES_ALERT_EVT_ALARM6,
|
||||
MES_ALERT_EVT_DISPLAY_TOAST_ = MES_ALERT_EVT_DISPLAY_TOAST,
|
||||
MES_ALERT_EVT_FIND_MY_PHONE_ = MES_ALERT_EVT_FIND_MY_PHONE,
|
||||
MES_ALERT_EVT_PLAY_RINGTONE_ = MES_ALERT_EVT_PLAY_RINGTONE,
|
||||
MES_ALERT_EVT_PLAY_SOUND_ = MES_ALERT_EVT_PLAY_SOUND,
|
||||
MES_ALERT_EVT_VIBRATE_ = MES_ALERT_EVT_VIBRATE,
|
||||
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE_ = MES_CAMERA_EVT_LAUNCH_PHOTO_MODE,
|
||||
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE_ = MES_CAMERA_EVT_LAUNCH_VIDEO_MODE,
|
||||
MES_CAMERA_EVT_START_VIDEO_CAPTURE_ = MES_CAMERA_EVT_START_VIDEO_CAPTURE,
|
||||
MES_CAMERA_EVT_STOP_PHOTO_MODE_ = MES_CAMERA_EVT_STOP_PHOTO_MODE,
|
||||
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE_ = MES_CAMERA_EVT_STOP_VIDEO_CAPTURE,
|
||||
MES_CAMERA_EVT_STOP_VIDEO_MODE_ = MES_CAMERA_EVT_STOP_VIDEO_MODE,
|
||||
MES_CAMERA_EVT_TAKE_PHOTO_ = MES_CAMERA_EVT_TAKE_PHOTO,
|
||||
MES_CAMERA_EVT_TOGGLE_FRONT_REAR_ = MES_CAMERA_EVT_TOGGLE_FRONT_REAR,
|
||||
MES_DEVICE_DISPLAY_OFF_ = MES_DEVICE_DISPLAY_OFF,
|
||||
MES_DEVICE_DISPLAY_ON_ = MES_DEVICE_DISPLAY_ON,
|
||||
MES_DEVICE_GESTURE_DEVICE_SHAKEN_ = MES_DEVICE_GESTURE_DEVICE_SHAKEN,
|
||||
MES_DEVICE_INCOMING_CALL_ = MES_DEVICE_INCOMING_CALL,
|
||||
MES_DEVICE_INCOMING_MESSAGE_ = MES_DEVICE_INCOMING_MESSAGE,
|
||||
MES_DEVICE_ORIENTATION_LANDSCAPE_ = MES_DEVICE_ORIENTATION_LANDSCAPE,
|
||||
MES_DEVICE_ORIENTATION_PORTRAIT_ = MES_DEVICE_ORIENTATION_PORTRAIT,
|
||||
MES_DPAD_BUTTON_1_DOWN_ = MES_DPAD_BUTTON_1_DOWN,
|
||||
MES_DPAD_BUTTON_1_UP_ = MES_DPAD_BUTTON_1_UP,
|
||||
MES_DPAD_BUTTON_2_DOWN_ = MES_DPAD_BUTTON_2_DOWN,
|
||||
MES_DPAD_BUTTON_2_UP_ = MES_DPAD_BUTTON_2_UP,
|
||||
MES_DPAD_BUTTON_3_DOWN_ = MES_DPAD_BUTTON_3_DOWN,
|
||||
MES_DPAD_BUTTON_3_UP_ = MES_DPAD_BUTTON_3_UP,
|
||||
MES_DPAD_BUTTON_4_DOWN_ = MES_DPAD_BUTTON_4_DOWN,
|
||||
MES_DPAD_BUTTON_4_UP_ = MES_DPAD_BUTTON_4_UP,
|
||||
MES_DPAD_BUTTON_A_DOWN_ = MES_DPAD_BUTTON_A_DOWN,
|
||||
MES_DPAD_BUTTON_A_UP_ = MES_DPAD_BUTTON_A_UP,
|
||||
MES_DPAD_BUTTON_B_DOWN_ = MES_DPAD_BUTTON_B_DOWN,
|
||||
MES_DPAD_BUTTON_B_UP_ = MES_DPAD_BUTTON_B_UP,
|
||||
MES_DPAD_BUTTON_C_DOWN_ = MES_DPAD_BUTTON_C_DOWN,
|
||||
MES_DPAD_BUTTON_C_UP_ = MES_DPAD_BUTTON_C_UP,
|
||||
MES_DPAD_BUTTON_D_DOWN_ = MES_DPAD_BUTTON_D_DOWN,
|
||||
MES_DPAD_BUTTON_D_UP_ = MES_DPAD_BUTTON_D_UP,
|
||||
MES_REMOTE_CONTROL_EVT_FORWARD_ = MES_REMOTE_CONTROL_EVT_FORWARD,
|
||||
MES_REMOTE_CONTROL_EVT_NEXTTRACK_ = MES_REMOTE_CONTROL_EVT_NEXTTRACK,
|
||||
MES_REMOTE_CONTROL_EVT_PAUSE_ = MES_REMOTE_CONTROL_EVT_PAUSE,
|
||||
MES_REMOTE_CONTROL_EVT_PLAY_ = MES_REMOTE_CONTROL_EVT_PLAY,
|
||||
MES_REMOTE_CONTROL_EVT_PREVTRACK_ = MES_REMOTE_CONTROL_EVT_PREVTRACK,
|
||||
MES_REMOTE_CONTROL_EVT_REWIND_ = MES_REMOTE_CONTROL_EVT_REWIND,
|
||||
MES_REMOTE_CONTROL_EVT_STOP_ = MES_REMOTE_CONTROL_EVT_STOP,
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN_ = MES_REMOTE_CONTROL_EVT_VOLUMEDOWN,
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEUP_ = MES_REMOTE_CONTROL_EVT_VOLUMEUP,
|
||||
};
|
||||
|
||||
//% weight=1 color="#333333"
|
||||
namespace control {
|
||||
void fiberDone(void *a)
|
||||
{
|
||||
@ -27,4 +141,21 @@ namespace control {
|
||||
void reset() {
|
||||
uBit.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
* @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.
|
||||
* @param value Component specific code indicating the cause of the event.
|
||||
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_QUEUE).
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1
|
||||
//% mode.defl=CREATE_AND_QUEUE
|
||||
void raiseEvent(int src, int value, EventCreationMode mode) { }
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
*/
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value"
|
||||
//% blockExternalInputs=1 blockStatement=1
|
||||
void onEvent(int src, int value, Action handler) { }
|
||||
}
|
||||
|
@ -1,108 +1,3 @@
|
||||
enum EventCreationMode {
|
||||
/**
|
||||
* MicroBitEvent is initialised, and no further processing takes place.
|
||||
*/
|
||||
CreateOnly = DAL.CREATE_ONLY as number,
|
||||
/**
|
||||
* MicroBitEvent is initialised, and queued on the MicroBitMessageBus.
|
||||
*/
|
||||
CreateAndQueue = DAL.CREATE_AND_QUEUE as number,
|
||||
/**
|
||||
* MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).
|
||||
*/
|
||||
CreateAndFire = DAL.CREATE_AND_FIRE as number,
|
||||
}
|
||||
|
||||
enum EventBusSource {
|
||||
MICROBIT_ID_BUTTON_A = DAL.MICROBIT_ID_BUTTON_A as number,
|
||||
MICROBIT_ID_BUTTON_B = DAL.MICROBIT_ID_BUTTON_B as number,
|
||||
MICROBIT_ID_BUTTON_AB = DAL.MICROBIT_ID_BUTTON_AB as number,
|
||||
MICROBIT_ID_RADIO = DAL.MICROBIT_ID_RADIO as number,
|
||||
MICROBIT_ID_GESTURE = DAL.MICROBIT_ID_GESTURE as number,
|
||||
MICROBIT_ID_ACCELEROMETER = DAL.MICROBIT_ID_ACCELEROMETER as number,
|
||||
MICROBIT_ID_IO_P0 = DAL.MICROBIT_ID_IO_P0 as number,
|
||||
MICROBIT_ID_IO_P1 = DAL.MICROBIT_ID_IO_P1 as number,
|
||||
MICROBIT_ID_IO_P2 = DAL.MICROBIT_ID_IO_P2 as number,
|
||||
MICROBIT_ID_IO_P3 = DAL.MICROBIT_ID_IO_P3 as number,
|
||||
MICROBIT_ID_IO_P4 = DAL.MICROBIT_ID_IO_P4 as number,
|
||||
MICROBIT_ID_IO_P5 = DAL.MICROBIT_ID_IO_P5 as number,
|
||||
MICROBIT_ID_IO_P6 = DAL.MICROBIT_ID_IO_P6 as number,
|
||||
MICROBIT_ID_IO_P7 = DAL.MICROBIT_ID_IO_P7 as number,
|
||||
MICROBIT_ID_IO_P8 = DAL.MICROBIT_ID_IO_P8 as number,
|
||||
MICROBIT_ID_IO_P9 = DAL.MICROBIT_ID_IO_P9 as number,
|
||||
MICROBIT_ID_IO_P10 = DAL.MICROBIT_ID_IO_P10 as number,
|
||||
MICROBIT_ID_IO_P11 = DAL.MICROBIT_ID_IO_P11 as number,
|
||||
MICROBIT_ID_IO_P12 = DAL.MICROBIT_ID_IO_P12 as number,
|
||||
MICROBIT_ID_IO_P13 = DAL.MICROBIT_ID_IO_P13 as number,
|
||||
MICROBIT_ID_IO_P14 = DAL.MICROBIT_ID_IO_P14 as number,
|
||||
MICROBIT_ID_IO_P15 = DAL.MICROBIT_ID_IO_P15 as number,
|
||||
MICROBIT_ID_IO_P16 = DAL.MICROBIT_ID_IO_P16 as number,
|
||||
MICROBIT_ID_IO_P19 = DAL.MICROBIT_ID_IO_P19 as number,
|
||||
MICROBIT_ID_IO_P20 = DAL.MICROBIT_ID_IO_P20 as number,
|
||||
MES_DEVICE_INFO_ID = DAL.MES_DEVICE_INFO_ID as number,
|
||||
MES_SIGNAL_STRENGTH_ID = DAL.MES_SIGNAL_STRENGTH_ID as number,
|
||||
MES_DPAD_CONTROLLER_ID = DAL.MES_DPAD_CONTROLLER_ID as number,
|
||||
MES_BROADCAST_GENERAL_ID = DAL.MES_BROADCAST_GENERAL_ID as number,
|
||||
}
|
||||
|
||||
enum EventBusValue {
|
||||
MICROBIT_EVT_ANY = DAL.MICROBIT_EVT_ANY as number,
|
||||
MICROBIT_BUTTON_EVT_CLICK = DAL.MICROBIT_BUTTON_EVT_CLICK as number,
|
||||
MICROBIT_RADIO_EVT_DATAGRAM = DAL.MICROBIT_RADIO_EVT_DATAGRAM as number,
|
||||
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = DAL.MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE as number,
|
||||
MES_ALERT_EVT_ALARM1 = DAL.MES_ALERT_EVT_ALARM1 as number,
|
||||
MES_ALERT_EVT_ALARM2 = DAL.MES_ALERT_EVT_ALARM2 as number,
|
||||
MES_ALERT_EVT_ALARM3 = DAL.MES_ALERT_EVT_ALARM3 as number,
|
||||
MES_ALERT_EVT_ALARM4 = DAL.MES_ALERT_EVT_ALARM4 as number,
|
||||
MES_ALERT_EVT_ALARM5 = DAL.MES_ALERT_EVT_ALARM5 as number,
|
||||
MES_ALERT_EVT_ALARM6 = DAL.MES_ALERT_EVT_ALARM6 as number,
|
||||
MES_ALERT_EVT_DISPLAY_TOAST = DAL.MES_ALERT_EVT_DISPLAY_TOAST as number,
|
||||
MES_ALERT_EVT_FIND_MY_PHONE = DAL.MES_ALERT_EVT_FIND_MY_PHONE as number,
|
||||
MES_ALERT_EVT_PLAY_RINGTONE = DAL.MES_ALERT_EVT_PLAY_RINGTONE as number,
|
||||
MES_ALERT_EVT_PLAY_SOUND = DAL.MES_ALERT_EVT_PLAY_SOUND as number,
|
||||
MES_ALERT_EVT_VIBRATE = DAL.MES_ALERT_EVT_VIBRATE as number,
|
||||
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE = DAL.MES_CAMERA_EVT_LAUNCH_PHOTO_MODE as number,
|
||||
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE = DAL.MES_CAMERA_EVT_LAUNCH_VIDEO_MODE as number,
|
||||
MES_CAMERA_EVT_START_VIDEO_CAPTURE = DAL.MES_CAMERA_EVT_START_VIDEO_CAPTURE as number,
|
||||
MES_CAMERA_EVT_STOP_PHOTO_MODE = DAL.MES_CAMERA_EVT_STOP_PHOTO_MODE as number,
|
||||
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE = DAL.MES_CAMERA_EVT_STOP_VIDEO_CAPTURE as number,
|
||||
MES_CAMERA_EVT_STOP_VIDEO_MODE = DAL.MES_CAMERA_EVT_STOP_VIDEO_MODE as number,
|
||||
MES_CAMERA_EVT_TAKE_PHOTO = DAL.MES_CAMERA_EVT_TAKE_PHOTO as number,
|
||||
MES_CAMERA_EVT_TOGGLE_FRONT_REAR = DAL.MES_CAMERA_EVT_TOGGLE_FRONT_REAR as number,
|
||||
MES_DEVICE_DISPLAY_OFF = DAL.MES_DEVICE_DISPLAY_OFF as number,
|
||||
MES_DEVICE_DISPLAY_ON = DAL.MES_DEVICE_DISPLAY_ON as number,
|
||||
MES_DEVICE_GESTURE_DEVICE_SHAKEN = DAL.MES_DEVICE_GESTURE_DEVICE_SHAKEN as number,
|
||||
MES_DEVICE_INCOMING_CALL = DAL.MES_DEVICE_INCOMING_CALL as number,
|
||||
MES_DEVICE_INCOMING_MESSAGE = DAL.MES_DEVICE_INCOMING_MESSAGE as number,
|
||||
MES_DEVICE_ORIENTATION_LANDSCAPE = DAL.MES_DEVICE_ORIENTATION_LANDSCAPE as number,
|
||||
MES_DEVICE_ORIENTATION_PORTRAIT = DAL.MES_DEVICE_ORIENTATION_PORTRAIT as number,
|
||||
MES_DPAD_BUTTON_1_DOWN = DAL.MES_DPAD_BUTTON_1_DOWN as number,
|
||||
MES_DPAD_BUTTON_1_UP = DAL.MES_DPAD_BUTTON_1_UP as number,
|
||||
MES_DPAD_BUTTON_2_DOWN = DAL.MES_DPAD_BUTTON_2_DOWN as number,
|
||||
MES_DPAD_BUTTON_2_UP = DAL.MES_DPAD_BUTTON_2_UP as number,
|
||||
MES_DPAD_BUTTON_3_DOWN = DAL.MES_DPAD_BUTTON_3_DOWN as number,
|
||||
MES_DPAD_BUTTON_3_UP = DAL.MES_DPAD_BUTTON_3_UP as number,
|
||||
MES_DPAD_BUTTON_4_DOWN = DAL.MES_DPAD_BUTTON_4_DOWN as number,
|
||||
MES_DPAD_BUTTON_4_UP = DAL.MES_DPAD_BUTTON_4_UP as number,
|
||||
MES_DPAD_BUTTON_A_DOWN = DAL.MES_DPAD_BUTTON_A_DOWN as number,
|
||||
MES_DPAD_BUTTON_A_UP = DAL.MES_DPAD_BUTTON_A_UP as number,
|
||||
MES_DPAD_BUTTON_B_DOWN = DAL.MES_DPAD_BUTTON_B_DOWN as number,
|
||||
MES_DPAD_BUTTON_B_UP = DAL.MES_DPAD_BUTTON_B_UP as number,
|
||||
MES_DPAD_BUTTON_C_DOWN = DAL.MES_DPAD_BUTTON_C_DOWN as number,
|
||||
MES_DPAD_BUTTON_C_UP = DAL.MES_DPAD_BUTTON_C_UP as number,
|
||||
MES_DPAD_BUTTON_D_DOWN = DAL.MES_DPAD_BUTTON_D_DOWN as number,
|
||||
MES_DPAD_BUTTON_D_UP = DAL.MES_DPAD_BUTTON_D_UP as number,
|
||||
MES_REMOTE_CONTROL_EVT_FORWARD = DAL.MES_REMOTE_CONTROL_EVT_FORWARD as number,
|
||||
MES_REMOTE_CONTROL_EVT_NEXTTRACK = DAL.MES_REMOTE_CONTROL_EVT_NEXTTRACK as number,
|
||||
MES_REMOTE_CONTROL_EVT_PAUSE = DAL.MES_REMOTE_CONTROL_EVT_PAUSE as number,
|
||||
MES_REMOTE_CONTROL_EVT_PLAY = DAL.MES_REMOTE_CONTROL_EVT_PLAY as number,
|
||||
MES_REMOTE_CONTROL_EVT_PREVTRACK = DAL.MES_REMOTE_CONTROL_EVT_PREVTRACK as number,
|
||||
MES_REMOTE_CONTROL_EVT_REWIND = DAL.MES_REMOTE_CONTROL_EVT_REWIND as number,
|
||||
MES_REMOTE_CONTROL_EVT_STOP = DAL.MES_REMOTE_CONTROL_EVT_STOP as number,
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN = DAL.MES_REMOTE_CONTROL_EVT_VOLUMEDOWN as number,
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEUP = DAL.MES_REMOTE_CONTROL_EVT_VOLUMEUP as number,
|
||||
}
|
||||
|
||||
//% weight=1 color="#333333"
|
||||
namespace control {
|
||||
|
||||
@ -120,22 +15,4 @@ namespace control {
|
||||
export function eventValue(id: EventBusValue) : number {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
* @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.
|
||||
* @param value Component specific code indicating the cause of the event.
|
||||
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_QUEUE).
|
||||
*/
|
||||
// shim=micro_bit::busRaiseEvent
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1
|
||||
export function raiseEvent(src: number, value: number, mode: EventCreationMode = EventCreationMode.CreateAndQueue): void { }
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
*/
|
||||
// shim=micro_bit::onBusEvent
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value"
|
||||
//% blockExternalInputs=1 blockStatement=1
|
||||
export function onEvent(src: number, value: number, handler: Action): void { }
|
||||
}
|
||||
|
225
libs/microbit/enums.d.ts
vendored
Normal file
225
libs/microbit/enums.d.ts
vendored
Normal file
@ -0,0 +1,225 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare namespace basic {
|
||||
}
|
||||
|
||||
|
||||
declare enum Button {
|
||||
A = 1, // MICROBIT_ID_BUTTON_A
|
||||
B = 2, // MICROBIT_ID_BUTTON_B
|
||||
//% block="A+B"
|
||||
AB = 26, // MICROBIT_ID_BUTTON_AB
|
||||
}
|
||||
|
||||
|
||||
declare enum Dimension {
|
||||
//% block=x
|
||||
X = 0,
|
||||
//% block=y
|
||||
Y = 1,
|
||||
//% block=z
|
||||
Z = 2,
|
||||
//% block=strength
|
||||
Strength = 3,
|
||||
}
|
||||
|
||||
|
||||
declare enum Rotation {
|
||||
//% block=pitch
|
||||
Pitch = 0,
|
||||
//% block=roll
|
||||
Roll = 1,
|
||||
}
|
||||
|
||||
|
||||
declare enum TouchPin {
|
||||
//% enumval=uBit.io.P0
|
||||
P0 = 0,
|
||||
//% enumval=uBit.io.P1
|
||||
P1 = 1,
|
||||
//% enumval=uBit.io.P2
|
||||
P2 = 2,
|
||||
}
|
||||
|
||||
|
||||
declare enum AcceleratorRange {
|
||||
/**
|
||||
* The accelerator measures forces up to 1 gravity
|
||||
*/
|
||||
//% block="1g"
|
||||
OneG = 1,
|
||||
/**
|
||||
* The accelerator measures forces up to 2 gravity
|
||||
*/
|
||||
//% block="2g"
|
||||
TwoG = 2,
|
||||
/**
|
||||
* The accelerator measures forces up to 4 gravity
|
||||
*/
|
||||
//% block="4g"
|
||||
FourG = 4,
|
||||
/**
|
||||
* The accelerator measures forces up to 8 gravity
|
||||
*/
|
||||
//% block="8g"
|
||||
EightG = 8,
|
||||
}
|
||||
|
||||
|
||||
declare enum Gesture {
|
||||
/**
|
||||
* Raised when shaken
|
||||
*/
|
||||
//% block=shake
|
||||
Shake = 11, // GESTURE_SHAKE
|
||||
/**
|
||||
* Raised when the logo is upward and the screen is vertical
|
||||
*/
|
||||
//% block="logo up"
|
||||
LogoUp = 1, // GESTURE_UP
|
||||
/**
|
||||
* Raised when the logo is downward and the screen is vertical
|
||||
*/
|
||||
//% block="logo down"
|
||||
LogoDown = 2, // GESTURE_DOWN
|
||||
/**
|
||||
* Raised when the screen is pointing down and the board is horizontal
|
||||
*/
|
||||
//% block="screen up"
|
||||
ScreenUp = 5, // GESTURE_FACE_UP
|
||||
/**
|
||||
* Raised when the screen is pointing up and the board is horizontal
|
||||
*/
|
||||
//% block="screen down"
|
||||
ScreenDown = 6, // GESTURE_FACE_DOWN
|
||||
/**
|
||||
* Raised when the screen is pointing left
|
||||
*/
|
||||
//% block="tilt left"
|
||||
TiltLeft = 3, // GESTURE_LEFT
|
||||
/**
|
||||
* Raised when the screen is pointing right
|
||||
*/
|
||||
//% block="tilt right"
|
||||
TiltRight = 4, // GESTURE_RIGHT
|
||||
/**
|
||||
* Raised when the board is falling!
|
||||
*/
|
||||
//% block="free fall"
|
||||
FreeFall = 7, // GESTURE_FREEFALL
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* How to create the event.
|
||||
*/
|
||||
|
||||
declare enum EventCreationMode {
|
||||
/**
|
||||
* MicroBitEvent is initialised, and no further processing takes place.
|
||||
*/
|
||||
CreateOnly = 0, // CREATE_ONLY
|
||||
/**
|
||||
* MicroBitEvent is initialised, and queued on the MicroBitMessageBus.
|
||||
*/
|
||||
CreateAndQueue = 1, // CREATE_AND_QUEUE
|
||||
/**
|
||||
* MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).
|
||||
*/
|
||||
CreateAndFire = 2, // CREATE_AND_FIRE
|
||||
}
|
||||
|
||||
|
||||
declare enum EventBusSource {
|
||||
MICROBIT_ID_BUTTON_A = 1, // MICROBIT_ID_BUTTON_A
|
||||
MICROBIT_ID_BUTTON_B = 2, // MICROBIT_ID_BUTTON_B
|
||||
MICROBIT_ID_BUTTON_AB = 26, // MICROBIT_ID_BUTTON_AB
|
||||
MICROBIT_ID_RADIO = 29, // MICROBIT_ID_RADIO
|
||||
MICROBIT_ID_GESTURE = 27, // MICROBIT_ID_GESTURE
|
||||
MICROBIT_ID_ACCELEROMETER = 4, // MICROBIT_ID_ACCELEROMETER
|
||||
MICROBIT_ID_IO_P0 = 7, // MICROBIT_ID_IO_P0
|
||||
MICROBIT_ID_IO_P1 = 8, // MICROBIT_ID_IO_P1
|
||||
MICROBIT_ID_IO_P2 = 9, // MICROBIT_ID_IO_P2
|
||||
MICROBIT_ID_IO_P3 = 10, // MICROBIT_ID_IO_P3
|
||||
MICROBIT_ID_IO_P4 = 11, // MICROBIT_ID_IO_P4
|
||||
MICROBIT_ID_IO_P5 = 12, // MICROBIT_ID_IO_P5
|
||||
MICROBIT_ID_IO_P6 = 13, // MICROBIT_ID_IO_P6
|
||||
MICROBIT_ID_IO_P7 = 14, // MICROBIT_ID_IO_P7
|
||||
MICROBIT_ID_IO_P8 = 15, // MICROBIT_ID_IO_P8
|
||||
MICROBIT_ID_IO_P9 = 16, // MICROBIT_ID_IO_P9
|
||||
MICROBIT_ID_IO_P10 = 17, // MICROBIT_ID_IO_P10
|
||||
MICROBIT_ID_IO_P11 = 18, // MICROBIT_ID_IO_P11
|
||||
MICROBIT_ID_IO_P12 = 19, // MICROBIT_ID_IO_P12
|
||||
MICROBIT_ID_IO_P13 = 20, // MICROBIT_ID_IO_P13
|
||||
MICROBIT_ID_IO_P14 = 21, // MICROBIT_ID_IO_P14
|
||||
MICROBIT_ID_IO_P15 = 22, // MICROBIT_ID_IO_P15
|
||||
MICROBIT_ID_IO_P16 = 23, // MICROBIT_ID_IO_P16
|
||||
MICROBIT_ID_IO_P19 = 24, // MICROBIT_ID_IO_P19
|
||||
MICROBIT_ID_IO_P20 = 25, // MICROBIT_ID_IO_P20
|
||||
MES_DEVICE_INFO_ID = 1103, // MES_DEVICE_INFO_ID
|
||||
MES_SIGNAL_STRENGTH_ID = 1101, // MES_SIGNAL_STRENGTH_ID
|
||||
MES_DPAD_CONTROLLER_ID = 1104, // MES_DPAD_CONTROLLER_ID
|
||||
MES_BROADCAST_GENERAL_ID = 2000, // MES_BROADCAST_GENERAL_ID
|
||||
}
|
||||
|
||||
|
||||
declare enum EventBusValue {
|
||||
MICROBIT_EVT_ANY = 0, // MICROBIT_EVT_ANY
|
||||
MICROBIT_BUTTON_EVT_CLICK = 3, // MICROBIT_BUTTON_EVT_CLICK
|
||||
MICROBIT_RADIO_EVT_DATAGRAM = 1, // MICROBIT_RADIO_EVT_DATAGRAM
|
||||
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1, // MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE
|
||||
MES_ALERT_EVT_ALARM1 = 6, // MES_ALERT_EVT_ALARM1
|
||||
MES_ALERT_EVT_ALARM2 = 7, // MES_ALERT_EVT_ALARM2
|
||||
MES_ALERT_EVT_ALARM3 = 8, // MES_ALERT_EVT_ALARM3
|
||||
MES_ALERT_EVT_ALARM4 = 9, // MES_ALERT_EVT_ALARM4
|
||||
MES_ALERT_EVT_ALARM5 = 10, // MES_ALERT_EVT_ALARM5
|
||||
MES_ALERT_EVT_ALARM6 = 11, // MES_ALERT_EVT_ALARM6
|
||||
MES_ALERT_EVT_DISPLAY_TOAST = 1, // MES_ALERT_EVT_DISPLAY_TOAST
|
||||
MES_ALERT_EVT_FIND_MY_PHONE = 5, // MES_ALERT_EVT_FIND_MY_PHONE
|
||||
MES_ALERT_EVT_PLAY_RINGTONE = 4, // MES_ALERT_EVT_PLAY_RINGTONE
|
||||
MES_ALERT_EVT_PLAY_SOUND = 3, // MES_ALERT_EVT_PLAY_SOUND
|
||||
MES_ALERT_EVT_VIBRATE = 2, // MES_ALERT_EVT_VIBRATE
|
||||
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE = 1, // MES_CAMERA_EVT_LAUNCH_PHOTO_MODE
|
||||
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE = 2, // MES_CAMERA_EVT_LAUNCH_VIDEO_MODE
|
||||
MES_CAMERA_EVT_START_VIDEO_CAPTURE = 4, // MES_CAMERA_EVT_START_VIDEO_CAPTURE
|
||||
MES_CAMERA_EVT_STOP_PHOTO_MODE = 6, // MES_CAMERA_EVT_STOP_PHOTO_MODE
|
||||
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE = 5, // MES_CAMERA_EVT_STOP_VIDEO_CAPTURE
|
||||
MES_CAMERA_EVT_STOP_VIDEO_MODE = 7, // MES_CAMERA_EVT_STOP_VIDEO_MODE
|
||||
MES_CAMERA_EVT_TAKE_PHOTO = 3, // MES_CAMERA_EVT_TAKE_PHOTO
|
||||
MES_CAMERA_EVT_TOGGLE_FRONT_REAR = 8, // MES_CAMERA_EVT_TOGGLE_FRONT_REAR
|
||||
MES_DEVICE_DISPLAY_OFF = 5, // MES_DEVICE_DISPLAY_OFF
|
||||
MES_DEVICE_DISPLAY_ON = 6, // MES_DEVICE_DISPLAY_ON
|
||||
MES_DEVICE_GESTURE_DEVICE_SHAKEN = 4, // MES_DEVICE_GESTURE_DEVICE_SHAKEN
|
||||
MES_DEVICE_INCOMING_CALL = 7, // MES_DEVICE_INCOMING_CALL
|
||||
MES_DEVICE_INCOMING_MESSAGE = 8, // MES_DEVICE_INCOMING_MESSAGE
|
||||
MES_DEVICE_ORIENTATION_LANDSCAPE = 1, // MES_DEVICE_ORIENTATION_LANDSCAPE
|
||||
MES_DEVICE_ORIENTATION_PORTRAIT = 2, // MES_DEVICE_ORIENTATION_PORTRAIT
|
||||
MES_DPAD_BUTTON_1_DOWN = 9, // MES_DPAD_BUTTON_1_DOWN
|
||||
MES_DPAD_BUTTON_1_UP = 10, // MES_DPAD_BUTTON_1_UP
|
||||
MES_DPAD_BUTTON_2_DOWN = 11, // MES_DPAD_BUTTON_2_DOWN
|
||||
MES_DPAD_BUTTON_2_UP = 12, // MES_DPAD_BUTTON_2_UP
|
||||
MES_DPAD_BUTTON_3_DOWN = 13, // MES_DPAD_BUTTON_3_DOWN
|
||||
MES_DPAD_BUTTON_3_UP = 14, // MES_DPAD_BUTTON_3_UP
|
||||
MES_DPAD_BUTTON_4_DOWN = 15, // MES_DPAD_BUTTON_4_DOWN
|
||||
MES_DPAD_BUTTON_4_UP = 16, // MES_DPAD_BUTTON_4_UP
|
||||
MES_DPAD_BUTTON_A_DOWN = 1, // MES_DPAD_BUTTON_A_DOWN
|
||||
MES_DPAD_BUTTON_A_UP = 2, // MES_DPAD_BUTTON_A_UP
|
||||
MES_DPAD_BUTTON_B_DOWN = 3, // MES_DPAD_BUTTON_B_DOWN
|
||||
MES_DPAD_BUTTON_B_UP = 4, // MES_DPAD_BUTTON_B_UP
|
||||
MES_DPAD_BUTTON_C_DOWN = 5, // MES_DPAD_BUTTON_C_DOWN
|
||||
MES_DPAD_BUTTON_C_UP = 6, // MES_DPAD_BUTTON_C_UP
|
||||
MES_DPAD_BUTTON_D_DOWN = 7, // MES_DPAD_BUTTON_D_DOWN
|
||||
MES_DPAD_BUTTON_D_UP = 8, // MES_DPAD_BUTTON_D_UP
|
||||
MES_REMOTE_CONTROL_EVT_FORWARD = 6, // MES_REMOTE_CONTROL_EVT_FORWARD
|
||||
MES_REMOTE_CONTROL_EVT_NEXTTRACK = 4, // MES_REMOTE_CONTROL_EVT_NEXTTRACK
|
||||
MES_REMOTE_CONTROL_EVT_PAUSE = 2, // MES_REMOTE_CONTROL_EVT_PAUSE
|
||||
MES_REMOTE_CONTROL_EVT_PLAY = 1, // MES_REMOTE_CONTROL_EVT_PLAY
|
||||
MES_REMOTE_CONTROL_EVT_PREVTRACK = 5, // MES_REMOTE_CONTROL_EVT_PREVTRACK
|
||||
MES_REMOTE_CONTROL_EVT_REWIND = 7, // MES_REMOTE_CONTROL_EVT_REWIND
|
||||
MES_REMOTE_CONTROL_EVT_STOP = 3, // MES_REMOTE_CONTROL_EVT_STOP
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN = 9, // MES_REMOTE_CONTROL_EVT_VOLUMEDOWN
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEUP = 8, // MES_REMOTE_CONTROL_EVT_VOLUMEUP
|
||||
}
|
||||
declare namespace control {
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
101
libs/microbit/input.cpp
Normal file
101
libs/microbit/input.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
#include "BitVM.h"
|
||||
|
||||
enum class Button {
|
||||
A = MICROBIT_ID_BUTTON_A,
|
||||
B = MICROBIT_ID_BUTTON_B,
|
||||
//% block="A+B"
|
||||
AB = MICROBIT_ID_BUTTON_AB,
|
||||
};
|
||||
|
||||
enum class Dimension {
|
||||
//% block=x
|
||||
X = 0,
|
||||
//% block=y
|
||||
Y = 1,
|
||||
//% block=z
|
||||
Z = 2,
|
||||
//% block=strength
|
||||
Strength = 3,
|
||||
};
|
||||
|
||||
enum class Rotation {
|
||||
//% block=pitch
|
||||
Pitch = 0,
|
||||
//% block=roll
|
||||
Roll = 1,
|
||||
};
|
||||
|
||||
enum class TouchPin {
|
||||
//% enumval=uBit.io.P0
|
||||
P0,
|
||||
//% enumval=uBit.io.P1
|
||||
P1,
|
||||
//% enumval=uBit.io.P2
|
||||
P2,
|
||||
};
|
||||
|
||||
enum class AcceleratorRange {
|
||||
/**
|
||||
* The accelerator measures forces up to 1 gravity
|
||||
*/
|
||||
//% block="1g"
|
||||
OneG = 1,
|
||||
/**
|
||||
* The accelerator measures forces up to 2 gravity
|
||||
*/
|
||||
//% block="2g"
|
||||
TwoG = 2,
|
||||
/**
|
||||
* The accelerator measures forces up to 4 gravity
|
||||
*/
|
||||
//% block="4g"
|
||||
FourG = 4,
|
||||
/**
|
||||
* The accelerator measures forces up to 8 gravity
|
||||
*/
|
||||
//% block="8g"
|
||||
EightG = 8
|
||||
};
|
||||
|
||||
enum class Gesture {
|
||||
/**
|
||||
* Raised when shaken
|
||||
*/
|
||||
//% block=shake
|
||||
Shake = GESTURE_SHAKE,
|
||||
/**
|
||||
* Raised when the logo is upward and the screen is vertical
|
||||
*/
|
||||
//% block="logo up"
|
||||
LogoUp = GESTURE_UP,
|
||||
/**
|
||||
* Raised when the logo is downward and the screen is vertical
|
||||
*/
|
||||
//% block="logo down"
|
||||
LogoDown = GESTURE_DOWN,
|
||||
/**
|
||||
* Raised when the screen is pointing down and the board is horizontal
|
||||
*/
|
||||
//% block="screen up"
|
||||
ScreenUp = GESTURE_FACE_UP,
|
||||
/**
|
||||
* Raised when the screen is pointing up and the board is horizontal
|
||||
*/
|
||||
//% block="screen down"
|
||||
ScreenDown = GESTURE_FACE_DOWN,
|
||||
/**
|
||||
* Raised when the screen is pointing left
|
||||
*/
|
||||
//% block="tilt left"
|
||||
TiltLeft = GESTURE_LEFT,
|
||||
/**
|
||||
* Raised when the screen is pointing right
|
||||
*/
|
||||
//% block="tilt right"
|
||||
TiltRight = GESTURE_RIGHT,
|
||||
/**
|
||||
* Raised when the board is falling!
|
||||
*/
|
||||
//% block="free fall"
|
||||
FreeFall = GESTURE_FREEFALL
|
||||
};
|
@ -1,121 +1,3 @@
|
||||
enum Button {
|
||||
A = DAL.MICROBIT_ID_BUTTON_A as number,
|
||||
B = DAL.MICROBIT_ID_BUTTON_B as number,
|
||||
//% block="A+B"
|
||||
AB = DAL.MICROBIT_ID_BUTTON_AB as number,
|
||||
}
|
||||
|
||||
enum Dimension {
|
||||
//% block=x
|
||||
X = 0,
|
||||
//% block=y
|
||||
Y = 1,
|
||||
//% block=z
|
||||
Z = 2,
|
||||
//% block=strength
|
||||
Strength = 3,
|
||||
}
|
||||
|
||||
enum Rotation {
|
||||
//% block=pitch
|
||||
Pitch = 0,
|
||||
//% block=roll
|
||||
Roll = 1,
|
||||
}
|
||||
|
||||
enum TouchPin {
|
||||
//% enumval=uBit.io.P0
|
||||
P0,
|
||||
//% enumval=uBit.io.P1
|
||||
P1,
|
||||
//% enumval=uBit.io.P2
|
||||
P2,
|
||||
}
|
||||
|
||||
enum AcceleratorRange {
|
||||
/**
|
||||
* The accelerator measures forces up to 1 gravity
|
||||
*/
|
||||
//% block="1g"
|
||||
OneG = 1,
|
||||
/**
|
||||
* The accelerator measures forces up to 2 gravity
|
||||
*/
|
||||
//% block="2g"
|
||||
TwoG = 2,
|
||||
/**
|
||||
* The accelerator measures forces up to 4 gravity
|
||||
*/
|
||||
//% block="4g"
|
||||
FourG = 4,
|
||||
/**
|
||||
* The accelerator measures forces up to 8 gravity
|
||||
*/
|
||||
//% block="8g"
|
||||
EightG = 8
|
||||
}
|
||||
|
||||
/*
|
||||
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
|
||||
};
|
||||
*/
|
||||
|
||||
enum Gesture {
|
||||
/**
|
||||
* Raised when shaken
|
||||
*/
|
||||
//% block=shake
|
||||
Shake = 11,
|
||||
/**
|
||||
* Raised when the logo is upward and the screen is vertical
|
||||
*/
|
||||
//% block="logo up"
|
||||
LogoUp = 1,
|
||||
/**
|
||||
* Raised when the logo is downward and the screen is vertical
|
||||
*/
|
||||
//% block="logo down"
|
||||
LogoDown = 2,
|
||||
/**
|
||||
* Raised when the screen is pointing down and the board is horizontal
|
||||
*/
|
||||
//% block="screen up"
|
||||
ScreenUp = 5,
|
||||
/**
|
||||
* Raised when the screen is pointing up and the board is horizontal
|
||||
*/
|
||||
//% block="screen down"
|
||||
ScreenDown = 6,
|
||||
/**
|
||||
* Raised when the screen is pointing left
|
||||
*/
|
||||
//% block="tilt left"
|
||||
TiltLeft = 3,
|
||||
/**
|
||||
* Raised when the screen is pointing right
|
||||
*/
|
||||
//% block="tilt right"
|
||||
TiltRight = 4,
|
||||
/**
|
||||
* Raised when the board is falling!
|
||||
*/
|
||||
//% block="free fall"
|
||||
FreeFall = 7
|
||||
}
|
||||
|
||||
//% color=300 weight=99
|
||||
namespace input {
|
||||
/**
|
||||
|
@ -5,10 +5,13 @@
|
||||
"files": [
|
||||
"README.md",
|
||||
"dal.d.ts",
|
||||
"enums.d.ts",
|
||||
"shims.d.ts",
|
||||
"core.d.ts",
|
||||
"mbit.ts",
|
||||
"images.ts",
|
||||
"basic.cpp",
|
||||
"input.cpp",
|
||||
"input.ts",
|
||||
"control.ts",
|
||||
"control.cpp",
|
||||
|
125
libs/microbit/shims.d.ts
vendored
Normal file
125
libs/microbit/shims.d.ts
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
// Auto-generated. Do not edit.
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to basic micro:bit functionality.
|
||||
*/
|
||||
//% color=190 weight=100
|
||||
declare namespace basic {
|
||||
|
||||
/**
|
||||
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
|
||||
* @param interval speed of scroll; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||
//% async
|
||||
//% interval.defl=150 shim=basic::showNumber
|
||||
function showNumber(value: number, interval?: number): void;
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds TODO
|
||||
* @param interval TODO
|
||||
*/
|
||||
//% help=basic/show-leds
|
||||
//% weight=95 blockGap=8
|
||||
//% imageLiteral=1 async
|
||||
//% blockId=device_show_leds
|
||||
//% block="show leds" icon="\uf00a"
|
||||
//% interval.defl=400 imageLiteral=1 shim=basic::showLeds
|
||||
function showLeds(leds: string, interval?: number): void;
|
||||
|
||||
/**
|
||||
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
|
||||
* @param text the text to scroll on the screen, eg: "Hello!"
|
||||
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-string
|
||||
//% weight=87 blockGap=8
|
||||
//% block="show|string %text" icon="\uf031"
|
||||
//% async
|
||||
//% blockId=device_print_message
|
||||
//% interval.defl=150 shim=basic::showString
|
||||
function showString(text: string, interval?: number): void;
|
||||
|
||||
/**
|
||||
* Turn off all LEDs
|
||||
*/
|
||||
//% help=basic/clear-screen weight=79
|
||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d" shim=basic::clearScreen
|
||||
function clearScreen(): void;
|
||||
|
||||
/**
|
||||
* Shows a sequence of LED screens as an animation.
|
||||
* @param leds TODO
|
||||
* @param interval TODO
|
||||
*/
|
||||
//% help=basic/show-animation shim=micro_bit::showAnimation imageLiteral=1 async
|
||||
//% interval.defl=400 imageLiteral=1 shim=basic::showAnimation
|
||||
function showAnimation(leds: string, interval?: number): void;
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds TODO
|
||||
*/
|
||||
//% help=basic/plot-leds weight=80 shim=micro_bit::plotLeds imageLiteral=1 shim=basic::plotLeds
|
||||
function plotLeds(leds: string): void;
|
||||
|
||||
/**
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=basic/forever weight=55 blockGap=8
|
||||
//% blockId=device_forever block="forever" icon="\uf01e" shim=basic::forever
|
||||
function forever(a: () => void): void;
|
||||
|
||||
/**
|
||||
* Pause for the specified time in milliseconds
|
||||
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
|
||||
*/
|
||||
//% help=basic/pause weight=54
|
||||
//% async block="pause (ms) %pause"
|
||||
//% blockId=device_pause icon="\uf110" shim=basic::pause
|
||||
function pause(ms: number): void;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% weight=1 color="#333333"
|
||||
declare namespace control {
|
||||
|
||||
/**
|
||||
* Schedules code that run in the background.
|
||||
*/
|
||||
//% help=control/in-background
|
||||
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
|
||||
function inBackground(a: () => void): void;
|
||||
|
||||
/**
|
||||
* Resets the BBC micro:bit.
|
||||
*/
|
||||
//% weight=30 async help=control/reset
|
||||
//% blockId="control_reset" block="reset" shim=control::reset
|
||||
function reset(): void;
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
* @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.
|
||||
* @param value Component specific code indicating the cause of the event.
|
||||
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_QUEUE).
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1
|
||||
//% mode.defl=CREATE_AND_QUEUE shim=control::raiseEvent
|
||||
function raiseEvent(src: number, value: number, mode: EventCreationMode ): void;
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
*/
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value"
|
||||
//% blockExternalInputs=1 blockStatement=1 shim=control::onEvent
|
||||
function onEvent(src: number, value: number, handler: () => void): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
Loading…
Reference in New Issue
Block a user