Glasses
Overview
The SDK exposes information about the glasses via the M2GlassesService (accessed from Evs.glassesService).
Examples of the information that can be received from the glasses interface:
- Battery level
- Charging state
- Serial number
- Firmware version
The interface also enables turning off the glasses and registering to glasses event callbacks.
Connection Events
Register for connection lifecycle events to monitor the glasses state:
Evs.glassesService.registerConnectionListener(object : IM2GlassesConnectionEvents {
override fun onConnectionStatusChanged(status: ConnectionStatus) {
when (status) {
ConnectionStatus.Ready -> { /* glasses connected and ready */ }
ConnectionStatus.Disconnected -> { /* glasses disconnected */ }
ConnectionStatus.Connecting -> { /* connection in progress */ }
else -> { }
}
}
})
Battery Monitoring
Touch Events
Touch events can be received in 2 ways:
- Register to the glasses events via
Evs.glassesService - Override
M2Screen.onTouch()
The following example uses M2Screen.onTouch to listen to touch events:
When enabled, the following discrete touch events are available:
| Touch Gesture | Description |
|---|---|
Touch.Backward |
Backward swipe |
Touch.Forward |
Forward swipe |
Touch.Tap |
Tapping the touch pad |
Touch.LongTap |
Long pressing the touch pad |
Proximity
The proximity sensor detects whether the glasses are on or off the face.
| Event | Description |
|---|---|
| Off face | Indicates the glasses are off face |
| On face | Indicates the glasses are on face (proximity sensor is triggered) |
Ambient Light
The ambient sensor measures daylight in lux.
When enabled, the ambient callback will be triggered with the ambient sensor reading. This value is also used by the auto brightness mechanism.
Power Button Events
Evs.glassesService.registerSystemListener(object : IM2GlassesSystemEvents {
override fun onPowerButtonPressed(event: PowerButton) {
when (event) {
PowerButton.Click -> { /* single press */ }
PowerButton.LongClick -> { /* long press */ }
PowerButton.BeforeShutdown -> { /* glasses shutting down - a stock shutdown HUD is displayed */ }
else -> { }
}
}
})
Device Information
See Also
- Inertial Sensors - IMU data and head tracking
- Communication - BLE connection and data exchange
- Display - Brightness and display control