VL6180X (VL6180X v0.3.0) View Source

A library to interface with the VL6180X time-of-flight laser sensor.

Link to this section Summary

Functions

Helper function to return gain value for 1x ALS GAIN.

Helper function to return gain value for 10x ALS GAIN.

Helper function to return gain value for 1.25x ALS GAIN.

Helper function to return gain value for 1.67x ALS GAIN.

Helper function to return gain value for 20x ALS GAIN.

Helper function to return gain value for 2.5x ALS GAIN.

Helper function to return gain value for 40x ALS GAIN.

Helper function to return gain value for 5x ALS GAIN.

Initialize the sensor.

Reads the lux (light value) from the sensor.

Opens the bus to the I2C channel, optionally takes the device address.

Reads the distance from the sensor to the object infront.

Reads the status of the range sensor.

Link to this section Types

Specs

error_reaon() :: atom()

Specs

gain() :: 0..7

Specs

range_states() :: :no_error | error_reaon()

Specs

t() :: %VL6180X{bus: Circuits.I2C.bus(), device: Circuits.I2C.address()}

Link to this section Functions

Specs

als_gain_1() :: gain()

Helper function to return gain value for 1x ALS GAIN.

Specs

als_gain_10() :: gain()

Helper function to return gain value for 10x ALS GAIN.

Specs

als_gain_1_25() :: gain()

Helper function to return gain value for 1.25x ALS GAIN.

Specs

als_gain_1_67() :: gain()

Helper function to return gain value for 1.67x ALS GAIN.

Specs

als_gain_20() :: gain()

Helper function to return gain value for 20x ALS GAIN.

Specs

als_gain_2_5() :: gain()

Helper function to return gain value for 2.5x ALS GAIN.

Specs

als_gain_40() :: gain()

Helper function to return gain value for 40x ALS GAIN.

Specs

als_gain_5() :: gain()

Helper function to return gain value for 5x ALS GAIN.

Specs

init(t()) :: :ok | {:error, term()}

Initialize the sensor.

Calling this is required before proceeding with any readings.

Returns :ok.

Specs

lux(t(), gain()) :: {:ok, float()}

Reads the lux (light value) from the sensor.

:warn: THIS IS EXPERIMENTAL

Link to this function

open(bus_name, address \\ 41)

View Source

Specs

open(binary(), Circuits.I2C.address()) :: {:ok, t()}

Opens the bus to the I2C channel, optionally takes the device address.

Returns {:ok, ref}.

Specs

range(t()) :: pos_integer()

Reads the distance from the sensor to the object infront.

The sensor uses the time light takes to travel to the object and bounce back. The sensors operation range is between 5mm and 100mm, in practice, with good you can get further distances.

This call is blocking until the sensor finishes the reading. This usually is prettry fast when no error occurs.

Returns the distance as a positive integer.

Specs

range_status(t()) :: {:ok, range_states()} | {:error, term()}

Reads the status of the range sensor.

Returns {:ok, :no_error} when everything is correct. When the sensor has encountered an error it'll return {:ok, error_reaon}. IF the state could not be red from the sensor it'll return {:error, erro_reason}