Use APDS9960
color, proximity and gesture sensor in Elixir.
Basically we want to do something similar to what Adafruits APDS9960 guide does.
Add apds9960 to your list of dependencies in mix.exs:
def deps do
[
{:apds9960, "~> 0.1"}
]
end
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)
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}
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.