3#include <wiringPiI2C.h>
9#include "../Data/SensorLevels.h"
119 virtual void TurnOn()
override;
131 virtual void TurnOff()
override;
158 virtual std::string
ToString()
const override;
193 virtual float CalculateLux(
const uint16_t ch0,
const uint16_t ch1);
207 virtual float GetLux()
const;
Abstract base class for every component (sensor, actuator, etc.) the library manages.
Definition: BaseComponent.h:60
TSL2591 high-dynamic-range digital light sensor (I2C), reading full-spectrum and IR channels to compu...
Definition: TSL2591.h:62
static float ConvertIntegrationTimeToDecimalMilliseconds(const E_TSL2591_IntegrationTime integrationTimeMilliseconds)
Converts an integration-time enum to its value in milliseconds.
Definition: TSL2591.cpp:479
virtual float CalculateLux(const uint16_t ch0, const uint16_t ch1)
Computes lux from the full-spectrum and IR channels, normalizing by counts-per-lux and rejecting IR,...
Definition: TSL2591.cpp:393
float myLightCutoffNormal
Upper lux bound of the "Normal" bucket.
Definition: TSL2591.h:76
virtual std::string DetermineLightCategory() const
Gets the short, human-readable light category for the current reading.
Definition: TSL2591.cpp:262
virtual float GetLux() const
Gets the most recently calculated lux value.
Definition: TSL2591.cpp:156
virtual void TurnOff() override
Turns the sensor off by disabling it over I2C (if it was initialized).
Definition: TSL2591.cpp:94
uint16_t myRawChannel1Reading
The most recent raw infrared (CH1) reading.
Definition: TSL2591.h:66
virtual void ProcessRawValues() override
Reads the raw CH0/CH1 channels, auto-adjusts gain if the reading is saturated or too dark (re-reading...
Definition: TSL2591.cpp:116
E_TSL2591_IntegrationTime myIntegrationTimeMilliseconds
How long the sensor integrates each reading.
Definition: TSL2591.h:68
static float ConvertAmplificationGainToDecimalMultiplier(const E_TSL2591_AmplificationGain amplificationGain)
Converts an amplification-gain enum to its decimal multiplier.
Definition: TSL2591.cpp:539
void SetLightLevelCutoffs(float dark, float veryDim, float dim, float normal, float bright)
Sets the ascending lux cutoffs that define the dark/very-dim/dim/normal/bright light-level buckets.
Definition: TSL2591.cpp:241
TSL2591(E_TSL2591_IntegrationTime integrationTimeMilliseconds=E_TSL2591_IntegrationTime::ATIME_100MS, E_TSL2591_AmplificationGain amplificationGain=E_TSL2591_AmplificationGain::GAIN_MED)
Builds a TSL2591 with the given integration time and gain, and default light-level cutoffs.
Definition: TSL2591.cpp:20
virtual void SetTiming(const E_TSL2591_IntegrationTime integrationTimeMilliseconds, const E_TSL2591_AmplificationGain amplificationGain)
Writes the combined integration-time and gain byte to the sensor's control register,...
Definition: TSL2591.cpp:449
virtual std::string ToString() const override
Serializes the raw CH0/CH1 readings, calculated lux, and current gain to a string.
Definition: TSL2591.cpp:601
E_TSL2591_AmplificationGain myAmplificationGain
The current amplification gain.
Definition: TSL2591.h:69
float myLightCutoffDim
Upper lux bound of the "Dim" bucket.
Definition: TSL2591.h:75
virtual void TurnOn() override
Initializes the sensor over I2C, powers on the ALS, applies the timing/gain, and lets the sensor wake...
Definition: TSL2591.cpp:62
float myLightCutoffDark
Upper lux bound of the "Dark" bucket.
Definition: TSL2591.h:73
virtual E_LightLevel CalculateLightLevel() const
Maps the most recent lux reading onto a 0 (pitch dark) to 5 (very bright) level.
Definition: TSL2591.cpp:174
float myLightCutoffVeryDim
Upper lux bound of the "Very Dim" bucket.
Definition: TSL2591.h:74
virtual ~TSL2591()
Destroys the sensor.
Definition: TSL2591.cpp:46
int myFileDescriptor
The open i2c device file descriptor.
Definition: TSL2591.h:64
static E_TSL2591_AmplificationGain ConvertDecimalMultiplierToAmplificationGain(const float decimalMultiplier)
Converts a decimal gain multiplier to the closest amplification-gain enum at or below it.
Definition: TSL2591.cpp:571
float myLightCutoffBright
Upper lux bound of the "Bright" bucket.
Definition: TSL2591.h:77
static E_TSL2591_IntegrationTime ConvertDecimalMillisecondsToIntegrationTime(const float decimalMilliseconds)
Converts a millisecond value to the closest integration-time enum at or below it.
Definition: TSL2591.cpp:498
virtual bool AdjustAndValidateSettings(const uint16_t ch0)
Auto-adjusts the amplification gain one step down when the channel is flooded (> 62000) or one step u...
Definition: TSL2591.cpp:325
uint16_t myRawChannel0Reading
The most recent raw full-spectrum (CH0) reading.
Definition: TSL2591.h:65
float myCalculatedLux
The most recently calculated lux value.
Definition: TSL2591.h:67
RumPi is the library's top-level facade.
Definition: AlertManager.h:6
constexpr int TSL2591_C1DATA_L
Definition: TSL2591.h:19
constexpr int TSL2591_COMMAND_BIT
Definition: TSL2591.h:15
constexpr int TSL2591_ADDR
Definition: TSL2591.h:14
E_TSL2591_AmplificationGain
This represents the amplification level, helpful for low/high light situations.
Definition: TSL2591.h:48
constexpr double TSL2591_LUX_COEFB
Definition: TSL2591.h:23
constexpr int TSL2591_CONTROL_REG
Definition: TSL2591.h:17
constexpr int TSL2591_C0DATA_L
Definition: TSL2591.h:18
E_LightLevel
How much light the sensor is seeing, darkest to brightest.
Definition: SensorLevels.h:17
constexpr double TSL2591_LUX_DF
Definition: TSL2591.h:22
constexpr int TSL2591_ENABLE_REG
Definition: TSL2591.h:16
E_TSL2591_IntegrationTime
This represents how long the sensor looks at the light in a reading.
Definition: TSL2591.h:32