Display current CPU temperature
[qcpufreq] / src / mainwindow.cpp
index d36e648..0a9af8b 100755 (executable)
@@ -47,6 +47,7 @@ MainWindow::MainWindow(QWidget *parent) :
     connect( ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()) );
     connect( ui->freq_adjust, SIGNAL(valueChanged(int)), this, SLOT(adjustFreq()) );
     connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
+    connect( ui->sr_btn, SIGNAL(clicked()), this, SLOT(setSmartReflex()) );
 
 }
 
@@ -92,6 +93,18 @@ void MainWindow::adjustFreq()
 
 
 /**
+  * Returns the current CPU temperature
+  */
+QString MainWindow::getCPUTemp()
+{
+#if defined(Q_WS_MAEMO_5)
+    return readSysFile( "devices/platform/omap34xx_temp/temp1_input_raw" );
+#endif
+    return "Unknown";
+}
+
+
+/**
   * Returns the maximum CPU frequency
   */
 int MainWindow::getMaxFreq()
@@ -231,6 +244,9 @@ void MainWindow::refresh()
     //display the current governor
     ui->freq_governor->setText( getScalingGovernor() );
 
+    //display current temperature
+    ui->cpu_temp->setText( getCPUTemp() );
+
     //smart reflex button
     if ( getSmartReflexState() == 1 ) {
        ui->sr_btn->setDown( true );
@@ -290,6 +306,31 @@ void MainWindow::setAutoRotaion()
 
 
 /**
+  * SLOT: Enables or disables Smart Reflex(tm) after pressing sr_btn
+  */
+void MainWindow::setSmartReflex()
+{
+//SmartReflex is only supprted on Maemo5
+#if defined(Q_WS_MAEMO_5)
+    QStringList arguments;
+    arguments.append( "/opt/usr/bin/set_sr" );
+
+    if ( getSmartReflexState() == 1 )
+       arguments.append( "off" );
+    else
+       arguments.append( "on" );
+
+    //execute the sr script script
+    QProcess script;
+    script.execute( "sudo", arguments );
+
+#endif
+    //refresh the UI
+    refresh();
+}
+
+
+/**
   * Returns true when the device is in portrait mode
   */
 bool MainWindow::usePortrait()