Try to calculate temperature from raw value
[qcpufreq] / 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" );
 }