Consider capacity for battery sensor

This commit is contained in:
scorpion-26 2023-05-10 13:08:17 +02:00
parent 80ade2b06e
commit c51fadbc79

View file

@ -92,10 +92,8 @@ namespace System
{ {
std::ifstream fullChargeFile(Config::Get().batteryFolder + "/charge_full"); std::ifstream fullChargeFile(Config::Get().batteryFolder + "/charge_full");
std::ifstream currentChargeFile(Config::Get().batteryFolder + "/charge_now"); std::ifstream currentChargeFile(Config::Get().batteryFolder + "/charge_now");
if (!fullChargeFile.is_open() || !currentChargeFile.is_open()) if (fullChargeFile.is_open() && currentChargeFile.is_open())
{ {
return -1.f;
}
std::string fullChargeStr; std::string fullChargeStr;
std::string currentChargeStr; std::string currentChargeStr;
std::getline(fullChargeFile, fullChargeStr); std::getline(fullChargeFile, fullChargeStr);
@ -105,6 +103,18 @@ namespace System
return ((double)intCurrentCharge / (double)intFullCharge); return ((double)intCurrentCharge / (double)intFullCharge);
} }
// Try capacity
std::ifstream capacityFile(Config::Get().batteryFolder + "/capacity");
if (capacityFile.is_open())
{
std::string capacityStr;
std::getline(capacityFile, capacityStr);
uint32_t intCapacity = atoi(capacityStr.c_str());
return (double)intCapacity / 100.0;
}
return -1;
}
RAMInfo GetRAMInfo() RAMInfo GetRAMInfo()
{ {
RAMInfo out{}; RAMInfo out{};