Proper BLE setup

This commit is contained in:
Michal Moskal 2016-04-01 18:01:44 -07:00
parent 70bd81d9c2
commit 746dc5d5ab
5 changed files with 258 additions and 117 deletions

View File

@ -0,0 +1,121 @@
#include "BitVM.h"
#include "MESEvents.h"
enum class MesCameraEvent {
//% block="take photo"
TakePhoto = MES_CAMERA_EVT_TAKE_PHOTO,
//% block="start video capture"
StartVideoCapture = MES_CAMERA_EVT_START_VIDEO_CAPTURE,
//% block="stop video capture"
StopVideoCapture = MES_CAMERA_EVT_STOP_VIDEO_CAPTURE,
//% block="toggle front-rear"
ToggleFrontRear = MES_CAMERA_EVT_TOGGLE_FRONT_REAR,
//% block="launch photo mode"
LaunchPhotoMode = MES_CAMERA_EVT_LAUNCH_PHOTO_MODE,
//% block="launch video mode"
LaunchVideoMode = MES_CAMERA_EVT_LAUNCH_VIDEO_MODE,
//% block="stop photo mode"
StopPhotoMode = MES_CAMERA_EVT_STOP_PHOTO_MODE,
//% block="stop video mode"
StopVideoMode = MES_CAMERA_EVT_STOP_VIDEO_MODE,
};
enum class MesAlertEvent {
//% block="display toast"
DisplayToast = MES_ALERT_EVT_DISPLAY_TOAST,
//% block="vibrate"
Vibrate = MES_ALERT_EVT_VIBRATE,
//% block="play sound"
PlaySound = MES_ALERT_EVT_PLAY_SOUND,
//% block="play ring tone"
PlayRingtone = MES_ALERT_EVT_PLAY_RINGTONE,
//% block="find my phone"
FindMyPhone = MES_ALERT_EVT_FIND_MY_PHONE,
//% block="ring alarm"
RingAlarm = MES_ALERT_EVT_ALARM1,
//% block="ring alarm 2"
RingAlarm2 = MES_ALERT_EVT_ALARM2,
//% block="ring alarm 3"
RingAlarm3 = MES_ALERT_EVT_ALARM3,
//% block="ring alarm 4"
RingAlarm4 = MES_ALERT_EVT_ALARM4,
//% block="ring alarm 5"
RingAlarm5 = MES_ALERT_EVT_ALARM5,
//% block="ring alarm 6"
RingAlarm6 = MES_ALERT_EVT_ALARM6,
};
enum class MesDeviceInfo {
//% block="incoming call"
IncomingCall = MES_DEVICE_INCOMING_CALL,
//% block="incoming message"
IncomingMessage = MES_DEVICE_INCOMING_MESSAGE,
//% block="orientation landscape"
OrientationLandscape = MES_DEVICE_ORIENTATION_LANDSCAPE,
//% block="orientation portrait"
OrientationPortrait = MES_DEVICE_ORIENTATION_PORTRAIT,
//% block="shaken"
Shaken = MES_DEVICE_GESTURE_DEVICE_SHAKEN,
//% block="display off"
DisplayOff = MES_DEVICE_DISPLAY_OFF,
//% block="display on"
DisplayOn = MES_DEVICE_DISPLAY_ON,
};
enum class MesRemoteControlEvent {
//% block="play"
play = MES_REMOTE_CONTROL_EVT_PLAY,
//% block="pause"
pause = MES_REMOTE_CONTROL_EVT_PAUSE,
//% block="stop"
stop = MES_REMOTE_CONTROL_EVT_STOP,
//% block="next track"
nextTrack = MES_REMOTE_CONTROL_EVT_NEXTTRACK,
//% block="previous track"
previousTrack = MES_REMOTE_CONTROL_EVT_PREVTRACK,
//% block="forward"
forward = MES_REMOTE_CONTROL_EVT_FORWARD,
//% block="rewind"
rewind = MES_REMOTE_CONTROL_EVT_REWIND,
//% block="volume up"
volumeUp = MES_REMOTE_CONTROL_EVT_VOLUMEUP,
//% block="volume down"
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,
};

View File

