summaryrefslogtreecommitdiffstats
path: root/plugins/sensors
diff options
context:
space:
mode:
authorEckhart Koppen <eckhart.koppen@nokia.com>2011-04-20 11:52:57 +0300
committerEckhart Koppen <eckhart.koppen@nokia.com>2011-04-20 11:52:57 +0300
commitfb3e9bc2d941462f1244aaf0ea79425a307f883d (patch)
treeafce91959098ec887ce466abc6e40342261df3db /plugins/sensors
parentc61d909c7b815319e40ba27d7f84e92aa5f1f946 (diff)
parent6f0dc7cc40dd63763a581a7fb6d4e76649b8026c (diff)
Merge branch 'master' into 1.2.0v1.2.0
Diffstat (limited to 'plugins/sensors')
-rw-r--r--plugins/sensors/meego/Sensors.conf5
-rw-r--r--plugins/sensors/meego/main.cpp3
-rw-r--r--plugins/sensors/meego/meego.pri7
-rw-r--r--plugins/sensors/meego/meegoaccelerometer.cpp12
-rw-r--r--plugins/sensors/meego/meegoaccelerometer.h4
-rw-r--r--plugins/sensors/meego/meegoals.cpp9
-rw-r--r--plugins/sensors/meego/meegoals.h2
-rw-r--r--plugins/sensors/meego/meegocompass.cpp9
-rw-r--r--plugins/sensors/meego/meegocompass.h2
-rw-r--r--plugins/sensors/meego/meegogyroscope.cpp12
-rw-r--r--plugins/sensors/meego/meegogyroscope.h4
-rw-r--r--plugins/sensors/meego/meegoirproximitysensor.cpp83
-rw-r--r--plugins/sensors/meego/meegoirproximitysensor.h75
-rw-r--r--plugins/sensors/meego/meegolightsensor.cpp9
-rw-r--r--plugins/sensors/meego/meegolightsensor.h2
-rw-r--r--plugins/sensors/meego/meegomagnetometer.cpp12
-rw-r--r--plugins/sensors/meego/meegomagnetometer.h4
-rw-r--r--plugins/sensors/meego/meegoorientationsensor.cpp9
-rw-r--r--plugins/sensors/meego/meegoorientationsensor.h2
-rw-r--r--plugins/sensors/meego/meegoproximitysensor.cpp9
-rw-r--r--plugins/sensors/meego/meegoproximitysensor.h3
-rw-r--r--plugins/sensors/meego/meegorotationsensor.cpp10
-rw-r--r--plugins/sensors/meego/meegorotationsensor.h2
-rw-r--r--plugins/sensors/meego/meegosensorbase.cpp18
-rw-r--r--plugins/sensors/meego/meegosensorbase.h35
-rw-r--r--plugins/sensors/meego/meegotapsensor.cpp2
-rw-r--r--plugins/sensors/meego/meegotapsensor.h2
-rw-r--r--plugins/sensors/meego/qirproximitysensor.cpp153
-rw-r--r--plugins/sensors/meego/qirproximitysensor.h82
-rw-r--r--plugins/sensors/meego/qirproximitysensor_p.h78
-rw-r--r--plugins/sensors/n900/n900proximitysensor.cpp9
-rw-r--r--plugins/sensors/symbian/rotationsensorsym.cpp19
32 files changed, 572 insertions, 115 deletions
diff --git a/plugins/sensors/meego/Sensors.conf b/plugins/sensors/meego/Sensors.conf
index f3b7965518..aa3be63a38 100644
--- a/plugins/sensors/meego/Sensors.conf
+++ b/plugins/sensors/meego/Sensors.conf
@@ -4,7 +4,8 @@ QAmbientLightSensor=meego.als
QCompass=meego.compass
QMagnetometer=meego.magnetometer
QOrientationSensor=meego.orientationsensor
-QProximitySensor=meego.proximity
+QProximitySensor=meego.proximitysensor
QRotationSensor=meego.rotationsensor
QTapSensor=meego.tapsensor
-QLightSensor=meego.lightsensor \ No newline at end of file
+QLightSensor=meego.lightsensor
+QIRProximitySensor=meego.irproximitysensor
diff --git a/plugins/sensors/meego/main.cpp b/plugins/sensors/meego/main.cpp
index 40981e0fe3..46e5bde767 100644
--- a/plugins/sensors/meego/main.cpp
+++ b/plugins/sensors/meego/main.cpp
@@ -45,6 +45,7 @@
#include "meegomagnetometer.h"
#include "meegoorientationsensor.h"
#include "meegoproximitysensor.h"
+#include "meegoirproximitysensor.h"
#include "meegorotationsensor.h"
#include "meegotapsensor.h"
#include "meegogyroscope.h"
@@ -99,6 +100,8 @@ public:
return new meegogyroscope(sensor);
if (sensor->identifier() == meegolightsensor::id)
return new meegolightsensor(sensor);
+ if (sensor->identifier() == meegoirproximitysensor::id)
+ return new meegoirproximitysensor(sensor);
return 0;
}
};
diff --git a/plugins/sensors/meego/meego.pri b/plugins/sensors/meego/meego.pri
index 95f586f238..11b1806e5f 100644
--- a/plugins/sensors/meego/meego.pri
+++ b/plugins/sensors/meego/meego.pri
@@ -8,7 +8,10 @@ HEADERS += meegosensorbase.h \
meegoproximitysensor.h \
meegorotationsensor.h \
meegotapsensor.h \
- meegolightsensor.h
+ meegolightsensor.h \
+ meegoirproximitysensor.h \
+ qirproximitysensor.h \
+ qirproximitysensor_p.h \
SOURCES += meegosensorbase.cpp \
meegoaccelerometer.cpp \
@@ -18,7 +21,9 @@ SOURCES += meegosensorbase.cpp \
meegomagnetometer.cpp \
meegoorientationsensor.cpp \
meegoproximitysensor.cpp \
+ meegoirproximitysensor.cpp \
meegorotationsensor.cpp \
meegotapsensor.cpp \
meegolightsensor.cpp \
+ qirproximitysensor.cpp \
main.cpp
diff --git a/plugins/sensors/meego/meegoaccelerometer.cpp b/plugins/sensors/meego/meegoaccelerometer.cpp
index 4a1d097d6a..3813547dd2 100644
--- a/plugins/sensors/meego/meegoaccelerometer.cpp
+++ b/plugins/sensors/meego/meegoaccelerometer.cpp
@@ -72,17 +72,15 @@ void meegoaccelerometer::slotFrameAvailable(const QVector<XYZ>& frame)
}
bool meegoaccelerometer::doConnect(){
- if (m_bufferSize==1?
- QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&))):
- QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& ))))
- return true;
- return false;
+ if (m_bufferSize==1)
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&)));
+ return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& )));
}
-const QString meegoaccelerometer::sensorName(){
+QString meegoaccelerometer::sensorName() const{
return "accelerometersensor";
}
-const qreal meegoaccelerometer::correctionFactor(){return GRAVITY_EARTH_THOUSANDTH;}
+qreal meegoaccelerometer::correctionFactor() const{return GRAVITY_EARTH_THOUSANDTH;}
diff --git a/plugins/sensors/meego/meegoaccelerometer.h b/plugins/sensors/meego/meegoaccelerometer.h
index d34a45a918..357fbe2d8a 100644
--- a/plugins/sensors/meego/meegoaccelerometer.h
+++ b/plugins/sensors/meego/meegoaccelerometer.h
@@ -59,8 +59,8 @@ public:
meegoaccelerometer(QSensor *sensor);
protected:
virtual bool doConnect();
- virtual const QString sensorName();
- virtual const qreal correctionFactor();
+ virtual QString sensorName() const;
+ virtual qreal correctionFactor() const;
private:
diff --git a/plugins/sensors/meego/meegoals.cpp b/plugins/sensors/meego/meegoals.cpp
index 7e95574114..65d008d749 100644
--- a/plugins/sensors/meego/meegoals.cpp
+++ b/plugins/sensors/meego/meegoals.cpp
@@ -75,15 +75,12 @@ void meegoals::slotDataAvailable(const Unsigned& data)
}
bool meegoals::doConnect(){
- if (!(QObject::connect(m_sensorInterface, SIGNAL(ALSChanged(const Unsigned&)),
- this, SLOT(slotDataAvailable(const Unsigned&))))){
- return false;
- }
- return true;
+ return QObject::connect(m_sensorInterface, SIGNAL(ALSChanged(const Unsigned&)),
+ this, SLOT(slotDataAvailable(const Unsigned&)));
}
-const QString meegoals::sensorName(){
+QString meegoals::sensorName() const{
return "alssensor";
}
diff --git a/plugins/sensors/meego/meegoals.h b/plugins/sensors/meego/meegoals.h
index 0465bd3f36..4bfa093b90 100644
--- a/plugins/sensors/meego/meegoals.h
+++ b/plugins/sensors/meego/meegoals.h
@@ -59,7 +59,7 @@ public:
meegoals(QSensor *sensor);
protected:
virtual bool doConnect();
- virtual const QString sensorName();
+ virtual QString sensorName() const;
virtual void start();
diff --git a/plugins/sensors/meego/meegocompass.cpp b/plugins/sensors/meego/meegocompass.cpp
index bbb14372a3..2b8d6ad796 100644
--- a/plugins/sensors/meego/meegocompass.cpp
+++ b/plugins/sensors/meego/meegocompass.cpp
@@ -67,14 +67,11 @@ void meegocompass::slotDataAvailable(const Compass& data)
bool meegocompass::doConnect(){
- if (!(QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const Compass&)),
- this, SLOT(slotDataAvailable(const Compass&))))){
- return false;
- }
- return true;
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const Compass&)),
+ this, SLOT(slotDataAvailable(const Compass&)));
}
-const QString meegocompass::sensorName(){
+QString meegocompass::sensorName() const{
return "compasssensor";
}
diff --git a/plugins/sensors/meego/meegocompass.h b/plugins/sensors/meego/meegocompass.h
index e2c7cf34fa..f8c192a073 100644
--- a/plugins/sensors/meego/meegocompass.h
+++ b/plugins/sensors/meego/meegocompass.h
@@ -59,7 +59,7 @@ public:
meegocompass(QSensor *sensor);
protected:
virtual bool doConnect();
- virtual const QString sensorName();
+ virtual QString sensorName() const;
private:
QCompassReading m_reading;
diff --git a/plugins/sensors/meego/meegogyroscope.cpp b/plugins/sensors/meego/meegogyroscope.cpp
index c2a22406e0..1514ee0a6e 100644
--- a/plugins/sensors/meego/meegogyroscope.cpp
+++ b/plugins/sensors/meego/meegogyroscope.cpp
@@ -73,15 +73,13 @@ void meegogyroscope::slotFrameAvailable(const QVector<XYZ>& frame)
}
bool meegogyroscope::doConnect(){
- if (m_bufferSize==1?
- QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&))):
- QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& ))))
- return true;
- return false;
+ if (m_bufferSize==1)
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&)));
+ return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& )));
}
-const QString meegogyroscope::sensorName(){
+QString meegogyroscope::sensorName() const{
return "gyroscopesensor";
}
-const qreal meegogyroscope::correctionFactor(){return MILLI;}
+qreal meegogyroscope::correctionFactor() const{return MILLI;}
diff --git a/plugins/sensors/meego/meegogyroscope.h b/plugins/sensors/meego/meegogyroscope.h
index 6048e9bbe2..4887ecfd60 100644
--- a/plugins/sensors/meego/meegogyroscope.h
+++ b/plugins/sensors/meego/meegogyroscope.h
@@ -59,8 +59,8 @@ public:
meegogyroscope(QSensor *sensor);
protected:
virtual bool doConnect();
- virtual const QString sensorName();
- virtual const qreal correctionFactor();
+ virtual QString sensorName() const;
+ virtual qreal correctionFactor() const;
private:
diff --git a/plugins/sensors/meego/meegoirproximitysensor.cpp b/plugins/sensors/meego/meegoirproximitysensor.cpp
new file mode 100644
index 0000000000..379297bfe0
--- /dev/null
+++ b/plugins/sensors/meego/meegoirproximitysensor.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "meegoirproximitysensor.h"
+#define RM680_PS "/dev/bh1770glc_ps"
+
+char const * const meegoirproximitysensor::id("meego.irproximitysensor");
+bool meegoirproximitysensor::m_initDone = false;
+
+
+
+meegoirproximitysensor::meegoirproximitysensor(QSensor *sensor)
+ : meegosensorbase(sensor)
+{
+ initSensor<ProximitySensorChannelInterface>(m_initDone);
+ setReading<QIRProximityReading>(&m_reading);
+ setDescription(QLatin1String("reflectance as percentage (%) of maximum"));
+ addOutputRange(0, 100, 1);
+ addDataRate(10,10);
+ rangeMax = QFile::exists(RM680_PS)?255:1023;
+}
+
+#ifdef Q_WS_MAEMO_6
+void meegoirproximitysensor::slotDataAvailable(const Proximity& proximity){
+ m_reading.setReflectance((float)proximity.reflectance()*100 / rangeMax);
+ m_reading.setTimestamp(proximity.UnsignedData().timestamp_);
+ newReadingAvailable();
+}
+#endif
+
+
+bool meegoirproximitysensor::doConnect(){
+#ifdef Q_WS_MAEMO_6
+ return QObject::connect(m_sensorInterface, SIGNAL(reflectanceDataAvailable(const Proximity&)),
+ this, SLOT(slotDataAvailable(const Proximity&)));
+#endif
+ return false;
+}
+
+
+QString meegoirproximitysensor::sensorName() const{
+ return "proximitysensor";
+}
+
+
diff --git a/plugins/sensors/meego/meegoirproximitysensor.h b/plugins/sensors/meego/meegoirproximitysensor.h
new file mode 100644
index 0000000000..7625e05487
--- /dev/null
+++ b/plugins/sensors/meego/meegoirproximitysensor.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MEEGOIRPROXIMITYSENSOR_H
+#define MEEGOIRPROXIMITYSENSOR_H
+
+#include "meegosensorbase.h"
+#include <qirproximitysensor.h>
+#include <proximitysensor_i.h>
+
+
+QTM_USE_NAMESPACE
+
+class meegoirproximitysensor : public meegosensorbase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+
+ meegoirproximitysensor(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+
+private:
+ QIRProximityReading m_reading;
+ static bool m_initDone;
+ int rangeMax;
+
+private slots:
+#ifdef Q_WS_MAEMO_6
+ void slotDataAvailable(const Proximity& proximity);
+#endif
+};
+
+#endif
diff --git a/plugins/sensors/meego/meegolightsensor.cpp b/plugins/sensors/meego/meegolightsensor.cpp
index aa19eb0e11..7793f136b8 100644
--- a/plugins/sensors/meego/meegolightsensor.cpp
+++ b/plugins/sensors/meego/meegolightsensor.cpp
@@ -59,14 +59,11 @@ void meegolightsensor::slotDataAvailable(const Unsigned& data)
}
bool meegolightsensor::doConnect(){
- if (!(QObject::connect(m_sensorInterface, SIGNAL(ALSChanged(const Unsigned&)),
- this, SLOT(slotDataAvailable(const Unsigned&))))){
- return false;
- }
- return true;
+ return QObject::connect(m_sensorInterface, SIGNAL(ALSChanged(const Unsigned&)),
+ this, SLOT(slotDataAvailable(const Unsigned&)));
}
-const QString meegolightsensor::sensorName(){
+QString meegolightsensor::sensorName() const{
return "alssensor";
}
diff --git a/plugins/sensors/meego/meegolightsensor.h b/plugins/sensors/meego/meegolightsensor.h
index 4d77299869..b66cde2957 100644
--- a/plugins/sensors/meego/meegolightsensor.h
+++ b/plugins/sensors/meego/meegolightsensor.h
@@ -59,7 +59,7 @@ public:
meegolightsensor(QSensor *sensor);
protected:
virtual bool doConnect();
- virtual const QString sensorName();
+ virtual QString sensorName() const;
private:
QLightReading m_reading;
diff --git a/plugins/sensors/meego/meegomagnetometer.cpp b/plugins/sensors/meego/meegomagnetometer.cpp
index 69b92e4218..069fa815f1 100644
--- a/plugins/sensors/meego/meegomagnetometer.cpp
+++ b/plugins/sensors/meego/meegomagnetometer.cpp
@@ -86,15 +86,13 @@ void meegomagnetometer::slotFrameAvailable(const QVector<MagneticField>& frame
}
bool meegomagnetometer::doConnect(){
- if (m_bufferSize==1?
- QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const MagneticField&)), this, SLOT(slotDataAvailable(const MagneticField&))):
- QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<MagneticField>& )),this, SLOT(slotFrameAvailable(const QVector<MagneticField>& ))))
- return true;
- return false;
+ if (m_bufferSize==1)
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const MagneticField&)), this, SLOT(slotDataAvailable(const MagneticField&)));
+ return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<MagneticField>& )),this, SLOT(slotFrameAvailable(const QVector<MagneticField>& )));
}
-const QString meegomagnetometer::sensorName(){
+QString meegomagnetometer::sensorName() const{
return "magnetometersensor";
}
-const qreal meegomagnetometer::correctionFactor(){return meegomagnetometer::NANO;}
+qreal meegomagnetometer::correctionFactor() const{return meegomagnetometer::NANO;}
diff --git a/plugins/sensors/meego/meegomagnetometer.h b/plugins/sensors/meego/meegomagnetometer.h
index b95651a4e7..fd2f461f76 100644
--- a/plugins/sensors/meego/meegomagnetometer.h
+++ b/plugins/sensors/meego/meegomagnetometer.h
@@ -60,8 +60,8 @@ public:
protected:
virtual bool doConnect();
virtual void start();
- virtual const QString sensorName();
- virtual const qreal correctionFactor();
+ virtual QString sensorName() const;
+ virtual qreal correctionFactor() const;
private:
diff --git a/plugins/sensors/meego/meegoorientationsensor.cpp b/plugins/sensors/meego/meegoorientationsensor.cpp
index de777da886..9bc1d603c8 100644
--- a/plugins/sensors/meego/meegoorientationsensor.cpp
+++ b/plugins/sensors/meego/meegoorientationsensor.cpp
@@ -71,14 +71,11 @@ void meegoorientationsensor::slotDataAvailable(const Unsigned& data)
}
bool meegoorientationsensor::doConnect(){
- if (!(QObject::connect(m_sensorInterface, SIGNAL(orientationChanged(const Unsigned&)),
- this, SLOT(slotDataAvailable(const Unsigned&))))){
- return false;
- }
- return true;
+ return QObject::connect(m_sensorInterface, SIGNAL(orientationChanged(const Unsigned&)),
+ this, SLOT(slotDataAvailable(const Unsigned&)));
}
-const QString meegoorientationsensor::sensorName(){
+QString meegoorientationsensor::sensorName() const{
return "orientationsensor";
}
diff --git a/plugins/sensors/meego/meegoorientationsensor.h b/plugins/sensors/meego/meegoorientationsensor.h
index 038c71bec8..dd58fa8a0f 100644
--- a/plugins/sensors/meego/meegoorientationsensor.h
+++ b/plugins/sensors/meego/meegoorientationsensor.h
@@ -59,7 +59,7 @@ public:
meegoorientationsensor(QSensor *sensor);
protected:
virtual bool doConnect();
- virtual const QString sensorName();
+ virtual QString sensorName() const;
virtual void start();
private:
diff --git a/plugins/sensors/meego/meegoproximitysensor.cpp b/plugins/sensors/meego/meegoproximitysensor.cpp
index 8513f59bf9..fb1c3bcb8b 100644
--- a/plugins/sensors/meego/meegoproximitysensor.cpp
+++ b/plugins/sensors/meego/meegoproximitysensor.cpp
@@ -41,11 +41,11 @@
#include "meegoproximitysensor.h"
-char const * const meegoproximitysensor::id("meego.proximity");
+char const * const meegoproximitysensor::id("meego.proximitysensor");
bool meegoproximitysensor::m_initDone = false;
meegoproximitysensor::meegoproximitysensor(QSensor *sensor)
- : meegosensorbase(sensor)
+ : meegosensorbase(sensor), m_exClose(false)
{
initSensor<ProximitySensorChannelInterface>(m_initDone);
setReading<QProximityReading>(&m_reading);
@@ -63,9 +63,12 @@ void meegoproximitysensor::start(){
void meegoproximitysensor::slotDataAvailable(const Unsigned& data)
{
+ bool close = data.x()? true: false;
+ if (close == m_exClose) return;
m_reading.setClose(data.x()? true: false);
m_reading.setTimestamp(data.UnsignedData().timestamp_);
newReadingAvailable();
+ m_exClose = close;
}
bool meegoproximitysensor::doConnect(){
@@ -74,6 +77,6 @@ bool meegoproximitysensor::doConnect(){
}
-const QString meegoproximitysensor::sensorName(){
+QString meegoproximitysensor::sensorName() const{
return "proximitysensor";
}
diff --git a/plugins/sensors/meego/meegoproximitysensor.h b/plugins/sensors/meego/meegoproximitysensor.h
index 6c45ee905e..285b43d785 100644
--- a/plugins/sensors/meego/meegoproximitysensor.h
+++ b/plugins/sensors/meego/meegoproximitysensor.h
@@ -59,13 +59,14 @@ public:
meegoproximitysensor(QSensor *sensor);
protected:
virtual bool doConnect();
- virtual const QString sensorName();
+ virtual QString sensorName() const;
virtual void start();
private:
QProximityReading m_reading;
static bool m_initDone;
+ bool m_exClose;
private slots:
void slotDataAvailable(const Unsigned& data);
diff --git a/plugins/sensors/meego/meegorotationsensor.cpp b/plugins/sensors/meego/meegorotationsensor.cpp
index 5a1943373a..38c285ee62 100644
--- a/plugins/sensors/meego/meegorotationsensor.cpp
+++ b/plugins/sensors/meego/meegorotationsensor.cpp
@@ -69,13 +69,11 @@ void meegorotationsensor::slotFrameAvailable(const QVector<XYZ>& frame)
}
bool meegorotationsensor::doConnect(){
- if (m_bufferSize==1?
- QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&))):
- QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& ))))
- return true;
- return false;
+ if (m_bufferSize==1)
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&)));
+ return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& )));
}
-const QString meegorotationsensor::sensorName(){
+QString meegorotationsensor::sensorName() const{
return "rotationsensor";
}
diff --git a/plugins/sensors/meego/meegorotationsensor.h b/plugins/sensors/meego/meegorotationsensor.h
index 52b01eca14..8c0e407615 100644
--- a/plugins/sensors/meego/meegorotationsensor.h
+++ b/plugins/sensors/meego/meegorotationsensor.h
@@ -59,7 +59,7 @@ public:
meegorotationsensor(QSensor *sensor);
protected:
virtual bool doConnect();
- virtual const QString sensorName();
+ virtual QString sensorName() const;
private:
QRotationReading m_reading;
diff --git a/plugins/sensors/meego/meegosensorbase.cpp b/plugins/sensors/meego/meegosensorbase.cpp
index 71efc4e283..26ffbe6d10 100644
--- a/plugins/sensors/meego/meegosensorbase.cpp
+++ b/plugins/sensors/meego/meegosensorbase.cpp
@@ -44,15 +44,16 @@
SensorManagerInterface* meegosensorbase::m_remoteSensorManager = 0;
-
-const float meegosensorbase::GRAVITY_EARTH = 9.80665;
-const float meegosensorbase::GRAVITY_EARTH_THOUSANDTH = 0.00980665;
+//According to wikipedia link http://en.wikipedia.org/wiki/Standard_gravity
+//const float meegosensorbase::GRAVITY_EARTH = 9.812865328;
+const float meegosensorbase::GRAVITY_EARTH_THOUSANDTH = 0.009812865328;
const int meegosensorbase::KErrNotFound=-1;
const int meegosensorbase::KErrInUse=-14;
const char* const meegosensorbase::ALWAYS_ON = "alwaysOn";
const char* const meegosensorbase::BUFFER_SIZE = "bufferSize";
const char* const meegosensorbase::MAX_BUFFER_SIZE = "maxBufferSize";
const char* const meegosensorbase::EFFICIENT_BUFFER_SIZE = "efficientBufferSize";
+QStringList meegosensorbase::m_bufferingSensors = QStringList()<<"meego.accelerometer"<<"meego.magnetometer"<<"meego.gyroscope"<<"meego.rotationsensor";
meegosensorbase::meegosensorbase(QSensor *sensor)
: QSensorBackend(sensor), m_sensorInterface(0), m_bufferSize(-1), m_prevOutputRange(0), m_efficientBufferSize(1), m_maxBufferSize(1)
@@ -91,7 +92,7 @@ void meegosensorbase::start()
int l = sensor()->outputRanges().size();
if (l>1){
if (currentRange != m_prevOutputRange){
-#ifdef Q_WS_MAEMO6
+#ifdef Q_WS_MAEMO_6
bool isOk = m_sensorInterface->setDataRangeIndex(currentRange); //NOTE THAT THE CHANGE MIGHT NOT SUCCEED, FIRST COME FIRST SERVED
if (!isOk) sensorError(KErrInUse);
else m_prevOutputRange = currentRange;
@@ -149,8 +150,11 @@ bool meegosensorbase::doConnectAfterCheck(){
int size = bufferSize();
if (size == m_bufferSize) return true;
- m_sensorInterface->setBufferSize(size);
+ if (m_bufferingSensors.contains(sensor()->identifier()))
+ m_sensorInterface->setBufferSize(size);
+ else size = 1;
+
// if multiple->single or single->multiple or if uninitialized
if ((m_bufferSize>1 && size==1) || (m_bufferSize==1 && size>1) || m_bufferSize==-1){
m_bufferSize = size;
@@ -166,7 +170,7 @@ bool meegosensorbase::doConnectAfterCheck(){
}
-const int meegosensorbase::bufferSize(){
+int meegosensorbase::bufferSize() const{
QVariant bufferVariant = sensor()->property(BUFFER_SIZE);
int bufferSize = bufferVariant.isValid()?bufferVariant.toInt():1;
if (bufferSize==1) return 1;
@@ -183,5 +187,5 @@ const int meegosensorbase::bufferSize(){
return bufferSize;
}
-const qreal meegosensorbase::correctionFactor(){return 1;}
+qreal meegosensorbase::correctionFactor() const{return 1;}
diff --git a/plugins/sensors/meego/meegosensorbase.h b/plugins/sensors/meego/meegosensorbase.h
index 55b32db0df..449584dc44 100644
--- a/plugins/sensors/meego/meegosensorbase.h
+++ b/plugins/sensors/meego/meegosensorbase.h
@@ -68,9 +68,10 @@ protected:
static const float GRAVITY_EARTH_THOUSANDTH; //for speed
static const int KErrNotFound;
static const int KErrInUse;
+ static QStringList m_bufferingSensors;
void setRanges(qreal correctionFactor=1);
- virtual const QString sensorName()=0;
+ virtual QString sensorName() const=0;
template<typename T>
void initSensor(bool &initDone)
@@ -124,21 +125,28 @@ protected:
}
//bufferSizes
- IntegerRangeList sizes = m_sensorInterface->getAvailableBufferSizes();
- int l = sizes.size();
- for (int i=0; i<l; i++){
- int second = sizes.at(i).second;
- m_maxBufferSize = second>m_bufferSize? second:m_maxBufferSize;
+ if (m_bufferingSensors.contains(sensor()->identifier())){
+
+ IntegerRangeList sizes = m_sensorInterface->getAvailableBufferSizes();
+ int l = sizes.size();
+ for (int i=0; i<l; i++){
+ int second = sizes.at(i).second;
+ m_maxBufferSize = second>m_bufferSize? second:m_maxBufferSize;
+ }
+ m_maxBufferSize = m_maxBufferSize<0?1:m_maxBufferSize;
+ //SensorFW guarantees to provide the most efficient size first
+ //TODO: remove from comments
+ //m_efficientBufferSize = m_sensorInterface->hwBuffering()? (l>0?sizes.at(0).first:1) : 1;
}
- m_maxBufferSize = m_maxBufferSize<0?1:m_maxBufferSize;
- //SensorFW guarantees to provide the most efficient size first
- //TODO: remove from comments
-// m_efficientBufferSize = m_sensorInterface->hwBuffering()? (l>0?sizes.at(0).first:1) : 1;
+ else
+ m_maxBufferSize = 1;
sensor()->setProperty(MAX_BUFFER_SIZE, m_maxBufferSize);
sensor()->setProperty(EFFICIENT_BUFFER_SIZE, m_efficientBufferSize);
- if (sensor()->type()=="QAmbientLightSensor") return; // SensorFW returns lux values, plugin enumerated values
+ QString type = sensor()->type();
+ if (type=="QAmbientLightSensor") return; // SensorFW returns lux values, plugin enumerated values
+ if (type=="QIRProximitySensor") return; // SensorFW returns raw reflectance values, plugin % of max reflectance
if (name=="accelerometersensor") return; // SensorFW returns milliGs, plugin m/s^2
if (name=="magnetometersensor") return; // SensorFW returns nanoTeslas, plugin Teslas
if (name=="gyroscopesensor") return; // SensorFW returns DSPs, plugin milliDSPs
@@ -153,10 +161,11 @@ protected:
AbstractSensorChannelInterface* m_sensorInterface;
int m_bufferSize;
- const int bufferSize();
- virtual const qreal correctionFactor();
+ int bufferSize() const;
+ virtual qreal correctionFactor() const;
private:
+
static SensorManagerInterface* m_remoteSensorManager;
int m_prevOutputRange;
bool doConnectAfterCheck();
diff --git a/plugins/sensors/meego/meegotapsensor.cpp b/plugins/sensors/meego/meegotapsensor.cpp
index 5504c91bee..26c4b5de85 100644
--- a/plugins/sensors/meego/meegotapsensor.cpp
+++ b/plugins/sensors/meego/meegotapsensor.cpp
@@ -102,6 +102,6 @@ bool meegotapsensor::doConnect(){
}
-const QString meegotapsensor::sensorName(){
+QString meegotapsensor::sensorName() const{
return "tapsensor";
}
diff --git a/plugins/sensors/meego/meegotapsensor.h b/plugins/sensors/meego/meegotapsensor.h
index 85b46e9431..dc7be9d958 100644
--- a/plugins/sensors/meego/meegotapsensor.h
+++ b/plugins/sensors/meego/meegotapsensor.h
@@ -60,7 +60,7 @@ public:
protected:
virtual bool doConnect();
virtual void start();
- virtual const QString sensorName();
+ virtual QString sensorName() const;
private:
QTapReading m_reading;
diff --git a/plugins/sensors/meego/qirproximitysensor.cpp b/plugins/sensors/meego/qirproximitysensor.cpp
new file mode 100644
index 0000000000..ff94c3ebfd
--- /dev/null
+++ b/plugins/sensors/meego/qirproximitysensor.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qirproximitysensor.h>
+#include "qirproximitysensor_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QIRProximityReading)
+
+/*!
+ \class QIRProximityReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+
+ \brief The QIRProximityReading class holds readings from the IR proximity sensor.
+
+ The IR (infra-red) proximity sensor detects proximity by beaming out infra-red light
+ and detecting how much of the light returns.
+
+ The biggest limitation of this technology is that there is no reliable way to turn the
+ reflectance values into distances unless both the item being detected and the ambient
+ conditions are known.
+
+ \section2 QIRProximityReading Units
+
+ The sensor reports reflectance as a percentage. That is, 0 indicates nothing was detected
+ within the range of the sensor and 100 indicates the infra-red signal returned at the full
+ power level that it was sent at.
+*/
+
+/*!
+ \property QIRProximityReading::reflectance
+ \brief Holds the reflectance value.
+
+ The reflectance is a percentage (from 0 to 100) indicating how much of the transmitted
+ infra-red light was returned.
+
+ \sa {QIRProximityReading Units}
+*/
+qreal QIRProximityReading::reflectance() const
+{
+ return d->reflectance;
+}
+
+/*!
+ Sets the reflectance value to \a reflectance.
+*/
+void QIRProximityReading::setReflectance(qreal reflectance)
+{
+ d->reflectance = reflectance;
+}
+
+// =====================================================================
+
+/*!
+ \class QIRProximityFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+
+ \brief The QIRProximityFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QIRProximityReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QIRProximityFilter::filter(QIRProximityReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QIRProximitySensor::type("QIRProximitySensor");
+
+/*!
+ \class QIRProximitySensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+
+ \brief The QIRProximitySensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QIRProximityReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QIRProximityReading.
+
+ \sa QIRProximityReading
+*/
+
+/*!
+ \fn QIRProximitySensor::QIRProximitySensor(QObject *parent)
+
+ Construct the sensor as a child of \a parent.
+*/
+
+/*!
+ \fn QIRProximitySensor::~QIRProximitySensor()
+
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+
+/*!
+ \fn QIRProximitySensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+
+#include "moc_qirproximitysensor.cpp"
+QTM_END_NAMESPACE
diff --git a/plugins/sensors/meego/qirproximitysensor.h b/plugins/sensors/meego/qirproximitysensor.h
new file mode 100644
index 0000000000..fd57f89d80
--- /dev/null
+++ b/plugins/sensors/meego/qirproximitysensor.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QIRPROXIMITYSENSOR_H
+#define QIRPROXIMITYSENSOR_H
+
+#include <qsensor.h>
+
+QTM_BEGIN_NAMESPACE
+
+class QIRProximityReadingPrivate;
+
+class Q_SENSORS_EXPORT QIRProximityReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal reflectance READ reflectance)
+ DECLARE_READING(QIRProximityReading)
+public:
+ qreal reflectance() const;
+ void setReflectance(qreal reflectance);
+};
+
+class Q_SENSORS_EXPORT QIRProximityFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QIRProximityReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) { return filter(static_cast<QIRProximityReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QIRProximitySensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QIRProximitySensor(QObject *parent = 0) : QSensor(QIRProximitySensor::type, parent) {}
+ virtual ~QIRProximitySensor() {}
+ QIRProximityReading *reading() const { return static_cast<QIRProximityReading*>(QSensor::reading()); }
+ static char const * const type;
+};
+
+QTM_END_NAMESPACE
+
+#endif
+
diff --git a/plugins/sensors/meego/qirproximitysensor_p.h b/plugins/sensors/meego/qirproximitysensor_p.h
new file mode 100644
index 0000000000..e06e929360
--- /dev/null
+++ b/plugins/sensors/meego/qirproximitysensor_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QIRPROXIMITYSENSOR_P_H
+#define QIRPROXIMITYSENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QTM_BEGIN_NAMESPACE
+
+class QIRProximityReadingPrivate
+{
+public:
+ QIRProximityReadingPrivate()
+ : reflectance(0)
+ {
+ }
+
+
+
+ /*
+ * Note that this class is copied so you may need to implement
+ * a copy constructor if you have complex types or pointers
+ * as values.
+ */
+ qreal reflectance;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/plugins/sensors/n900/n900proximitysensor.cpp b/plugins/sensors/n900/n900proximitysensor.cpp
index 4248c41c79..46e2c0588d 100644
--- a/plugins/sensors/n900/n900proximitysensor.cpp
+++ b/plugins/sensors/n900/n900proximitysensor.cpp
@@ -51,12 +51,9 @@ n900proximitysensor::n900proximitysensor(QSensor *sensor)
: n900filebasedsensor(sensor)
{
setReading<QProximityReading>(&m_reading);
- // Not sure what rate the hardware runs at. Actually, I don't
- // think it's even configurable. I think the proximity state
- // is updated via interrupt. This this is really about the poll
- // speed.
- // Report 1-100 so the app can choose the speed it wants to poll
- addDataRate(1, 100);
+ // The proximity hardware runs at 10Hz.
+ // Report 1-10 so the app can choose the speed it wants to poll
+ addDataRate(1, 10);
}
void n900proximitysensor::start()
diff --git a/plugins/sensors/symbian/rotationsensorsym.cpp b/plugins/sensors/symbian/rotationsensorsym.cpp
index b4b166ba88..23dc122586 100644
--- a/plugins/sensors/symbian/rotationsensorsym.cpp
+++ b/plugins/sensors/symbian/rotationsensorsym.cpp
@@ -81,6 +81,7 @@ CRotationSensorSym::CRotationSensorSym(QSensor *sensor):CSensorBackendSym(sensor
{
setReading<QRotationReading>(&iReading);
iBackendData.iSensorType = KSensrvChannelTypeIdRotationData;
+ sensor->setProperty("hasZ", QVariant(FALSE));
}
/*
@@ -125,24 +126,6 @@ void CRotationSensorSym::ProcessReading()
iReading.setY(iData.iDeviceRotationAboutYAxis - 180);
}
- if(iData.iDeviceRotationAboutZAxis == TSensrvRotationData::KSensrvRotationUndefined)
- {
- sensor()->setProperty("hasZ", QVariant(FALSE));
- }
- else
- {
- sensor()->setProperty("hasZ", QVariant(TRUE));
- // For z axis symbian provides reading from 0 to 359 range
- // This logic maps value to Qt range -180 to 180
- if(iData.iDeviceRotationAboutZAxis >= 0 && iData.iDeviceRotationAboutZAxis <= 180)
- {
- iReading.setZ(180 - iData.iDeviceRotationAboutZAxis);
- }
- else if(iData.iDeviceRotationAboutZAxis > 180 && iData.iDeviceRotationAboutZAxis < 360)
- {
- iReading.setZ(0 - (iData.iDeviceRotationAboutZAxis - 180));
- }
- }
// Set the timestamp
iReading.setTimestamp(iData.iTimeStamp.Int64());
// Release the lock