fix(power): add comments to explain current/power_now

This commit is contained in:
NBonaparte 2018-01-28 15:43:40 -08:00 committed by Patrick Ziegler
parent 95d3b4f1eb
commit 2a056d5b23

View File

@ -85,11 +85,13 @@ namespace modules {
m_consumption_reader = make_unique<consumption_reader>([this,&path_battery] { m_consumption_reader = make_unique<consumption_reader>([this,&path_battery] {
float consumption; float consumption;
// if the rate we found was the current, calculate power (P = I*V)
if (m_frate == path_battery + "current_now") { if (m_frate == path_battery + "current_now") {
unsigned long current{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)}; unsigned long current{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)};
unsigned long voltage{std::strtoul(file_util::contents(m_fvoltage).c_str(), nullptr, 10)}; unsigned long voltage{std::strtoul(file_util::contents(m_fvoltage).c_str(), nullptr, 10)};
consumption = ((voltage / 1000.0) * (current / 1000.0)) / 1e6; consumption = ((voltage / 1000.0) * (current / 1000.0)) / 1e6;
// if it was power, just use as is
} else { } else {
unsigned long power{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)}; unsigned long power{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)};