From 07a8de4034b28026aa8831ab35e8a74ecfb0ff40 Mon Sep 17 00:00:00 2001 From: datalore Date: Tue, 18 Jun 2024 13:14:59 +0200 Subject: [PATCH] feat: Added capacity and max charge comparison to design --- include/batteryinfo.h | 2 ++ src/batteryinfo.cc | 3 +++ src/main.cc | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/batteryinfo.h b/include/batteryinfo.h index dd795c3..1b593c3 100644 --- a/include/batteryinfo.h +++ b/include/batteryinfo.h @@ -12,10 +12,12 @@ namespace dlore std::string Technology; unsigned int CellSeriesCount; unsigned int Capacity; + unsigned int CapacityDesign; float Vnow; float Vmin; unsigned int ChargeNow; unsigned int ChargeFull; + unsigned int ChargeFullPercentageDesign; unsigned int ChargeFullDesign; } typedef BatteryInfo; diff --git a/src/batteryinfo.cc b/src/batteryinfo.cc index 125ef4b..be52410 100644 --- a/src/batteryinfo.cc +++ b/src/batteryinfo.cc @@ -26,6 +26,9 @@ namespace dlore info.ChargeFull = std::stoi(readData(classPath / "charge_full")) / 1000; info.ChargeFullDesign = std::stoi(readData(classPath / "charge_full_design")) / 1000; + info.ChargeFullPercentageDesign = 100 * info.ChargeFull / info.ChargeFullDesign; + info.CapacityDesign = 100 * info.ChargeNow / info.ChargeFullDesign; + int Vnow = std::stoi(readData(classPath / "voltage_now")) / 1000; int Vmin = std::stoi(readData(classPath / "voltage_min_design")) / 1000; diff --git a/src/main.cc b/src/main.cc index ceec6c9..a5b45f8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -16,12 +16,13 @@ void printBattery(std::filesystem::path classPath) std::cout << std::endl << "\tTechnology: " << bat.Technology; std::cout << std::endl << "\tCell series count: " << bat.CellSeriesCount << 's' << std::endl; std::cout << std::endl << "\tCapacity: " << bat.Capacity << '%'; + std::cout << std::endl << "\tCapacity (design): " << bat.CapacityDesign << '%'; std::cout << std::endl << "\tVmin: " << bat.Vmin << 'V'; std::cout << " Per cell: " << bat.Vmin / bat.CellSeriesCount << 'V'; std::cout << std::endl << "\tVnow: " << bat.Vnow << 'V'; std::cout << " Per cell: " << bat.Vnow / bat.CellSeriesCount << 'V'; std::cout << std::endl << "\tCharge now: " << bat.ChargeNow << "mAh"; - std::cout << std::endl << "\tCharge full: " << bat.ChargeFull << "mAh"; + std::cout << std::endl << "\tCharge full: " << bat.ChargeFull << "mAh (" << bat.ChargeFullPercentageDesign << "% of design)"; std::cout << std::endl << "\tCharge full (design): " << bat.ChargeFullDesign << "mAh" << std::endl; }