Outputs data from a TSL2591 on stdout.
#include <iostream>
#include <thread>
#include <iomanip>
#include <assert.h>
#include <boost/exception/diagnostic_information.hpp>
constexpr int valw = 8;
bool quit = false;
try {
);
std::cout.precision(6);
std::uint16_t c0, c1;
do {
std::this_thread::sleep_for(std::chrono::seconds(1));
assert(visB.
unit == chku);
assert(irB.
unit == chku);
std::cout <<
"Visible: " << std::setw(16) << visB.
value <<
"W/m2 " <<
std::setw(16) << irB.
value <<
"W/m2 " << std::setw(5) <<
} while (!quit);
} catch (...) {
std::cerr << "Program failed in runtest(): " <<
boost::current_exception_diagnostic_information() << std::endl;
}
int main(int argc, char *argv[])
try {
std::unique_ptr<duds::hardware::interface::I2c> i2c(
argc > 1 ? argv[1] : "/dev/i2c-1",
0x29
)
);
int gain = 0;
int integration = 0;
meter.
init(gain, integration);
std::this_thread::sleep_for(std::chrono::milliseconds(2));
std::thread doit(runtest, std::ref(meter));
std::cin.get();
quit = true;
doit.join();
} catch (...) {
std::cerr << "Program failed in main(): " <<
boost::current_exception_diagnostic_information() << std::endl;
return 1;
}