qtmobility/plugins/sensors/maemo6/maemo6compass.cpp
changeset 11 06b8e2af4411
parent 8 71781823f776
child 14 6fbed849b4f4
--- a/qtmobility/plugins/sensors/maemo6/maemo6compass.cpp	Thu May 27 13:42:11 2010 +0300
+++ b/qtmobility/plugins/sensors/maemo6/maemo6compass.cpp	Fri Jun 11 14:26:25 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -53,8 +53,7 @@
         initSensor<CompassSensorChannelInterface>("compasssensor");
 
         if (m_sensorInterface) {
-            QObject::connect(static_cast<CompassSensorChannelInterface*>(m_sensorInterface), SIGNAL(levelChanged(const int&)), this, SLOT(slotLevelChanged(const int&)));
-            QObject::connect(static_cast<CompassSensorChannelInterface*>(m_sensorInterface), SIGNAL(degreesChanged(const int&)), this, SLOT(slotDegreesChanged(const int&)));
+            QObject::connect(static_cast<CompassSensorChannelInterface*>(m_sensorInterface), SIGNAL(dataAvailable(const Compass&)), this, SLOT(dataAvailable(const Compass&)));
         } else {
             qWarning() << "Unable to initialize compass sensor.";            
         }
@@ -69,26 +68,16 @@
     }
 }
 
-void maemo6compass::slotLevelChanged(const int& level)
+void maemo6compass::dataAvailable(const Compass& data)
 {
     // The scale for level is [0,3], where 3 is the best
     // Qt: Measured as a value from 0 to 1 with higher values being better.
-    float l = ((float) level) / 3.0;
+    m_reading.setCalibrationLevel(((float) data.level()) / 3.0);
 
-    qreal calibrationLevel = l;
-    m_reading.setCalibrationLevel(calibrationLevel);
-    //m_reading.setTimestamp(level.timestamp());
-    m_reading.setTimestamp(createTimestamp()); //TODO: use correct timestamp
+    // The scale for degrees from sensord is [0,359]
+    // Value can be directly used as azimuth
+    m_reading.setAzimuth(data.degrees());
+
+    m_reading.setTimestamp(data.data().timestamp_);
     newReadingAvailable();
 }
-
-void maemo6compass::slotDegreesChanged(const int& degrees)
-{
-    // The scale for degrees from sensord is [0,359]
-    // Value can be directly used as azimuth
-    qreal azimuth = degrees;
-    m_reading.setAzimuth(azimuth);
-    //m_reading.setTimestamp(degrees.timestamp());
-    m_reading.setTimestamp(createTimestamp()); //TODO: use correct timestamp
-    newReadingAvailable();
-}