From fcba2cd1248bbdaefb8f77239cd541a88f9d3755 Mon Sep 17 00:00:00 2001 From: Daniel Klaffenbach Date: Sun, 7 Nov 2010 15:09:36 +0100 Subject: [PATCH] Add support for automatic bq27x00_battery module loading This will allow QCPUFreq to display a more accurate temperature value. --- src/data/scripts/QCPUFreq.helper | 4 ++++ src/mainwindow.cpp | 29 +++++++++++++++++++++++++---- src/mainwindow.h | 2 ++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/data/scripts/QCPUFreq.helper b/src/data/scripts/QCPUFreq.helper index 7153fd5..a867e8a 100755 --- a/src/data/scripts/QCPUFreq.helper +++ b/src/data/scripts/QCPUFreq.helper @@ -9,6 +9,10 @@ if [[ -z $1 || -z $2 ]]; then fi case "$1" in + "load_bq27") + /sbin/modprobe bq27x00_battery + exit 0 + ;; "set_maxfreq") #set scaling_max_freq echo $2 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 318f471..5b0193a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -54,12 +54,12 @@ MainWindow::MainWindow(QWidget *parent) : settings = new Settings; settings->hide(); + //applies the settings from the settings dialog + applySettings(); + init(); refresh(); - // setup auto rotation - setAutoRotation(); - //initialize orientation orientationChanged(); @@ -83,7 +83,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->sr_box, SIGNAL(clicked()), this, SLOT(setSmartReflex())); connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettings())); - connect(settings, SIGNAL(settingsChanged()), this, SLOT(setAutoRotation())); + connect(settings, SIGNAL(settingsChanged()), this, SLOT(applySettings())); } @@ -140,6 +140,16 @@ void MainWindow::adjustFreq() /** + * SLOT: applies the settings from the Settings dialog. + */ +void MainWindow::applySettings() +{ + setAutoRotation(); + setAdvancedTemperature(); +} + + +/** * Calls the QCPUFreq helper script with "sudo action param" * * @param action : the action of the helper script @@ -435,6 +445,17 @@ void MainWindow::orientationChanged() /** + * Checks the settings if the "bq27x00_battery" needs to be loaded. + */ +void MainWindow::setAdvancedTemperature() +{ + if (settings->usePowerKernel() && settings->useAdvancedTemperature()) { + callHelper( "load_bq27", "null" ); + } +} + + +/** * Enables or disables the auto-rotation feature of Maemo5 devices. */ void MainWindow::setAutoRotation() diff --git a/src/mainwindow.h b/src/mainwindow.h index b2fc16c..0d0bdcc 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,8 +43,10 @@ public: public slots: void about(); void adjustFreq(); + void applySettings(); void orientationChanged(); void refresh(); + void setAdvancedTemperature(); void setAutoRotation(); void setSmartReflex(); void showHelp(); -- 1.7.9.5