Outputs data from a INA219 on stdout.
#include <iostream>
#include <thread>
#include <iomanip>
#include <assert.h>
#include <boost/exception/diagnostic_information.hpp>
constexpr int valw = 8;
bool quit = false;
std::cout.precision(5);
std::int16_t sv, bv;
do {
std::cout <<
"Shunt: " << std::setw(valw) << shnV.
value <<
"v Bus: " << std::setw(valw) << busV.
value <<
"v " <<
std::setw(valw) << busI.value << "A " << std::setw(valw) <<
"W s = " << std::setw(valw-2) << sv << " b = " <<
std::setw(valw-2) << bv << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
} while (!quit);
}
int main(void)
try {
std::unique_ptr<duds::hardware::interface::Smbus> smbus(
"/dev/i2c-1",
0x40,
)
);
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 << "ERROR: " << boost::current_exception_diagnostic_information()
<< std::endl;
return 1;
}