Display current CPU temperature
authorDaniel Klaffenbach <danielklaffenbach@gmail.com>
Wed, 23 Jun 2010 10:42:38 +0000 (12:42 +0200)
committerDaniel Klaffenbach <danielklaffenbach@gmail.com>
Wed, 23 Jun 2010 10:42:38 +0000 (12:42 +0200)
src/mainwindow.cpp
src/mainwindow.h
src/mainwindow.ui

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()
index d438ee2..448aa53 100755 (executable)
@@ -40,10 +40,12 @@ public slots:
     void orientationChanged();
     void refresh();
     void setAutoRotaion();
+    void setSmartReflex();
 
 
 private:
     Ui::MainWindow *ui;
+    QString getCPUTemp();
     int getMaxFreq();
     int getMinFreq();
     int getScalingFreq( int step );
index aa85343..fd4f6a6 100755 (executable)
            </widget>
           </item>
           <item row="3" column="0">
+           <widget class="QLabel" name="label_6">
+            <property name="text">
+             <string>Current CPU temperature:</string>
+            </property>
+           </widget>
+          </item>
+          <item row="3" column="1">
+           <widget class="QLabel" name="cpu_temp">
+            <property name="text">
+             <string>Unknown</string>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="0">
            <widget class="QLabel" name="label_5">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
@@ -83,7 +97,7 @@
             </property>
            </widget>
           </item>
-          <item row="3" column="1">
+          <item row="4" column="1">
            <widget class="QPushButton" name="sr_btn">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Minimum" vsizetype="Minimum">