View Source TSL256X (tsl256x v0.1.0)

Documentation for TSL256x family of Ligh to digital convertors.

This module supports TSL2560 and 2561 in both T and SC packages.

To start add the module to your mix.exs

Summary

Functions

Disable the sensor

Enable the sensor

Checks to see if the sensor is currently enabled.

Gets the current gain setting from the sensor

Sets the current gain setting for the sensor

Gets the current integration time from the sensors.

Set the integration time, check integration_time/1 for the possible values.

Calculate the current light strength in lux.

Start the sensor and return a struct for future calls.

Stop the light sensor and closes the I2C bus.

Types

@type t() :: %TSL256X{bus_ref: term(), rev: term(), type: term()}

Functions

@spec disable(t()) :: :ok | {:error, any()}

Disable the sensor

@spec enable(t()) :: :ok | {:error, any()}

Enable the sensor

@spec enabled?(t()) :: true | false | {:error, any()}

Checks to see if the sensor is currently enabled.

@spec gain(t()) :: 0 | 1

Gets the current gain setting from the sensor:

  • 0 - 1X
  • 1 - 16X
@spec gain(t(), 0 | 1) :: :ok | {:error, any()}

Sets the current gain setting for the sensor:

  • 0 - 1X
  • 1 - 16X
Link to this function

integration_time(sensor)

View Source
@spec integration_time(t()) :: 0 | 1 | 2 | 3 | {:error, any()}

Gets the current integration time from the sensors.

valuescalenominal integration time
00.03413.7 ms
10.252101 ms
21402 ms
3--N/A

When the value is set to 3, manual timing control is used, check the datasheet for more information.

Link to this function

integration_time(sensor, value)

View Source
@spec integration_time(t(), 0..3) :: :ok | {:error, any()}

Set the integration time, check integration_time/1 for the possible values.

Calculate the current light strength in lux.

Example

   iex> TSL256X.lux(sensor)
   2851
Link to this function

start(i2c_bus, retries \\ 1)

View Source
@spec start(String.t(), integer()) :: {:ok, t()} | {:error, any()}

Start the sensor and return a struct for future calls.

Examples

iex> TSL256X.start("i2c-1", 4)
{:ok, %TSL256X{}}
@spec stop(t()) :: :ok

Stop the light sensor and closes the I2C bus.

Examples

iex> TSL256X.stop(sensor)
:ok