@ -1,120 +1,3 @@
enum MesCameraEvent {
//% block="take photo"
TakePhoto = DAL.MES_CAMERA_EVT_TAKE_PHOTO as number,
//% block="start video capture"
StartVideoCapture = DAL.MES_CAMERA_EVT_START_VIDEO_CAPTURE as number,
//% block="stop video capture"
StopVideoCapture = DAL.MES_CAMERA_EVT_STOP_VIDEO_CAPTURE as number,
//% block="toggle front-rear"
ToggleFrontRear = DAL.MES_CAMERA_EVT_TOGGLE_FRONT_REAR as number,
//% block="launch photo mode"
LaunchPhotoMode = DAL.MES_CAMERA_EVT_LAUNCH_PHOTO_MODE as number,
//% block="launch video mode"
LaunchVideoMode = DAL.MES_CAMERA_EVT_LAUNCH_VIDEO_MODE as number,
//% block="stop photo mode"
StopPhotoMode = DAL.MES_CAMERA_EVT_STOP_PHOTO_MODE as number,
//% block="stop video mode"
StopVideoMode = DAL.MES_CAMERA_EVT_STOP_VIDEO_MODE as number,
}
enum MesAlertEvent {
//% block="display toast"
DisplayToast = DAL.MES_ALERT_EVT_DISPLAY_TOAST as number,
//% block="vibrate"
Vibrate = DAL.MES_ALERT_EVT_VIBRATE as number,
//% block="play sound"
PlaySound = DAL.MES_ALERT_EVT_PLAY_SOUND as number,
//% block="play ring tone"
PlayRingtone = DAL.MES_ALERT_EVT_PLAY_RINGTONE as number,
//% block="find my phone"
FindMyPhone = DAL.MES_ALERT_EVT_FIND_MY_PHONE as number,
//% block="ring alarm"
RingAlarm = DAL.MES_ALERT_EVT_ALARM1 as number,
//% block="ring alarm 2"
RingAlarm2 = DAL.MES_ALERT_EVT_ALARM2 as number,
//% block="ring alarm 3"
RingAlarm3 = DAL.MES_ALERT_EVT_ALARM3 as number,
//% block="ring alarm 4"
RingAlarm4 = DAL.MES_ALERT_EVT_ALARM4 as number,
//% block="ring alarm 5"
RingAlarm5 = DAL.MES_ALERT_EVT_ALARM5 as number,
//% block="ring alarm 6"
RingAlarm6 = DAL.MES_ALERT_EVT_ALARM6 as number,
}
enum MesDeviceInfo {
//% block="incoming call"
IncomingCall = DAL.MES_DEVICE_INCOMING_CALL as number,
//% block="incoming message"
IncomingMessage = DAL.MES_DEVICE_INCOMING_MESSAGE as number,
//% block="orientation landscape"
OrientationLandscape = DAL.MES_DEVICE_ORIENTATION_LANDSCAPE as number,
//% block="orientation portrait"
OrientationPortrait = DAL.MES_DEVICE_ORIENTATION_PORTRAIT as number,
//% block="shaken"
Shaken = DAL.MES_DEVICE_GESTURE_DEVICE_SHAKEN as number,
//% block="display off"
DisplayOff = DAL.MES_DEVICE_DISPLAY_OFF as number,
//% block="display on"
DisplayOn = DAL.MES_DEVICE_DISPLAY_ON as number,
}
enum MesRemoteControlEvent {
//% block="play"
play = DAL.MES_REMOTE_CONTROL_EVT_PLAY as number,
//% block="pause"
pause = DAL.MES_REMOTE_CONTROL_EVT_PAUSE as number,
//% block="stop"
stop = DAL.MES_REMOTE_CONTROL_EVT_STOP as number,
//% block="next track"
nextTrack = DAL.MES_REMOTE_CONTROL_EVT_NEXTTRACK as number,
//% block="previous track"
previousTrack = DAL.MES_REMOTE_CONTROL_EVT_PREVTRACK as number,
//% block="forward"
forward = DAL.MES_REMOTE_CONTROL_EVT_FORWARD as number,
//% block="rewind"
rewind = DAL.MES_REMOTE_CONTROL_EVT_REWIND as number,
//% block="volume up"
volumeUp = DAL.MES_REMOTE_CONTROL_EVT_VOLUMEUP as number,
//% block="volume down"
volumeDown = DAL.MES_REMOTE_CONTROL_EVT_VOLUMEDOWN as number,
}
enum MesDpadButtonInfo {
//% block="A down"
ADown = DAL.MES_DPAD_BUTTON_A_DOWN as number,
//% block="A up"
AUp = DAL.MES_DPAD_BUTTON_A_UP as number,
//% block="B down"
BDown = DAL.MES_DPAD_BUTTON_B_DOWN as number,
//% block="B up"
BUp = DAL.MES_DPAD_BUTTON_B_UP as number,
//% block="C down"
CDown = DAL.MES_DPAD_BUTTON_C_DOWN as number,
//% block="C up"
CUp = DAL.MES_DPAD_BUTTON_C_UP as number,
//% block="D down"
DDown = DAL.MES_DPAD_BUTTON_D_DOWN as number,
//% block="D up"
DUp = DAL.MES_DPAD_BUTTON_D_UP as number,
//% block="1 down"
_1Down = DAL.MES_DPAD_BUTTON_1_UP as number,
//% block="1 up"
_1Up = DAL.MES_DPAD_BUTTON_1_DOWN as number,
//% block="2 down"
_2Down = DAL.MES_DPAD_BUTTON_2_DOWN as number,
//% block="2 up"
_2Up = DAL.MES_DPAD_BUTTON_2_UP as number,
//% block="3 down"
_3Down = DAL.MES_DPAD_BUTTON_3_DOWN as number,
//% block="3 up"
_3Up = DAL.MES_DPAD_BUTTON_3_UP as number,
//% block="4 down"
_4Down = DAL.MES_DPAD_BUTTON_4_DOWN as number,
//% block="4 up"
_4Up = DAL.MES_DPAD_BUTTON_4_UP as number,
}
//% color=156 weight=80
namespace devices {
/**

125
libs/microbit-devices/enums.d.ts vendored Normal file
View File

@ -0,0 +1,125 @@
// Auto-generated. Do not edit.
declare enum MesCameraEvent {
//% block="take photo"
TakePhoto = 3, // MES_CAMERA_EVT_TAKE_PHOTO
//% block="start video capture"
StartVideoCapture = 4, // MES_CAMERA_EVT_START_VIDEO_CAPTURE
//% block="stop video capture"
StopVideoCapture = 5, // MES_CAMERA_EVT_STOP_VIDEO_CAPTURE
//% block="toggle front-rear"
ToggleFrontRear = 8, // MES_CAMERA_EVT_TOGGLE_FRONT_REAR
//% block="launch photo mode"
LaunchPhotoMode = 1, // MES_CAMERA_EVT_LAUNCH_PHOTO_MODE
//% block="launch video mode"
LaunchVideoMode = 2, // MES_CAMERA_EVT_LAUNCH_VIDEO_MODE
//% block="stop photo mode"
StopPhotoMode = 6, // MES_CAMERA_EVT_STOP_PHOTO_MODE
//% block="stop video mode"
StopVideoMode = 7, // MES_CAMERA_EVT_STOP_VIDEO_MODE
}
declare enum MesAlertEvent {
//% block="display toast"
DisplayToast = 1, // MES_ALERT_EVT_DISPLAY_TOAST
//% block="vibrate"
Vibrate = 2, // MES_ALERT_EVT_VIBRATE
//% block="play sound"
PlaySound = 3, // MES_ALERT_EVT_PLAY_SOUND
//% block="play ring tone"
PlayRingtone = 4, // MES_ALERT_EVT_PLAY_RINGTONE
//% block="find my phone"
FindMyPhone = 5, // MES_ALERT_EVT_FIND_MY_PHONE
//% block="ring alarm"
RingAlarm = 6, // MES_ALERT_EVT_ALARM1
//% block="ring alarm 2"
RingAlarm2 = 7, // MES_ALERT_EVT_ALARM2
//% block="ring alarm 3"
RingAlarm3 = 8, // MES_ALERT_EVT_ALARM3
//% block="ring alarm 4"
RingAlarm4 = 9, // MES_ALERT_EVT_ALARM4
//% block="ring alarm 5"
RingAlarm5 = 10, // MES_ALERT_EVT_ALARM5
//% block="ring alarm 6"
RingAlarm6 = 11, // MES_ALERT_EVT_ALARM6
}
declare enum MesDeviceInfo {
//% block="incoming call"
IncomingCall = 7, // MES_DEVICE_INCOMING_CALL
//% block="incoming message"
IncomingMessage = 8, // MES_DEVICE_INCOMING_MESSAGE
//% block="orientation landscape"
OrientationLandscape = 1, // MES_DEVICE_ORIENTATION_LANDSCAPE
//% block="orientation portrait"
OrientationPortrait = 2, // MES_DEVICE_ORIENTATION_PORTRAIT
//% block="shaken"
Shaken = 4, // MES_DEVICE_GESTURE_DEVICE_SHAKEN
//% block="display off"
DisplayOff = 5, // MES_DEVICE_DISPLAY_OFF
//% block="display on"
DisplayOn = 6, // MES_DEVICE_DISPLAY_ON
}
declare enum MesRemoteControlEvent {
//% block="play"
play = 1, // MES_REMOTE_CONTROL_EVT_PLAY
//% block="pause"
pause = 2, // MES_REMOTE_CONTROL_EVT_PAUSE
//% block="stop"
stop = 3, // MES_REMOTE_CONTROL_EVT_STOP
//% block="next track"
nextTrack = 4, // MES_REMOTE_CONTROL_EVT_NEXTTRACK
//% block="previous track"
previousTrack = 5, // MES_REMOTE_CONTROL_EVT_PREVTRACK
//% block="forward"
forward = 6, // MES_REMOTE_CONTROL_EVT_FORWARD
//% block="rewind"
rewind = 7, // MES_REMOTE_CONTROL_EVT_REWIND
//% block="volume up"
volumeUp = 8, // MES_REMOTE_CONTROL_EVT_VOLUMEUP
//% block="volume down"
volumeDown = 9, // MES_REMOTE_CONTROL_EVT_VOLUMEDOWN
}
declare 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
}
// Auto-generated. Do not edit. Really.

View File

@ -3,11 +3,18 @@
"description": "The BLE specific services",
"files": [
"README.md",
"enums.d.ts",
"devices.cpp",
"devices.ts"
],
"public": true,
"dependencies": {
"microbit": "file:../microbit"
},
"microbit": {
"config": {
"MICROBIT_BLE_ENABLED": "1"
}
},
"installedVersion": "zakvul"
}

View File

@ -9,5 +9,10 @@
"dependencies": {
"microbit": "file:../microbit"
},
"microbit": {
"config": {
"MICROBIT_BLE_ENABLED": "0"
}
},
"installedVersion": "rlfgis"
}