Add support for automatic bq27x00_battery module loading
authorDaniel Klaffenbach <danielklaffenbach@gmail.com>
Sun, 7 Nov 2010 14:09:36 +0000 (15:09 +0100)
committerDaniel Klaffenbach <danielklaffenbach@gmail.com>
Sun, 7 Nov 2010 14:09:36 +0000 (15:09 +0100)
This will allow QCPUFreq to display a more accurate temperature value.

src/data/scripts/QCPUFreq.helper
src/mainwindow.cpp
src/mainwindow.h

index 7153fd5..a867e8a 100755 (executable)
@@ -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
index 318f471..5b0193a 100644 (file)
@@ -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()
index b2fc16c..0d0bdcc 100644 (file)
@@ -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();