View Source APDS9960
Use the digital Color, proximity and gesture sensor APDS9960
in Elixir.
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
Coming soon
For more information, see API reference.