Library which provides functions to control a TAOS TSL2561 Light-To-Digital Converter via I2C.
Dependents: TweetTest NetworkThermometer GR-PEACH_TAMORI mDot_LoRa_Connect_ABPA_Lux ... more
TSL2561_I2C Class Reference
TSL2561_I2C class. More...
#include <TSL2561_I2C.h>
Public Member Functions | |
TSL2561_I2C (PinName sda, PinName scl) | |
Create TSL2561_I2C instance. | |
int | getVisibleAndIR () |
Read broadband photodiode (visible plus infrared) | |
int | getIROnly () |
Read infrared-responding photodiode. | |
float | getLux () |
Read sensors and calculate Illuminance in lux. | |
int | enablePower () |
Power up the device. | |
int | disablePower () |
Disable power to the device. | |
bool | isPowerEnabled () |
Check if power to the device is enabled. | |
int | readGain () |
Return present gain value. | |
int | setGain (const int gain) |
Set gain. | |
float | readIntegrationTime () |
Read the current integration time. | |
int | setIntegrationTime (const float itime) |
Set integration time. | |
int | readLowInterruptThreshold () |
Read the low trigger point for the comparison function for interrupt generation. | |
int | readHighInterruptThreshold () |
Read the high trigger point for the comparison function for interrupt generation. | |
int | setLowInterruptThreshold (const int threshold) |
Set the low trigger point for the comparison function for interrupt generation. | |
int | setHighInterruptThreshold (const int threshold) |
Set the high trigger point for the comparison function for interrupt generation. | |
int | readInterruptPersistence () |
Return the number of consecutive values out of range (set by the low and high thresholds) required to trigger an interrupt. | |
int | setInterruptPersistence (const int persistence) |
Set the number of consecutive values out of range (set by the low and high thresholds) required to trigger an interrupt. | |
int | readInterruptControl () |
Check the interrupt function's operation mode. | |
int | setInterruptControl (const int control) |
Set the interrupt function's operation mode. | |
int | clearInterrupt () |
Clear the interrupt, allowing normal operation to resume. | |
int | getPartNumber () |
Get integer indicating part number. | |
int | getRevisionNumber () |
Get revision number. |
Detailed Description
TSL2561_I2C class.
Abstraction for TAOS TSL2561 Light-To-Digital Converter.
Example:
#include "mbed.h" #include "TSL2561_I2C.h" TSL2561_I2C lum_sensor( p9, p10 ); int main() { lum_sensor.enablePower(); int rgb_readings[4]; while(1) { printf( "Luminosity: %4.2f\n", lum_sensor.getLux() ); wait_ms( 100 ); } }
Definition at line 38 of file TSL2561_I2C.h.
Constructor & Destructor Documentation
TSL2561_I2C | ( | PinName | sda, |
PinName | scl | ||
) |
Create TSL2561_I2C instance.
- Parameters:
-
sda sda pin for I2C scl scl pin for I2C
Definition at line 3 of file TSL2561_I2C.cpp.
Member Function Documentation
int clearInterrupt | ( | ) |
Clear the interrupt, allowing normal operation to resume.
(writes 0b11000000 to command register to clear interrupt)
- Returns:
- 1 if successful 0 if otherwise
Definition at line 262 of file TSL2561_I2C.cpp.
int disablePower | ( | ) |
Disable power to the device.
- Returns:
- 1 if successful 0 if otherwise
Definition at line 108 of file TSL2561_I2C.cpp.
int enablePower | ( | ) |
Power up the device.
- Returns:
- 1 if successful 0 if otherwise
Definition at line 103 of file TSL2561_I2C.cpp.
int getIROnly | ( | ) |
Read infrared-responding photodiode.
- Returns:
- Irradiance measured
Definition at line 46 of file TSL2561_I2C.cpp.
float getLux | ( | ) |
Read sensors and calculate Illuminance in lux.
- Returns:
- Illuminance (lux)
Definition at line 53 of file TSL2561_I2C.cpp.
int getPartNumber | ( | ) |
Get integer indicating part number.
- Returns:
- 0: TSL2560 1: TSL2561
Definition at line 268 of file TSL2561_I2C.cpp.
int getRevisionNumber | ( | ) |
int getVisibleAndIR | ( | ) |
Read broadband photodiode (visible plus infrared)
- Returns:
- Irradiance measured
Definition at line 39 of file TSL2561_I2C.cpp.
bool isPowerEnabled | ( | ) |
Check if power to the device is enabled.
- Returns:
- 1 if power ON 0 if power OFF
Definition at line 113 of file TSL2561_I2C.cpp.
int readGain | ( | ) |
Return present gain value.
- Returns:
- 1 (low gain mode) 16 (high gain mode)
Definition at line 122 of file TSL2561_I2C.cpp.
int readHighInterruptThreshold | ( | ) |
Read the high trigger point for the comparison function for interrupt generation.
- Returns:
- High threshold value
Definition at line 213 of file TSL2561_I2C.cpp.
float readIntegrationTime | ( | ) |
Read the current integration time.
- Returns:
- Integration time in milliseconds
Definition at line 162 of file TSL2561_I2C.cpp.
int readInterruptControl | ( | ) |
Check the interrupt function's operation mode.
- Returns:
- 0: Interrupt output disabled 1: Level Interrupt 2: SMBAlert compliant 3: Test Mode
Definition at line 249 of file TSL2561_I2C.cpp.
int readInterruptPersistence | ( | ) |
Return the number of consecutive values out of range (set by the low and high thresholds) required to trigger an interrupt.
- Returns:
- interrput persistence
Definition at line 236 of file TSL2561_I2C.cpp.
int readLowInterruptThreshold | ( | ) |
Read the low trigger point for the comparison function for interrupt generation.
- Returns:
- Low threshold value
Definition at line 206 of file TSL2561_I2C.cpp.
int setGain | ( | const int | gain ) |
Set gain.
- Parameters:
-
gain Gain must be either 1 or 16
- Returns:
- 1 if successful 0 if otherwise
Definition at line 140 of file TSL2561_I2C.cpp.
int setHighInterruptThreshold | ( | const int | threshold ) |
Set the high trigger point for the comparison function for interrupt generation.
- Parameters:
-
threshold High threshold value
- Returns:
- 1 if successful 0 if otherwise
Definition at line 228 of file TSL2561_I2C.cpp.
int setIntegrationTime | ( | const float | itime ) |
Set integration time.
- Parameters:
-
itime Integration time to set in milliseconds. Should be 13.7, 101 or 402.
- Returns:
- 1 if successful 0 if otherwise
Definition at line 183 of file TSL2561_I2C.cpp.
int setInterruptControl | ( | const int | control ) |
Set the interrupt function's operation mode.
- Parameters:
-
control Value to set. 0: interrupt every ADC cycle, 1-15: corresponding number of cycles until interrupt
- Returns:
- 1 if successful 0 if otherwise
Definition at line 255 of file TSL2561_I2C.cpp.
int setInterruptPersistence | ( | const int | persistence ) |
Set the number of consecutive values out of range (set by the low and high thresholds) required to trigger an interrupt.
- Parameters:
-
persistence Value to set. 0: interrupt every ADC cycle, 1-15: corresponding number of cycles until interrupt
- Returns:
- 1 if successful 0 if otherwise
Definition at line 242 of file TSL2561_I2C.cpp.
int setLowInterruptThreshold | ( | const int | threshold ) |
Set the low trigger point for the comparison function for interrupt generation.
- Parameters:
-
threshold Low threshold value
- Returns:
- 1 if successful 0 if otherwise
Definition at line 220 of file TSL2561_I2C.cpp.
Generated on Sat Jul 16 2022 03:59:54 by 1.7.2