View Source APDS9960 (apds9960 v0.3.0)

Use APDS9960 color, proximity and gesture sensor in Elixir.

Link to this section Summary

Types

The APDS9960 sensor option

t()

The APDS9960 sensor

Functions

Reads the color data.

Enable an engine for a desired feature.

Reads new gesture engine results, deduces gesture and returns the direction of the gesture.

Initializes the I2C bus and sensor.

Reads the proximity data. The proximity value is a number from 0 to 255 where the higher the number the closer an object is to the sensor.

Returns the status of the device.

Link to this section Types

Specs

engine() :: :color | :als | :proximity | :gesture

Specs

gesture_direction() :: :up | :down | :left | :right

Specs

option() :: [bus_name: binary(), reset: boolean(), set_defaults: boolean()]

The APDS9960 sensor option

Specs

t() :: %APDS9960{transport: APDS9960.Transport.t()}

The APDS9960 sensor

Link to this section Functions

Specs

color(t()) :: %{red: 0..65535, green: 0..65535, blue: 0..65535, clear: 0..65535}

Reads the color data.

# To get a color measurement, first enable the color engine.
APDS9960.enable_color(sensor)

APDS9960.color(sensor)
Link to this function

enable(apds9960, engine)

View Source

Specs

enable(t(), engine()) :: :ok

Enable an engine for a desired feature.

Link to this function

gesture(sensor, opts \\ [])

View Source

Specs

gesture(t(), Enum.t()) :: gesture_direction() | {:error, any()}

Reads new gesture engine results, deduces gesture and returns the direction of the gesture.

# To get a gesture result, first enable both the proximity engine and gesture engine.
APDS9960.enable(sensor, :gesture)
APDS9960.enable(sensor, :proximity)

APDS9960.gesture(sensor, timeout: 5000)

Specs

init([option()]) :: t()

Initializes the I2C bus and sensor.

Specs

proximity(t()) :: byte()

Reads the proximity data. The proximity value is a number from 0 to 255 where the higher the number the closer an object is to the sensor.

# To get a proximity result, first enable the proximity engine.
APDS9960.enable(sensor, :proximity)

APDS9960.proximity(sensor)

Specs

reset!(t()) :: :ok

Specs

set_defaults!(t()) :: :ok

Specs

status(t()) :: %{
  als_interrupt: byte(),
  als_valid: byte(),
  clear_photo_diode_saturation: byte(),
  gesture_interrupt: byte(),
  proximity_interrupt: byte(),
  proximity_or_gesture_saturation: byte(),
  proximity_valid: byte()
}

Returns the status of the device.