sensors


CloudControl Pro 9 Docs / sensors

sensors

sensors module provides the support for getting the sensor information of the device, including the distance sensor, light sensor, gravity sensor, orientation sensor, etc. Note that this module can only get the sensor data, CloudControl Pro does not provide the simulation or fake sensor data and event function.

Table of contents

Enumerations

Interfaces

Type Aliases

Functions

Type Aliases

Sensor

Ƭ Sensor: AndroidSensor & SensorExt

The type of object returned by getSensor, which extends the original Android Sensor classopen in new window with extra functions, see SensorExt.

Functions

getSensor

getSensor(name): Sensor | undefined

Get the sensor object by the specified sensor name, or undefined if not found.

A list of common sensors:

  • accelerometer
  • magnetic_field
  • orientation
  • gyroscope
  • light
  • pressure
  • temperature
  • proximity
  • gravity
  • linear_acceleration

See Sensoropen in new window for a full list.

Example

"nodejs";
const { getSensor, SensorDelay } = require("sensors");

const sensor = getSensor("light");
sensor.enableSensorEvent(SensorDelay.Normal)
      .on("change", (light) => {
          console.log(light);
      });
$autojs.keepRunning();

Parameters

Name Type Description
name string the sensor name

Returns

Sensor | undefined

the sensor object, or undefined