From 2a056d5b23c557c97aab5901be991783ec617e55 Mon Sep 17 00:00:00 2001 From: NBonaparte Date: Sun, 28 Jan 2018 15:43:40 -0800 Subject: [PATCH] fix(power): add comments to explain current/power_now --- src/modules/battery.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 67909260..958cb492 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -85,11 +85,13 @@ namespace modules { m_consumption_reader = make_unique([this,&path_battery] { float consumption; + // if the rate we found was the current, calculate power (P = I*V) if (m_frate == path_battery + "current_now") { 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)}; consumption = ((voltage / 1000.0) * (current / 1000.0)) / 1e6; + // if it was power, just use as is } else { unsigned long power{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)};