Options
All
  • Public
  • Public/Protected
  • All
Menu

Module 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, Auto.js Pro does not provide the simulation or fake sensor data and event function.

Index

Enumerations

Interfaces

Type aliases

Functions

Type aliases

Sensor

Sensor: AndroidSensor & SensorExt

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

Functions

getSensor

  • getSensor(name: string): 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 Sensor 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: string

      the sensor name

    Returns Sensor | undefined

    the sensor object, or undefined