From: Daniel Klaffenbach Date: Wed, 23 Jun 2010 10:42:38 +0000 (+0200) Subject: Display current CPU temperature X-Git-Tag: v0.2~4 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=413d3e851aa5ddae729856c15af42a88201f4a85;p=qcpufreq Display current CPU temperature --- diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d36e648..0a9af8b 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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() diff --git a/src/mainwindow.h b/src/mainwindow.h index d438ee2..448aa53 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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 ); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index aa85343..fd4f6a6 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -71,6 +71,20 @@ + + + Current CPU temperature: + + + + + + + Unknown + + + + @@ -83,7 +97,7 @@ - +