Interface: SensorExt


CloudControl Pro 9 Docs / sensors / SensorExt

Interface: SensorExt

sensors.SensorExt

The extension of object returned by getSensor, which extends the original Android Sensor classopen in new window with extra functions, including enableSensorEvent and disableSensorEvent.

Hierarchy

  • unknown

    SensorExt

Table of contents

Methods

Events

Methods

disableSensorEvent

disableSensorEvent(): SensorExt

Disable sensor event. After calling this function, the sensor will not send change and accuracy_change event.

Returns

SensorExt


enableSensorEvent

enableSensorEvent(delay?): SensorExt

Enable sensor event. Before calling this function, the sensor will not send change and accuracy_change event.

Parameters

Name Type Description
delay? SensorDelay sensor event rate

Returns

SensorExt

Events

on

on(event, listener): SensorExt

Sensor data event. The first parameter is an android.hardware.SensorEventopen in new window object, and the rest of the parameters are according to the sensor type.

The common sensor parameter type is:

  • accelerometer: (event: SensorEvent, ax: number, agy: number, az: number),the acceleration in each direction, unit is m/s^2
  • magnetic_field: (event: SensorEvent, hx: number, hy: number, hz: number),the magnetic field strength in each direction, unit is uT
  • orientation: (event: SensorEvent, azimuth: number, pitch: number, roll: number), see SensorEvent.valuesopen in new window
  • gyroscope: (event: SensorEvent, axisX: number, axisY: number, axisZ: number),the angular velocity in each direction, unit is rad/s
  • light: (event: SensorEvent, lux: number),the light intensity, unit is lx
  • pressure: (event: SensorEvent, pressure: number),the pressure, unit is hPa
  • temperature: (event: SensorEvent, temperature: number),the temperature, unit is °C
  • proximity: (event: SensorEvent, distance: number),the distance, unit is cm
  • gravity: (event: SensorEvent, gx: number, gy: number, gz: number),the gravity acceleration in each direction, unit is m/s^2
  • linear_acceleration: (event: SensorEvent, ax: number, ay: number, az: number),the linear acceleration in each direction, unit is m/s^2

See

SensorEventopen in new window change

Parameters

Name Type
event "change"
listener (event: SensorEvent, ...args: any) => void

Returns

SensorExt

on(event, listener): SensorExt

Sensor accuracy change event. The sensor accuracy range is 0~3, 0 means data is unreliable, 1~3 means low to high accuracy.

See

onAccuracyChangedopen in new window accuracy_change

Parameters

Name Type
event "accuracy_change"
listener (event: SensorEvent, accuracy: number) => void

Returns

SensorExt