Try to calculate temperature from raw value
authorDaniel Klaffenbach <danielklaffenbach@gmail.com>
Thu, 1 Jul 2010 12:00:47 +0000 (14:00 +0200)
committerDaniel Klaffenbach <danielklaffenbach@gmail.com>
Thu, 1 Jul 2010 12:00:47 +0000 (14:00 +0200)
On vanilla kernels we rely on temperature raw values. According to
some reports on talk.maemo.org the real temperature is approximately
calculated by the formula real=(raw*0.65).

src/mainwindow.cpp

index 712a50e..18d3e6e 100755 (executable)
@@ -156,9 +156,19 @@ QString MainWindow::getCPUTemp()
 
     //check if we can read a more accurate temperature (only for power kernel)
     if (file.exists())
-       return QString( readSysFile( "class/power_supply/bq27200-0/temp" ) + " °C" );
-    else
-       return readSysFile( "devices/platform/omap34xx_temp/temp1_input_raw" );
+       return QString( readSysFile( "class/power_supply/bq27200-0/temp" ) + " " + QString::fromUtf8("\302\260") + "C" );
+    else {
+       //read the current system temperature
+       QString tstring = readSysFile( "devices/platform/omap34xx_temp/temp1_input_raw" );
+       if (tstring == "0")
+           return tr( "Unknown" );
+
+       //convert it to an integer and calculate the approx. temperature from the raw value
+       int tint = tstring.toInt();
+       tint = ( 0.65 * tint );
+       tstring.setNum(tint);
+       return QString( tstring + " " + QString::fromUtf8("\302\260") + "C" );
+    }
 #endif
     return tr( "Unknown" );
 }