Commonly used functions. Here you you will find the functions you normally will need.
More...
Commonly used functions. Here you you will find the functions you normally will need.
- Note
- Interrupt must be enabled with sei() before any of the functions in this section must be called!!
◆ tsl2591_disable()
Disable/Power down the TSL2591 sensor.
- Note
- The sensor is not powered down before the driver calls the call-back function with TSL2591_OK as argument.
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The disable sensor/powered down command is send to the sensor. |
TSL2591_BUSY | The driver is busy. |
TSL2591_DRIVER_NOT_INITIALISED | The driver is not initialised - and can not be used!! |
◆ tsl2591_enable()
Enable/Power up the TSL2591 sensor.
- Note
- The sensor is not ready before the driver calls the call-back function with TSL2591_OK as argument.
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The enable sensor/powered up command is send to the sensor. |
TSL2591_BUSY | The driver is busy. |
TSL2591_DRIVER_NOT_INITIALISED | The driver is not initialised - and can not be used!! |
◆ tsl2591_fetchData()
Start fetching the TSL2591 sensor's light data.
- Note
- The sensors data is not ready before the driver calls the call-back function with TSL2591_DATA_READY as argument.
- Returns
- tsl2591_returnCode_t
- Return values
-
◆ tsl2591_fetchDeviceId()
Start fetching the TSL2591 sensor's device ID.
- Note
- The ID is not available before the driver calls the call-back function with TSL2591_DEV_ID_READY as argument.
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The fetch command is send to the sensor. Await the callback before the ID is retrieved with tsl2591_getDeviceId. |
TSL2591_BUSY | The driver is busy. |
TSL2591_DRIVER_NOT_INITIALISED | The driver is not initialised - and can not be used!! |
◆ tsl2591_getCombinedDataRaw()
Retrieve the latest combined light spectrum's as raw data fetched from the TSL2591 sensor.
- Parameters
-
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The light data retrieved OK. |
TSL2591_OVERFLOW | The last measuring is in overflow - consider a lower gain. |
TSL2591_UNDERFLOW | The last measuring is in underflow - consider a higher gain. |
◆ tsl2591_getDeviceId()
uint8_t tsl2591_getDeviceId |
( |
void |
| ) |
|
Retrieve the TSL2591 sensor's device ID.
- Note
- The sensors ID will always be 0x50.
- Returns
- The sensor's latest fetched device ID.
◆ tsl2591_getFullSpectrumRaw()
Retrieve the latest full light spectrum as raw data fetched from the TSL2591 sensor.
- Parameters
-
[out] | *fullSpectrum | pointer to the variable where the data will be stored. |
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The light data retrieved OK. |
TSL2591_OVERFLOW | The last measuring is in overflow - consider a lower gain. |
TSL2591_UNDERFLOW | The last measuring is in underflow - consider a higher gain. |
◆ tsl2591_getGain()
Retrieve the TSL2591 sensor's current gain setting.
- Returns
- The sensor's current gain.
◆ tsl2591_getInfraredRaw()
Retrieve the latest infrared light spectrum as raw data fetched from the TSL2591 sensor.
- Parameters
-
[out] | *infrared | pointer to the variable where the data will be stored. |
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The light data retrieved OK. |
TSL2591_OVERFLOW | The last measuring is in overflow - consider a lower gain. |
TSL2591_UNDERFLOW | The last measuring is in underflow - consider a higher gain. |
◆ tsl2591_getIntegrationTime()
Retrieve the TSL2591 sensor's current integration time.
- Returns
- The sensor's current integration time.
◆ tsl2591_getLux()
Retrieve the latest visible light spectrum as lux fetched from the TSL2591 sensor.
- Note
- Fetch of the TSL2591 sensor's light data must be performed tsl2591_fetchData before this function can be used.
- Parameters
-
[out] | *lux | pointer to the variable where the data will be stored. |
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The light data retrieved OK. |
TSL2591_OVERFLOW | The last measuring is in overflow - consider a lower gain. |
◆ tsl2591_setGainAndIntegrationTime()
Sets the TSL2591 sensor's Gain and Integration time.
The sensor supports four gain and six different integration times settings.
Gain |
Gain | Value | Use When |
x1 | TSL2591_GAIN_LOW | Bright light (default) |
x25 | TSL2591_GAIN_MED | Medium light |
x428 | TSL2591_GAIN_HIGH | Very dimmed light |
x9876 | TSL2591_GAIN_MAX | Darkness |
Integration Times (measuring time) |
Integration time | Value | Use When |
100 ms | TSL2591_INTEGRATION_TIME_100MS | Bright light (default) |
200 ms | TSL2591_INTEGRATION_TIME_200MS | Medium light |
300 ms | TSL2591_INTEGRATION_TIME_300MS | Medium light |
400 ms | TSL2591_INTEGRATION_TIME_400MS | Dim light |
500 ms | TSL2591_INTEGRATION_TIME_500MS | Dim light |
600 ms | TSL2591_INTEGRATION_TIME_600MS | Darkness |
The sensor's gain and integration time are set to TSL2591_GAIN_LOW (x1) and TSL2591_INTEGRATION_TIME_100MS on Power On Reset (POR).
- Note
- The gain and integration time is not set before before the driver calls the call-back function with TSL2591_OK as argument.
- Parameters
-
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The set gain and integration time command is send to the sensor. |
TSL2591_BUSY | The driver is busy. |
TSL2591_DRIVER_NOT_INITIALISED | The driver is not initialised - and can not be used!! |
◆ tsl259_getVisibleRaw()
Retrieve the latest visible light spectrum as raw data fetched from the TSL2591 sensor.
- Parameters
-
[out] | *visible | pointer to the variable where the data will be stored. |
- Returns
- tsl2591_returnCode_t
- Return values
-
TSL2591_OK | The light data retrieved OK. |
TSL2591_OVERFLOW | The last measuring is in overflow - consider a lower gain. |
TSL2591_UNDERFLOW | The last measuring is in underflow - consider a higher gain. |