https://github.com/mnishiguchi/apds9960
Use APDS9960 color, proximity and gesture sensor in Elixir
https://github.com/mnishiguchi/apds9960
elixir nerves-project
Last synced: 3 months ago
JSON representation
Use APDS9960 color, proximity and gesture sensor in Elixir
- Host: GitHub
- URL: https://github.com/mnishiguchi/apds9960
- Owner: mnishiguchi
- License: mit
- Created: 2022-02-03T02:02:42.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-10T00:46:37.000Z (over 3 years ago)
- Last Synced: 2025-02-03T11:41:31.833Z (3 months ago)
- Topics: elixir, nerves-project
- Language: Elixir
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# APDS9960
[](https://hex.pm/packages/apds9960)
[](https://hexdocs.pm/apds9960)
[](https://github.com/mnishiguchi/apds9960/actions/workflows/ci.yml)Use `APDS9960` color, proximity and gesture sensor in Elixir.
Basically we want to do something similar to what [Adafruits APDS9960 guide] does.
[Adafruits APDS9960 guide]: https://learn.adafruit.com/adafruit-apds9960-breakout/circuitpython
## Installation
Add apds9960 to your list of dependencies in mix.exs:
```elixir
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**
```elixir
sensor = APDS9960.init()
```**Enable the proximity engine**
```elixir
APDS9960.enable(sensor, :proximity)
```**Measure proximity**
```elixir
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**
```elixir
sensor = APDS9960.init()
```**Enable the color engine**
```elixir
APDS9960.enable(sensor, :color)
```**Retrieve the red, green, blue and clear color values**
```elixir
APDS9960.color(sensor)
# %{blue: 52, clear: 235, green: 73, red: 128}
```### Gesture detection
**Initialize the sensor**
```elixir
sensor = APDS9960.init()
```**Enable the proximity and gesture engines**
```elixir
APDS9960.enable(sensor, :proximity)
APDS9960.enable(sensor, :gesture)
```**Detect gesture direction**
```elixir
APDS9960.gesture(sensor, timeout: 5000)
```For more information, see [API reference](https://hexdocs.pm/apds9960/api-reference.html).