Revert "Merge pull request #40 from nephros/health", continue work in branch health
This reverts commit4a535edd59
, reversing changes made to54cbd89efa
.
This commit is contained in:
parent
4a535edd59
commit
44fc44be43
3 changed files with 0 additions and 65 deletions
|
@ -31,11 +31,6 @@ Page {
|
||||||
"empty": qsTr("empty", "Battery fully depleted"),
|
"empty": qsTr("empty", "Battery fully depleted"),
|
||||||
"unknown": qsTr("unknown", "Battery not detected, or faulty, or something")
|
"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
|
property bool serviceRunning: true
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
|
@ -171,16 +166,6 @@ Page {
|
||||||
label: qsTr("State:")
|
label: qsTr("State:")
|
||||||
value: statusText[battery.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 {
|
Column {
|
||||||
|
|
|
@ -38,14 +38,6 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
|
||||||
chargerConnectedFile = new QFile("/sys/class/power_supply/usb/present", this);
|
chargerConnectedFile = new QFile("/sys/class/power_supply/usb/present", this);
|
||||||
logE("Reading charger status from" + chargerConnectedFile->fileName());
|
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;
|
QString filename;
|
||||||
|
|
||||||
// e.g. for Sony Xperia XA2
|
// e.g. for Sony Xperia XA2
|
||||||
|
@ -120,26 +112,6 @@ void Battery::updateData()
|
||||||
}
|
}
|
||||||
currentFile->close();
|
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; }
|
int Battery::getCharge(){ return charge; }
|
||||||
|
@ -148,10 +120,6 @@ int Battery::getCurrent(){ return current; }
|
||||||
|
|
||||||
QString Battery::getState() { return state; }
|
QString Battery::getState() { return state; }
|
||||||
|
|
||||||
QString Battery::getHealth() { return health; }
|
|
||||||
|
|
||||||
int Battery::getTemperature(){ return temperature; }
|
|
||||||
|
|
||||||
bool Battery::getChargingEnabled() { return chargingEnabled; }
|
bool Battery::getChargingEnabled() { return chargingEnabled; }
|
||||||
|
|
||||||
bool Battery::getChargerConnected() { return chargerConnected; }
|
bool Battery::getChargerConnected() { return chargerConnected; }
|
||||||
|
|
|
@ -36,9 +36,6 @@ class Battery : public QObject
|
||||||
Q_PROPERTY(QString state READ getState NOTIFY stateChanged)
|
Q_PROPERTY(QString state READ getState NOTIFY stateChanged)
|
||||||
Q_PROPERTY(bool chargingEnabled READ getChargingEnabled NOTIFY chargingEnabledChanged)
|
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:
|
public:
|
||||||
Battery(Settings* newSettings, Logger* newLogger, QObject* parent = nullptr);
|
Battery(Settings* newSettings, Logger* newLogger, QObject* parent = nullptr);
|
||||||
~Battery();
|
~Battery();
|
||||||
|
@ -49,9 +46,6 @@ public:
|
||||||
bool getChargerConnected();
|
bool getChargerConnected();
|
||||||
QString getState();
|
QString getState();
|
||||||
|
|
||||||
QString getHealth();
|
|
||||||
int getTemperature();
|
|
||||||
|
|
||||||
bool getChargingEnabled();
|
bool getChargingEnabled();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -66,9 +60,6 @@ private:
|
||||||
Settings* settings = nullptr;
|
Settings* settings = nullptr;
|
||||||
Logger* logger = nullptr;
|
Logger* logger = nullptr;
|
||||||
|
|
||||||
QFile* temperatureFile = nullptr;
|
|
||||||
QFile* healthFile = nullptr;
|
|
||||||
|
|
||||||
// Default values:
|
// Default values:
|
||||||
int charge = 100; // 100% full
|
int charge = 100; // 100% full
|
||||||
int current = 0; // Not charging/discharging
|
int current = 0; // Not charging/discharging
|
||||||
|
@ -76,10 +67,6 @@ private:
|
||||||
QString state = "idle"; // dis/charging, idle, unknown
|
QString state = "idle"; // dis/charging, idle, unknown
|
||||||
bool chargingEnabled = true; // Only ever disabled manually
|
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 enableChargingValue = 1;
|
||||||
int disableChargingValue = 0;
|
int disableChargingValue = 0;
|
||||||
bool chargerIsEnabled = true;
|
bool chargerIsEnabled = true;
|
||||||
|
@ -90,17 +77,12 @@ private:
|
||||||
QString nextState = state;
|
QString nextState = state;
|
||||||
bool nextChargingEnabled = chargingEnabled;
|
bool nextChargingEnabled = chargingEnabled;
|
||||||
|
|
||||||
QString nextHealth = health;
|
|
||||||
int nextTemperature = temperature;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void chargeChanged(int);
|
void chargeChanged(int);
|
||||||
void currentChanged(int);
|
void currentChanged(int);
|
||||||
void stateChanged(QString);
|
void stateChanged(QString);
|
||||||
void chargingEnabledChanged(bool);
|
void chargingEnabledChanged(bool);
|
||||||
void chargerConnectedChanged(bool);
|
void chargerConnectedChanged(bool);
|
||||||
void healthChanged(QString);
|
|
||||||
void temperatureChanged(int);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BATTERY_H
|
#endif // BATTERY_H
|
||||||
|
|
Loading…
Reference in a new issue