View Source APDS9960 (apds9960 v0.2.0)

Use the digital Color, proximity and gesture sensor APDS9960 in Elixir.

Link to this section Summary

Types

The APDS9960 sensor option

The rotation of the device

t()

The APDS9960 sensor

Functions

Reads the color data.

Enable an engine for a desired feature.

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() :: :up | :down | :left | :right

Specs

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

The APDS9960 sensor option

Specs

rotation() :: 0 | 90 | 180 | 270

The rotation of the device

Specs

t() :: %APDS9960{rotation: rotation(), 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.

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.