Skip to content

Use APDS9960 color, proximity and gesture sensor in Elixir

License

Notifications You must be signed in to change notification settings

mnishiguchi/apds9960

Repository files navigation

APDS9960

Hex version API docs CI

Use APDS9960 color, proximity and gesture sensor in Elixir.

Basically we want to do something similar to what Adafruits APDS9960 guide does.

Installation

Add apds9960 to your list of dependencies in mix.exs:

def deps do
  [
    {:apds9960, "~> 0.1"}
  ]
end

Usage

Proximity detection

The proximity value ranges from 0 to 255, where the higher the number the closer an object is to the sensor.

Initialize the sensor

sensor = APDS9960.init()

Enable the proximity engine

APDS9960.enable(sensor, :proximity)

Measure proximity

APDS9960.proximity(sensor)

RGB Color Sensing

The results are 16-bit values from 0 to 65535, where 0 means the minimum amount of color and 65535 is the maximum amount of color.

Initialize the sensor

sensor = APDS9960.init()

Enable the color engine

APDS9960.enable(sensor, :color)

Retrieve the red, green, blue and clear color values

APDS9960.color(sensor)
# %{blue: 52, clear: 235, green: 73, red: 128}

Gesture detection

Initialize the sensor

sensor = APDS9960.init()

Enable the proximity and gesture engines

APDS9960.enable(sensor, :proximity)
APDS9960.enable(sensor, :gesture)

Detect gesture direction

APDS9960.gesture(sensor, timeout: 5000)

For more information, see API reference.

About

Use APDS9960 color, proximity and gesture sensor in Elixir

Topics

Resources

License

Stars

Watchers

Forks

Languages