move temperature correction factor

This commit is contained in:
nephros 2023-03-06 17:31:07 +01:00
parent 7a4017cfd8
commit adf154db23
4 changed files with 13 additions and 13 deletions

View file

@ -115,6 +115,11 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
break;
}
}
// e.g. PineTab outputs an integer in centi-centigrade
// Note that the formatter in the QML page, and the logger divide by 10 again!
if(temperatureFile->fileName().contains(QStringLiteral("xp20x-battery"))) {
tempCorrectionFactor = 10.0;
}
logL("Battery temperature file: " + (temperatureFile ? temperatureFile->fileName() : notFound));
@ -243,12 +248,6 @@ void Battery::updateData()
healthFile->close();
}
// e.g. PineTab outputs an integer in centi-centigrade
// Note that the formatter in the QML page, and the logger divide by 10 again!
float tempCorrectionFactor = 1.0 ;
if(temperatureFile->fileName().contains(QStringLiteral("xp20x-battery"))) {
tempCorrectionFactor = 10.0 ;
}
if(temperatureFile && temperatureFile->open(QIODevice::ReadOnly)) {
nextTemperature = temperatureFile->readLine().trimmed().toInt() / tempCorrectionFactor;
if(nextTemperature != temperature) {

View file

@ -85,6 +85,7 @@ private:
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)
float tempCorrectionFactor = 1.0; // PineTab outputs an integer in centi-centigrade
int enableChargingValue = 1;
int disableChargingValue = 0;
@ -99,7 +100,6 @@ private:
QString nextState = state;
bool nextChargingEnabled = chargingEnabled;
QString nextHealth = health;
int nextTemperature = temperature;

View file

@ -168,6 +168,12 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QCoreApplication *app, QOb
}
}
// e.g. PineTab outputs an integer in centi-centigrade
// Note that the formatter in the QML page, and the logger divide by 10 again!
if(temperatureFile->fileName().contains(QStringLiteral("xp20x-battery"))) {
tempCorrectionFactor = 10.0;
}
logL("Battery temperature file: " + (temperatureFile ? temperatureFile->fileName() : notFound));
// String: health state
@ -323,12 +329,6 @@ void Battery::updateData()
stateFile->close();
}
// e.g. PineTab outputs an integer in centi-centigrade
// Note that the formatter in the QML page, and the logger divide by 10 again!
float tempCorrectionFactor = 1.0 ;
if(temperatureFile->fileName().contains(QStringLiteral("xp20x-battery"))) {
tempCorrectionFactor = 10.0 ;
}
if(temperatureFile && temperatureFile->open(QIODevice::ReadOnly)) {
nextTemperature = temperatureFile->readLine().trimmed().toInt() / tempCorrectionFactor;
if(nextTemperature != temperature) {

View file

@ -121,6 +121,7 @@ private:
QString nextState = state;
bool nextChargingEnabled = chargingEnabled;
int nextTemperature = temperature;
float tempCorrectionFactor = 1.0;
QString nextHealth = health;
QFileDevice::Permissions originalPerms; // Updated in constructor