Adafruit HTS221 Library
Public Member Functions | List of all members
Adafruit_TSL2591 Class Reference

Class that stores state and functions for interacting with TSL2591 Light Sensor. More...

#include <Adafruit_TSL2591.h>

Inheritance diagram for Adafruit_TSL2591:

Public Member Functions

 Adafruit_TSL2591 (int32_t sensorID=-1)
 Instantiates a new Adafruit TSL2591 class. More...
 
boolean begin (TwoWire *theWire, uint8_t addr=TSL2591_ADDR)
 Setups the I2C interface and hardware, identifies if chip is found. More...
 
boolean begin (uint8_t addr=TSL2591_ADDR)
 Setups the I2C interface and hardware, identifies if chip is found. More...
 
void enable (void)
 Enables the chip, so it's ready to take readings.
 
void disable (void)
 Disables the chip, so it's in power down mode.
 
float calculateLux (uint16_t ch0, uint16_t ch1)
 Calculates the visible Lux based on the two light sensors. More...
 
void setGain (tsl2591Gain_t gain)
 Setter for sensor light gain. More...
 
void setTiming (tsl2591IntegrationTime_t integration)
 Setter for sensor integration time setting. More...
 
uint16_t getLuminosity (uint8_t channel)
 Reads the raw data from the channel. More...
 
uint32_t getFullLuminosity ()
 Reads the raw data from both light channels. More...
 
tsl2591IntegrationTime_t getTiming ()
 Getter for sensor integration time setting. More...
 
tsl2591Gain_t getGain ()
 Getter for sensor light gain. More...
 
void clearInterrupt (void)
 Clear interrupt status.
 
void registerInterrupt (uint16_t lowerThreshold, uint16_t upperThreshold, tsl2591Persist_t persist)
 Set up the interrupt to go off when light level is outside the lower/upper range. More...
 
uint8_t getStatus ()
 Gets the most recent sensor event from the hardware status register. More...
 
bool getEvent (sensors_event_t *)
 Gets the most recent sensor event. More...
 
void getSensor (sensor_t *)
 Gets the overall sensor_t data including the type, range and resulution. More...
 

Detailed Description

Class that stores state and functions for interacting with TSL2591 Light Sensor.

Constructor & Destructor Documentation

◆ Adafruit_TSL2591()

Adafruit_TSL2591::Adafruit_TSL2591 ( int32_t  sensorID = -1)

Instantiates a new Adafruit TSL2591 class.

Parameters
sensorIDAn optional ID # so you can track this sensor, it will tag sensorEvents you create.

Member Function Documentation

◆ begin() [1/2]

boolean Adafruit_TSL2591::begin ( TwoWire *  theWire,
uint8_t  addr = TSL2591_ADDR 
)

Setups the I2C interface and hardware, identifies if chip is found.

Parameters
theWirea reference to TwoWire instance
addrThe I2C adress of the sensor (Default 0x29)
Returns
True if a TSL2591 is found, false on any failure

◆ begin() [2/2]

boolean Adafruit_TSL2591::begin ( uint8_t  addr = TSL2591_ADDR)

Setups the I2C interface and hardware, identifies if chip is found.

Parameters
addrThe I2C adress of the sensor (Default 0x29)
Returns
True if a TSL2591 is found, false on any failure

◆ calculateLux()

float Adafruit_TSL2591::calculateLux ( uint16_t  ch0,
uint16_t  ch1 
)

Calculates the visible Lux based on the two light sensors.

Parameters
ch0Data from channel 0 (IR+Visible)
ch1Data from channel 1 (IR)
Returns
Lux, based on AMS coefficients (or < 0 if overflow)

◆ setGain()

void Adafruit_TSL2591::setGain ( tsl2591Gain_t  gain)

Setter for sensor light gain.

Parameters
gaintsl2591Gain_t gain value

◆ setTiming()

void Adafruit_TSL2591::setTiming ( tsl2591IntegrationTime_t  integration)

Setter for sensor integration time setting.

Parameters
integrationtsl2591IntegrationTime_t integration time setting

◆ getLuminosity()

uint16_t Adafruit_TSL2591::getLuminosity ( uint8_t  channel)

Reads the raw data from the channel.

Parameters
channelCan be 0 (IR+Visible, 1 (IR) or 2 (Visible only)
Returns
16-bit raw count, or 0 if channel is invalid

◆ getFullLuminosity()

uint32_t Adafruit_TSL2591::getFullLuminosity ( void  )

Reads the raw data from both light channels.

Returns
32-bit raw count where high word is IR, low word is IR+Visible

◆ getTiming()

tsl2591IntegrationTime_t Adafruit_TSL2591::getTiming ( )

Getter for sensor integration time setting.

Returns
tsl2591IntegrationTime_t integration time

◆ getGain()

tsl2591Gain_t Adafruit_TSL2591::getGain ( )

Getter for sensor light gain.

Returns
tsl2591Gain_t gain value

◆ registerInterrupt()

void Adafruit_TSL2591::registerInterrupt ( uint16_t  lowerThreshold,
uint16_t  upperThreshold,
tsl2591Persist_t  persist = TSL2591_PERSIST_ANY 
)

Set up the interrupt to go off when light level is outside the lower/upper range.

Parameters
lowerThresholdRaw light data reading level that is the lower value threshold for interrupt
upperThresholdRaw light data reading level that is the higher value threshold for interrupt
persistHow many counts we must be outside range for interrupt to fire, default is any single value

◆ getStatus()

uint8_t Adafruit_TSL2591::getStatus ( void  )

Gets the most recent sensor event from the hardware status register.

Returns
Sensor status as a byte. Bit 0 is ALS Valid. Bit 4 is ALS Interrupt. Bit 5 is No-persist Interrupt.

◆ getEvent()

bool Adafruit_TSL2591::getEvent ( sensors_event_t *  event)

Gets the most recent sensor event.

Parameters
eventPointer to Adafruit_Sensor sensors_event_t object that will be filled with sensor data
Returns
True on success, False on failure

◆ getSensor()

void Adafruit_TSL2591::getSensor ( sensor_t *  sensor)

Gets the overall sensor_t data including the type, range and resulution.

Parameters
sensorPointer to Adafruit_Sensor sensor_t object that will be filled with sensor type data

The documentation for this class was generated from the following files: