* Spelling mistakes
5.5 KiB
MES events
Events and event values are generated in the Message Event Service (MES). Using MES events allows orderly interactions between the @boardname@ and external devices. These events are sent to and received from other wireless devices paired with the @boardname@ (phone, game pad, etc.).
The event source IDs represent a device feature category. The event values are actions for, or notifications about a device feature.
~hint
MES system sources
The MES events are defined in this source file of the microbit-dal:
Also, you can see how the message bus works in the DAL core files:
~
Raised events
Events are generated, or raised, for by the @boardname@ for a paired device. These are raised using the raise event function.
control.raiseEvent(
control.eventSourceId(EventBusSource.MES_REMOTE_CONTROL_ID),
control.eventValueId(EventBusValue.MES_REMOTE_CONTROL_EVT_VOLUMEUP)
);
Remote control
Events for using the @boardname@ as a remote control for audio play.
MES_REMOTE_CONTROL_ID
MES_REMOTE_CONTROL_EVT_PLAY
: Play the current trackMES_REMOTE_CONTROL_EVT_PAUSE
: Pause the current play in progressMES_REMOTE_CONTROL_EVT_STOP
: Stop playing and reset to the beginning of the current trackMES_REMOTE_CONTROL_EVT_NEXTTRACK
: Skip to the next trackMES_REMOTE_CONTROL_EVT_PREVTRACK
: Skip to the previous trackMES_REMOTE_CONTROL_EVT_FORWARD
: Move forward in the current trackMES_REMOTE_CONTROL_EVT_REWIND
: Move backward in the current trackMES_REMOTE_CONTROL_EVT_VOLUMEUP
: Increase the play volume (audio)MES_REMOTE_CONTROL_EVT_VOLUMEDOWN
: Decrease the play volume (audio)
Camera
Control camera actions on a paired device.
MES_CAMERA_ID
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE
: Turn on or set the camera to photo mode.MES_CAMERA_EVT_LAUNCH_VIDEO_MODE
: Turn on or set the camera to video mode.MES_CAMERA_EVT_TAKE_PHOTO
: Capture the picture in the camera view.MES_CAMERA_EVT_START_VIDEO_CAPTURE
: Begin capturing video (start record)MES_CAMERA_EVT_STOP_VIDEO_CAPTURE
: End capturing video (stop record)MES_CAMERA_EVT_STOP_PHOTO_MODE
: Stop photo mode and return to the default modeMES_CAMERA_EVT_STOP_VIDEO_MODE
: Stop video mode and return to the default modeMES_CAMERA_EVT_TOGGLE_FRONT_REAR
: Switch from the front camera to rear camera or rear to front
Alerts
Trigger standard alert notifications on a device.
MES_ALERTS_ID
MES_ALERT_EVT_DISPLAY_TOAST
MES_ALERT_EVT_VIBRATE
MES_ALERT_EVT_PLAY_SOUND
MES_ALERT_EVT_PLAY_RINGTONE
MES_ALERT_EVT_FIND_MY_PHONE
MES_ALERT_EVT_ALARM1
MES_ALERT_EVT_ALARM2
MES_ALERT_EVT_ALARM3
MES_ALERT_EVT_ALARM4
MES_ALERT_EVT_ALARM5
MES_ALERT_EVT_ALARM6
Received events
Events are received by the @boardname@ from a paired device. You capture these in an on event function.
control.onEvent(EventBusSource.MES_DEVICE_INFO_ID, EventBusValue.MES_DEVICE_INCOMING_CALL, () => {
})
Carrier signal strength
Signal strength to the subscribed carrier service.
MES_SIGNAL_STRENGTH_ID
MES_SIGNAL_STRENGTH_EVT_NO_BAR
: No service available or very low signal strengthMES_SIGNAL_STRENGTH_EVT_ONE_BAR
: Low signal strengthMES_SIGNAL_STRENGTH_EVT_TWO_BAR
: Medium signal strengthMES_SIGNAL_STRENGTH_EVT_THREE_BAR
: High signal strengthMES_SIGNAL_STRENGTH_EVT_FOUR_BAR
: Full signal strength
Device information
Information about the current status of the device
MES_DEVICE_INFO_ID
MES_DEVICE_ORIENTATION_LANDSCAPE
: Display orientation is now in landscapeMES_DEVICE_ORIENTATION_PORTRAIT
: Display orientation is now in portraitMES_DEVICE_GESTURE_NONE
: No gesture detected for device activationMES_DEVICE_GESTURE_DEVICE_SHAKEN
: The device was shakenMES_DEVICE_DISPLAY_OFF
: Device display is now turned offMES_DEVICE_DISPLAY_ON
: Device display is now turned onMES_DEVICE_INCOMING_CALL
: Currently receiving an incoming callMES_DEVICE_INCOMING_MESSAGE
: A message was received (SMS or other messaging app)
Game pad controller
Button events from a paired game pad.
MES_DPAD_CONTROLLER_ID
MES_DPAD_BUTTON_A_DOWN
: Button A pressedMES_DPAD_BUTTON_A_UP
: Button A releasedMES_DPAD_BUTTON_B_DOWN
: Button B pressedMES_DPAD_BUTTON_B_UP
: Button B releasedMES_DPAD_BUTTON_C_DOWN
: Button C pressedMES_DPAD_BUTTON_C_UP
: Button C releasedMES_DPAD_BUTTON_D_DOWN
: Button D pressedMES_DPAD_BUTTON_D_UP
: Button D releasedMES_DPAD_BUTTON_1_DOWN
: Button 1 pressedMES_DPAD_BUTTON_1_UP
: Button 1 releasedMES_DPAD_BUTTON_2_DOWN
: Button 2 pressedMES_DPAD_BUTTON_2_UP
: Button 2 releasedMES_DPAD_BUTTON_3_DOWN
: Button 3 pressedMES_DPAD_BUTTON_3_UP
: Button 3 releasedMES_DPAD_BUTTON_4_DOWN
: Button 4 pressedMES_DPAD_BUTTON_4_UP
: Button 4 released