Use the unknown values in service, too

This commit is contained in:
Matti Viljanen 2021-05-22 23:42:57 +03:00
parent 843cfa8db7
commit d3f1297afd
No known key found for this signature in database
GPG key ID: CF32A1495158F888
2 changed files with 5 additions and 3 deletions

View file

@ -266,13 +266,14 @@ void Battery::showHealthNotification() {
}; };
// map string values from sysfs file to alert category // map string values from sysfs file to alert category
static const QMap<QString, int> HealthState { static const QMap<QString, int> HealthState {
{ "unknown" , HealthThresh["ok"] },
{ "good" , HealthThresh["ok"] }, { "good" , HealthThresh["ok"] },
{ "warm" , HealthThresh["warn"] }, { "warm" , HealthThresh["warn"] },
{ "cool" , HealthThresh["warn"] }, { "cool" , HealthThresh["warn"] },
{ "overheat" , HealthThresh["crit"] }, { "overheat" , HealthThresh["crit"] },
{ "cold" , HealthThresh["crit"] } { "cold" , HealthThresh["crit"] }
}; };
if(settings->getHealthNotificationsInterval() < 610 && ( HealthState[health] != HealthThresh["ok"] && HealthState[health] >= settings->getHealthAlert() ) ) { if(settings->getHealthNotificationsInterval() < 610 && temperature != 0x7FFFFFFF && ( HealthState[health] != HealthThresh["ok"] && HealthState[health] >= settings->getHealthAlert() ) ) {
QString displayTemp = QString::number(temperature / 10.0); QString displayTemp = QString::number(temperature / 10.0);
if (QLocale().measurementSystem() == QLocale::ImperialUSSystem) if (QLocale().measurementSystem() == QLocale::ImperialUSSystem)
displayTemp = QString::number((temperature / 10) * 1.8 + 32) + " F"; displayTemp = QString::number((temperature / 10) * 1.8 + 32) + " F";

View file

@ -73,8 +73,9 @@ private:
bool chargerConnected = false; // Charger plugged in bool chargerConnected = false; // Charger plugged in
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
int temperature = 0; // freezing
QString health = "Good"; // good, warm, overheat, possibly more QString health = "unknown"; // Good, warm, overheat. Might have Cold or Overvoltage depending on driver
int temperature = 0x7FFFFFFF; // This value means "unknown" (32-bit INT_MAX)
int enableChargingValue = 1; int enableChargingValue = 1;
int disableChargingValue = 0; int disableChargingValue = 0;