fix(battery): use power_now correctly
This commit is contained in:
parent
5c7ff09ed6
commit
95d3b4f1eb
@ -82,11 +82,19 @@ namespace modules {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Make consumption reader
|
// Make consumption reader
|
||||||
m_consumption_reader = make_unique<consumption_reader>([this] {
|
m_consumption_reader = make_unique<consumption_reader>([this,&path_battery] {
|
||||||
|
float consumption;
|
||||||
|
|
||||||
|
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)};
|
||||||
|
|
||||||
float consumption = ((voltage / 1000.0) * (current / 1000.0)) / 1e6;
|
consumption = ((voltage / 1000.0) * (current / 1000.0)) / 1e6;
|
||||||
|
} else {
|
||||||
|
unsigned long power{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)};
|
||||||
|
|
||||||
|
consumption = power / 1e6;
|
||||||
|
}
|
||||||
|
|
||||||
// convert to string with 2 decimmal places
|
// convert to string with 2 decimmal places
|
||||||
string rtn(16, '\0'); // 16 should be plenty big. Cant see it needing more than 6/7..
|
string rtn(16, '\0'); // 16 should be plenty big. Cant see it needing more than 6/7..
|
||||||
|
Loading…
Reference in New Issue
Block a user