From 44fc44be436b7fc756272413e54b95aae81e9c13 Mon Sep 17 00:00:00 2001 From: Matti Viljanen Date: Sun, 2 May 2021 13:46:40 +0300 Subject: [PATCH] Revert "Merge pull request #40 from nephros/health", continue work in branch `health` This reverts commit 4a535edd59a2e57b4894eb41f2e4fc3948f95e20, reversing changes made to 54cbd89efaab73f3f772485d221c58871062445b. --- application/qml/pages/MainPage.qml | 15 -------------- application/src/battery.cpp | 32 ------------------------------ application/src/battery.h | 18 ----------------- 3 files changed, 65 deletions(-) diff --git a/application/qml/pages/MainPage.qml b/application/qml/pages/MainPage.qml index d60147a..d6cf582 100644 --- a/application/qml/pages/MainPage.qml +++ b/application/qml/pages/MainPage.qml @@ -31,11 +31,6 @@ Page { "empty": qsTr("empty", "Battery fully depleted"), "unknown": qsTr("unknown", "Battery not detected, or faulty, or something") } - property variant healthText: { - "good": qsTr("Good", "Battery is OK"), - "warm": qsTr("Warm", "Battery is warm"), - "overheat": qsTr("Overheated", "Battery is very hot"), - } property bool serviceRunning: true Timer { @@ -171,16 +166,6 @@ Page { label: qsTr("State:") value: statusText[battery.state] } - MyDetailItem { - label: qsTr("Health:") - value: healthText[battery.health] - } - MyDetailItem { - label: qsTr("Temperature:") - // TODO: use weird degrees for US users - //value: useImperial ? celsiusToFahrenheit(battery.temperature) + " F" : Math.floor(battery.temperature / 10) + " °C" - value: Math.floor(battery.temperature / 10) + " °C" - } } } Column { diff --git a/application/src/battery.cpp b/application/src/battery.cpp index 8ae2ee0..06baa98 100644 --- a/application/src/battery.cpp +++ b/application/src/battery.cpp @@ -38,14 +38,6 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO chargerConnectedFile = new QFile("/sys/class/power_supply/usb/present", this); logE("Reading charger status from" + chargerConnectedFile->fileName()); - // Number: temperature - temperatureFile = new QFile("/sys/class/power_supply/battery/temp", this); - logE("Temperature file: " + temperatureFile->fileName()); - - // String: health state - healthFile = new QFile("/sys/class/power_supply/battery/health", this); - logE("Health file: " + healthFile->fileName()); - QString filename; // e.g. for Sony Xperia XA2 @@ -120,26 +112,6 @@ void Battery::updateData() } currentFile->close(); } - if(healthFile && healthFile->open(QIODevice::ReadOnly)) { - nextHealth = (QString(healthFile->readLine().trimmed().toLower())); - if(nextHealth != health) { - health = nextHealth; - emit healthChanged(health); - logV("Health: " + health); - } - healthFile->close(); - } - if(temperatureFile && temperatureFile->open(QIODevice::ReadOnly)) { - nextTemperature = temperatureFile->readLine().trimmed().toInt(); - if(nextTemperature != temperature) { - temperature = nextTemperature; - emit temperatureChanged(temperature); - // TODO: factor might be different depending on device - // X10 has degrees * 10 - logD(QString("Temperature: %1°C").arg(temperature / 10)); - } - temperatureFile->close(); - } } int Battery::getCharge(){ return charge; } @@ -148,10 +120,6 @@ int Battery::getCurrent(){ return current; } QString Battery::getState() { return state; } -QString Battery::getHealth() { return health; } - -int Battery::getTemperature(){ return temperature; } - bool Battery::getChargingEnabled() { return chargingEnabled; } bool Battery::getChargerConnected() { return chargerConnected; } diff --git a/application/src/battery.h b/application/src/battery.h index 2e05717..b059d86 100644 --- a/application/src/battery.h +++ b/application/src/battery.h @@ -36,9 +36,6 @@ class Battery : public QObject Q_PROPERTY(QString state READ getState NOTIFY stateChanged) Q_PROPERTY(bool chargingEnabled READ getChargingEnabled NOTIFY chargingEnabledChanged) - Q_PROPERTY(QString health READ getHealth NOTIFY healthChanged) - Q_PROPERTY(int temperature READ getTemperature NOTIFY temperatureChanged) - public: Battery(Settings* newSettings, Logger* newLogger, QObject* parent = nullptr); ~Battery(); @@ -49,9 +46,6 @@ public: bool getChargerConnected(); QString getState(); - QString getHealth(); - int getTemperature(); - bool getChargingEnabled(); public slots: @@ -66,9 +60,6 @@ private: Settings* settings = nullptr; Logger* logger = nullptr; - QFile* temperatureFile = nullptr; - QFile* healthFile = nullptr; - // Default values: int charge = 100; // 100% full int current = 0; // Not charging/discharging @@ -76,10 +67,6 @@ private: QString state = "idle"; // dis/charging, idle, unknown bool chargingEnabled = true; // Only ever disabled manually - - QString health = "Good"; // Good, Warm, Overheat. Might have Cold or Overvoltage depending on driver - int temperature = 0; // freezing - int enableChargingValue = 1; int disableChargingValue = 0; bool chargerIsEnabled = true; @@ -90,17 +77,12 @@ private: QString nextState = state; bool nextChargingEnabled = chargingEnabled; - QString nextHealth = health; - int nextTemperature = temperature; - signals: void chargeChanged(int); void currentChanged(int); void stateChanged(QString); void chargingEnabledChanged(bool); void chargerConnectedChanged(bool); - void healthChanged(QString); - void temperatureChanged(int); }; #endif // BATTERY_H