Read more accurate temperature on power kernels
authorDaniel Klaffenbach <danielklaffenbach@gmail.com>
Mon, 28 Jun 2010 21:14:03 +0000 (23:14 +0200)
committerDaniel Klaffenbach <danielklaffenbach@gmail.com>
Mon, 28 Jun 2010 21:14:03 +0000 (23:14 +0200)
src/mainwindow.cpp

index 201e005..712a50e 100755 (executable)
@@ -152,7 +152,13 @@ int MainWindow::callHelper(QString action, QString param)
 QString MainWindow::getCPUTemp()
 {
 #if defined(Q_WS_MAEMO_5)
-    return readSysFile( "devices/platform/omap34xx_temp/temp1_input_raw" );
+    QFile file( "/sys/class/power_supply/bq27200-0/temp" );
+
+    //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" );
 #endif
     return tr( "Unknown" );
 }
@@ -276,6 +282,9 @@ QString MainWindow::readSysFile(QString sys_file)
     QTextStream in( &file );
     QString txt = in.readLine();
 
+    //close the file
+    file.close();
+
     return txt;
 }