Skip to content

Glasses

Overview

The SDK exposes information about the glasses via the IEvsGlassesStateService interface (received from the Evs.instance().glasses() method).

An example 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 to register to the IEvsGlassesEvents callback interface.

Usage Example

The following examples shows how to listen the touch events.

Touch events can be received in 2 ways:

  1. Register to the glasses events by using Evs.instance().glasses().registerGlassesEvents(listener: glassesEvents)
  2. Override the Screen:onTouch

The following example uses the Screen:onTouch to listen to touch events:

Swift
// After initializing the SDK, don't forget to enable the touch:
// Evs.instance().sensors().enableTouch(enable: true)

// Override the screen onTouch
 override func onTouch(touch: TouchDirection) {

    // When tapping the glasses touch0pad
    // display a popup message on the screen
    if(touch==TouchDirection.tap){
        let t = Text()
        t
            .setResource(stockFont: Font.StockFont.medium)
            .setTextAlign(align: Align.center)
            .setText(text: "Nice Tap!!")
            .setBackgroundColor(evsColor: EvsColor.red)

        showPopup(message: PopupMessage(view: t,alignV: AlignV.center, timeoutMs: 3000))
    }
}
Kotlin
// After initializing the SDK, don't forget to enable the touch:
// Evs.instance().sensors().enableTouch(true)

// Override the screen onTouch
override fun onTouch(touch: TouchDirection) {

    // When tapping the glasses touch0pad 
    // display a popup message on the screen
    if(touch==TouchDirection.tap){
        val t = Text()
        t
            .setResource(Font.StockFont.Medium)
            .setTextAlign(Align.center)
            .setText("Nice Tap!!")
            .setBackgroundColor(EvsColor.Red)

        showPopup(PopupMessage(t,AlignV.center, 3000))
    }
}

More information about the touch sensor can be found in the Glasses Sensors page.


Learn about the Glasses Sensors