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 class 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
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
Events
on
▸ on(event
, listener
): SensorExt
Sensor data event. The first parameter is an android.hardware.SensorEvent 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 ism/s^2
。magnetic_field
:(event: SensorEvent, hx: number, hy: number, hz: number)
,the magnetic field strength in each direction, unit isuT
。orientation
:(event: SensorEvent, azimuth: number, pitch: number, roll: number)
, see SensorEvent.values。gyroscope
:(event: SensorEvent, axisX: number, axisY: number, axisZ: number)
,the angular velocity in each direction, unit israd/s
。light
:(event: SensorEvent, lux: number)
,the light intensity, unit islx
。pressure
:(event: SensorEvent, pressure: number)
,the pressure, unit ishPa
。temperature
:(event: SensorEvent, temperature: number)
,the temperature, unit is°C
。proximity
:(event: SensorEvent, distance: number)
,the distance, unit iscm
。gravity
:(event: SensorEvent, gx: number, gy: number, gz: number)
,the gravity acceleration in each direction, unit ism/s^2
。linear_acceleration
:(event: SensorEvent, ax: number, ay: number, az: number)
,the linear acceleration in each direction, unit ism/s^2
。
See
SensorEvent change
Parameters
Name | Type |
---|---|
event |
"change" |
listener |
(event : SensorEvent , ...args : any ) => void |
Returns
▸ 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
onAccuracyChanged accuracy_change
Parameters
Name | Type |
---|---|
event |
"accuracy_change" |
listener |
(event : SensorEvent , accuracy : number ) => void |