DUDS
Distributed Update of Data from Something
duds::hardware::devices::instruments::TSL2591 Class Reference

A quick try at supporting TSL2591 brightness sensor; will change significantly in the future. More...

#include <TSL2591.hpp>

Inheritance diagram for duds::hardware::devices::instruments::TSL2591:
Collaboration diagram for duds::hardware::devices::instruments::TSL2591:

Public Member Functions

 TSL2591 (std::unique_ptr< duds::hardware::interface::I2c > &c)
 Attempts to identify the device, then performs a reset. More...
 
 ~TSL2591 ()
 Calls suspend(). More...
 
duds::data::Quantity brightness () const
 Broad spectrum brightness. More...
 
std::uint16_t brightnessCount () const
 The value reported by the device for the broad spectrum brightness. More...
 
duds::data::Quantity brightnessIr () const
 Brightness mostly in infrared. More...
 
std::uint16_t brightnessIrCount () const
 The value reported by the device for the infrared brightness. More...
 
void init (int gain, int integration)
 Configures the device. More...
 
void resume ()
 Resumes operation after a call to suspend(). More...
 
void sample ()
 The device will update samples after it has completed integration. More...
 
void suspend ()
 Suspends operation by putting the device into a low-power mode. More...
 

Private Attributes

std::uint16_t broad
 The values supplied by the device. More...
 
std::unique_ptr< duds::hardware::interface::I2ccom
 The I2C communication interface. More...
 
duds::hardware::interface::Conversation initialize
 The conversation used to initialize the device. More...
 
duds::hardware::interface::Conversation input
 The conversation used to query the brightness values. More...
 
std::uint16_t ir
 
double scale
 A scalar value used to partially convert the counts supplied by the device into a value in Watts per square meter. More...
 

Detailed Description

A quick try at supporting TSL2591 brightness sensor; will change significantly in the future.

Seems to work, except the Quantity values are wrong.

Author
Jeff Jackowski
Examples:
tsl2591test.cpp.

Definition at line 40 of file TSL2591.hpp.

Constructor & Destructor Documentation

◆ TSL2591()

duds::hardware::devices::instruments::TSL2591::TSL2591 ( std::unique_ptr< duds::hardware::interface::I2c > &  c)

Attempts to identify the device, then performs a reset.

This should leave it in a low-power state where it does not sample. Default device address is 0x29.

Exceptions
DeviceMisidentifiedThe reported device ID is incorrect.

Definition at line 81 of file TSL2591.cpp.

◆ ~TSL2591()

duds::hardware::devices::instruments::TSL2591::~TSL2591 ( )

Calls suspend().

Definition at line 123 of file TSL2591.cpp.

Member Function Documentation

◆ brightness()

duds::data::Quantity duds::hardware::devices::instruments::TSL2591::brightness ( ) const

Broad spectrum brightness.

Includes visible and infrared.

Bug:
The value is wrong. I'm not sure which numbers on the datasheet to use to generate the number, or even if any of them are the ones needed. Changing the gain will result in very different results for the same light.
Examples:
tsl2591test.cpp.

Definition at line 180 of file TSL2591.cpp.

◆ brightnessCount()

std::uint16_t duds::hardware::devices::instruments::TSL2591::brightnessCount ( ) const
inline

The value reported by the device for the broad spectrum brightness.

Examples:
tsl2591test.cpp.

Definition at line 121 of file TSL2591.hpp.

◆ brightnessIr()

duds::data::Quantity duds::hardware::devices::instruments::TSL2591::brightnessIr ( ) const

Brightness mostly in infrared.

Bug:
The value is wrong. I'm not sure which numbers on the datasheet to use to generate the number, or even if any of them are the ones needed. Changing the gain will result in very different results for the same light.
Examples:
tsl2591test.cpp.

Definition at line 191 of file TSL2591.cpp.

◆ brightnessIrCount()

std::uint16_t duds::hardware::devices::instruments::TSL2591::brightnessIrCount ( ) const
inline

The value reported by the device for the infrared brightness.

Examples:
tsl2591test.cpp.

Definition at line 135 of file TSL2591.hpp.

◆ init()

void duds::hardware::devices::instruments::TSL2591::init ( int  gain,
int  integration 
)

Configures the device.

Parameters
gainThe gain mode to use. 0 is the lowest gain, and 3 is the highest. The factors are listed as:
  1. 1
  2. 25
  3. 428
  4. 9876
integrationThe integration time. It may be specified in milliseconds with values between 100 and 600. Only increments of 100ms can be used; values between these increments will be reduced to the next lowest value. The time may also be specified as a value between 0 (100ms) and 5 (600ms).
Exceptions
TSL2591BadGain
TSL2591BadIntegration
Examples:
tsl2591test.cpp.

Definition at line 127 of file TSL2591.cpp.

◆ resume()

void duds::hardware::devices::instruments::TSL2591::resume ( )

Resumes operation after a call to suspend().

Exceptions
DeviceUninitalizedinit() hasn't been called.

Definition at line 165 of file TSL2591.cpp.

◆ sample()

void duds::hardware::devices::instruments::TSL2591::sample ( )

The device will update samples after it has completed integration.

Sampling faster than that will read old values, but not bad data.

Examples:
tsl2591test.cpp.

Definition at line 172 of file TSL2591.cpp.

◆ suspend()

void duds::hardware::devices::instruments::TSL2591::suspend ( )

Suspends operation by putting the device into a low-power mode.

Definition at line 155 of file TSL2591.cpp.

Referenced by ~TSL2591().

Member Data Documentation

◆ broad

std::uint16_t duds::hardware::devices::instruments::TSL2591::broad
private

The values supplied by the device.

Definition at line 65 of file TSL2591.hpp.

Referenced by brightness(), and sample().

◆ com

std::unique_ptr<duds::hardware::interface::I2c> duds::hardware::devices::instruments::TSL2591::com
private

The I2C communication interface.

Definition at line 44 of file TSL2591.hpp.

Referenced by init(), resume(), sample(), suspend(), and TSL2591().

◆ initialize

duds::hardware::interface::Conversation duds::hardware::devices::instruments::TSL2591::initialize
private

The conversation used to initialize the device.

It is created in init() and held for later use by resume().

Definition at line 49 of file TSL2591.hpp.

Referenced by init(), and resume().

◆ input

duds::hardware::interface::Conversation duds::hardware::devices::instruments::TSL2591::input
private

The conversation used to query the brightness values.

It is created once in the constructor to avoid recreating it.

Definition at line 54 of file TSL2591.hpp.

Referenced by sample(), and TSL2591().

◆ ir

std::uint16_t duds::hardware::devices::instruments::TSL2591::ir
private

Definition at line 65 of file TSL2591.hpp.

Referenced by brightnessIr(), and sample().

◆ scale

double duds::hardware::devices::instruments::TSL2591::scale
private

A scalar value used to partially convert the counts supplied by the device into a value in Watts per square meter.

It takes into account the gain and integration settings.

Bug:
The value is almost certainly wrong.

Definition at line 61 of file TSL2591.hpp.

Referenced by brightness(), brightnessIr(), and init().


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