summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--examples/sensors/grue/plugin/plugin.json2
-rw-r--r--src/imports/sensors/qmlpressuresensor.cpp20
-rw-r--r--src/imports/sensors/qmlpressuresensor.h4
-rw-r--r--src/imports/sensors/sensors.cpp43
-rw-r--r--src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java11
-rw-r--r--src/plugins/sensors/android/src/androidjnisensors.cpp11
-rw-r--r--src/plugins/sensors/android/src/androidjnisensors.h9
-rw-r--r--src/plugins/sensors/android/src/androidpressure.cpp63
-rw-r--r--src/plugins/sensors/android/src/androidpressure.h58
-rw-r--r--src/plugins/sensors/android/src/androidproximity.cpp72
-rw-r--r--src/plugins/sensors/android/src/androidproximity.h59
-rw-r--r--src/plugins/sensors/android/src/androidtemperature.cpp66
-rw-r--r--src/plugins/sensors/android/src/androidtemperature.h58
-rw-r--r--src/plugins/sensors/android/src/main.cpp30
-rw-r--r--src/plugins/sensors/android/src/src.pro6
-rw-r--r--src/plugins/sensors/blackberry/bbpressuresensor.cpp3
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.cpp1
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.h4
-rw-r--r--src/plugins/sensors/blackberry/sensor.h6
-rw-r--r--src/plugins/sensors/ios/iosaccelerometer.h9
-rw-r--r--src/plugins/sensors/ios/iosaccelerometer.mm52
-rw-r--r--src/plugins/sensors/ios/iosgyroscope.h7
-rw-r--r--src/plugins/sensors/ios/iosgyroscope.mm51
-rw-r--r--src/plugins/sensors/ios/iosmagnetometer.h8
-rw-r--r--src/plugins/sensors/ios/iosmagnetometer.mm129
-rw-r--r--src/sensors/doc/qtsensors.qdocconf4
-rw-r--r--src/sensors/doc/src/compatmap.qdoc6
-rw-r--r--src/sensors/doc/src/qtsensors-cpp.qdoc4
-rw-r--r--src/sensors/doc/src/qtsensors5.qdoc2
-rw-r--r--src/sensors/qpressuresensor.cpp27
-rw-r--r--src/sensors/qpressuresensor.h4
-rw-r--r--src/sensors/qpressuresensor_p.h3
-rw-r--r--src/sensors/qsensor.cpp4
-rw-r--r--src/sensors/qsensor.h1
-rw-r--r--sync.profile1
-rw-r--r--tests/auto/qsensor/test_backends.h1
-rw-r--r--tests/auto/qsensor/tst_qsensor.cpp1
-rw-r--r--tests/manual/sensor_explorer/sensor_explorer.pro2
-rw-r--r--tests/manual/sensorclerk/collector.cpp190
-rw-r--r--tests/manual/sensorclerk/collector.h89
-rw-r--r--tests/manual/sensorclerk/main.cpp63
-rw-r--r--tests/manual/sensorclerk/qml/Button.qml129
-rw-r--r--tests/manual/sensorclerk/qml/main.qml76
-rw-r--r--tests/manual/sensorclerk/sensorclerk.pro11
45 files changed, 1224 insertions, 178 deletions
diff --git a/.qmake.conf b/.qmake.conf
index bf1b71f..2f09a2b 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,3 +1,3 @@
load(qt_build_config)
-MODULE_VERSION = 5.1.2
+MODULE_VERSION = 5.2.0
diff --git a/examples/sensors/grue/plugin/plugin.json b/examples/sensors/grue/plugin/plugin.json
index 8a55b3a..ab37205 100644
--- a/examples/sensors/grue/plugin/plugin.json
+++ b/examples/sensors/grue/plugin/plugin.json
@@ -1 +1 @@
-{ "Keys": [ "notused" ] }
+{ "Keys": [ "grue" ] }
diff --git a/src/imports/sensors/qmlpressuresensor.cpp b/src/imports/sensors/qmlpressuresensor.cpp
index a21f7c0..8f32b4e 100644
--- a/src/imports/sensors/qmlpressuresensor.cpp
+++ b/src/imports/sensors/qmlpressuresensor.cpp
@@ -99,6 +99,7 @@ QmlPressureReading::QmlPressureReading(QPressureSensor *sensor)
: QmlSensorReading(sensor)
, m_sensor(sensor)
, m_pressure(0)
+ , m_temperature(0)
{
}
@@ -118,6 +119,19 @@ qreal QmlPressureReading::pressure() const
return m_pressure;
}
+/*!
+ \qmlproperty qreal PressureReading::temperature
+ This property holds the pressure sensor's temperature value in degrees Celsius.
+
+ Please see QPressureReading::temperature for information about this property.
+ \since QtSensors 5.2
+*/
+
+qreal QmlPressureReading::temperature() const
+{
+ return m_temperature;
+}
+
QSensorReading *QmlPressureReading::reading() const
{
return m_sensor->reading();
@@ -130,4 +144,10 @@ void QmlPressureReading::readingUpdate()
m_pressure = pressure;
Q_EMIT pressureChanged();
}
+
+ qreal temperature = m_sensor->reading()->temperature();
+ if (m_temperature != temperature) {
+ m_temperature = temperature;
+ Q_EMIT temperatureChanged();
+ }
}
diff --git a/src/imports/sensors/qmlpressuresensor.h b/src/imports/sensors/qmlpressuresensor.h
index 627915a..c8c19fd 100644
--- a/src/imports/sensors/qmlpressuresensor.h
+++ b/src/imports/sensors/qmlpressuresensor.h
@@ -65,14 +65,17 @@ class QmlPressureReading : public QmlSensorReading
{
Q_OBJECT
Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged)
+ Q_PROPERTY(qreal temperature READ temperature NOTIFY temperatureChanged REVISION 1)
public:
explicit QmlPressureReading(QPressureSensor *sensor);
~QmlPressureReading();
qreal pressure() const;
+ qreal temperature() const;
Q_SIGNALS:
void pressureChanged();
+ Q_REVISION(1) void temperatureChanged();
private:
QSensorReading *reading() const Q_DECL_OVERRIDE;
@@ -80,6 +83,7 @@ private:
QPressureSensor *m_sensor;
qreal m_pressure;
+ qreal m_temperature;
};
QT_END_NAMESPACE
diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp
index 77ad754..abcb381 100644
--- a/src/imports/sensors/sensors.cpp
+++ b/src/imports/sensors/sensors.cpp
@@ -174,6 +174,49 @@ public:
qmlRegisterUncreatableType<QmlTiltSensorReading >(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading"));
qmlRegisterType <QmlSensorGesture >(package, major, minor, "SensorGesture");
+
+ // Register the 5.2 interfaces
+ major = 5;
+ minor = 2;
+ qmlRegisterSingletonType <QmlSensorGlobal >(package, major, minor, "QmlSensors", global_object_50);
+ qmlRegisterUncreatableType<QmlSensorRange >(package, major, minor, "Range", QLatin1String("Cannot create Range"));
+ qmlRegisterUncreatableType<QmlSensorOutputRange >(package, major, minor, "OutputRange", QLatin1String("Cannot create OutputRange"));
+ qmlRegisterUncreatableType<QmlSensor,1 >(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor"));
+ qmlRegisterUncreatableType<QmlSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading"));
+ qmlRegisterType <QmlAccelerometer,1 >(package, major, minor, "Accelerometer");
+ qmlRegisterUncreatableType<QmlAccelerometerReading >(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading"));
+ qmlRegisterType <QmlAltimeter >(package, major, minor, "Altimeter");
+ qmlRegisterUncreatableType<QmlAltimeterReading >(package, major, minor, "AltimeterReading", QLatin1String("Cannot create AltimeterReading"));
+ qmlRegisterType <QmlAmbientLightSensor >(package, major, minor, "AmbientLightSensor");
+ qmlRegisterUncreatableType<QmlAmbientLightSensorReading>(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading"));
+ qmlRegisterType <QmlAmbientTemperatureSensor >(package, major, minor, "AmbientTemperatureSensor");
+ qmlRegisterUncreatableType<QmlAmbientTemperatureReading>(package, major, minor, "AmbientTemperatureReading", QLatin1String("Cannot create AmbientTemperatureReading"));
+ qmlRegisterType <QmlCompass >(package, major, minor, "Compass");
+ qmlRegisterUncreatableType<QmlCompassReading >(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading"));
+ qmlRegisterType <QmlGyroscope >(package, major, minor, "Gyroscope");
+ qmlRegisterUncreatableType<QmlGyroscopeReading >(package, major, minor, "GyroscopeReading", QLatin1String("Cannot create GyroscopeReading"));
+ qmlRegisterType <QmlHolsterSensor >(package, major, minor, "HolsterSensor");
+ qmlRegisterUncreatableType<QmlHolsterReading >(package, major, minor, "HolsterReading", QLatin1String("Cannot create HolsterReading"));
+ qmlRegisterType <QmlIRProximitySensor >(package, major, minor, "IRProximitySensor");
+ qmlRegisterUncreatableType<QmlIRProximitySensorReading >(package, major, minor, "IRProximityReading", QLatin1String("Cannot create IRProximityReading"));
+ qmlRegisterType <QmlLightSensor >(package, major, minor, "LightSensor");
+ qmlRegisterUncreatableType<QmlLightSensorReading >(package, major, minor, "LightReading", QLatin1String("Cannot create LightReading"));
+ qmlRegisterType <QmlMagnetometer >(package, major, minor, "Magnetometer");
+ qmlRegisterUncreatableType<QmlMagnetometerReading >(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading"));
+ qmlRegisterType <QmlOrientationSensor >(package, major, minor, "OrientationSensor");
+ qmlRegisterUncreatableType<QmlOrientationSensorReading >(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading"));
+ qmlRegisterType <QmlPressureSensor >(package, major, minor, "PressureSensor");
+ qmlRegisterUncreatableType<QmlPressureReading,1 >(package, major, minor, "PressureReading", QLatin1String("Cannot create PressureReading"));
+ qmlRegisterType <QmlProximitySensor >(package, major, minor, "ProximitySensor");
+ qmlRegisterUncreatableType<QmlProximitySensorReading >(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading"));
+ qmlRegisterType <QmlRotationSensor >(package, major, minor, "RotationSensor");
+ qmlRegisterUncreatableType<QmlRotationSensorReading >(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading"));
+ qmlRegisterType <QmlTapSensor >(package, major, minor, "TapSensor");
+ qmlRegisterUncreatableType<QmlTapSensorReading >(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading"));
+ qmlRegisterType <QmlTiltSensor >(package, major, minor, "TiltSensor");
+ qmlRegisterUncreatableType<QmlTiltSensorReading >(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading"));
+
+ qmlRegisterType <QmlSensorGesture >(package, major, minor, "SensorGesture");
}
};
diff --git a/src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java b/src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java
index c7956d2..5507b07 100644
--- a/src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java
+++ b/src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java
@@ -98,6 +98,17 @@ public class QtSensors implements SensorEventListener
return null;
}
+ private static float getSensorMaximumRange(int sensorType)
+ {
+ try {
+ Sensor s = m_sensorManager.getDefaultSensor(sensorType);
+ return s.getMaximumRange();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return 0;
+ }
+
private static boolean registerSensor(int sensorType, int rate)
{
synchronized (m_syncObject) {
diff --git a/src/plugins/sensors/android/src/androidjnisensors.cpp b/src/plugins/sensors/android/src/androidjnisensors.cpp
index 6365433..af39e0b 100644
--- a/src/plugins/sensors/android/src/androidjnisensors.cpp
+++ b/src/plugins/sensors/android/src/androidjnisensors.cpp
@@ -53,6 +53,7 @@ static jmethodID getSensorListMethodId;
static jmethodID registerSensorMethodId;
static jmethodID unregisterSensorMethodId;
static jmethodID getSensorDescriptionMethodId;
+static jmethodID getSensorMaximumRangeMethodId;
static QHash<int, QList<AndroidSensors::AndroidSensorsListenerInterface *> > listenersHash;
QReadWriteLock listenersLocker;
@@ -119,6 +120,15 @@ namespace AndroidSensors
return ret;
}
+ qreal sensorMaximumRange(AndroidSensorType sensor)
+ {
+ AttachedJNIEnv aenv;
+ if (!aenv.jniEnv)
+ return 0;
+ jfloat range = aenv.jniEnv->CallStaticFloatMethod(sensorsClass, getSensorMaximumRangeMethodId, jint(sensor));
+ return range;
+ }
+
bool registerListener(AndroidSensorType sensor, AndroidSensorsListenerInterface *listener, int dataRate)
{
listenersLocker.lockForWrite();
@@ -214,6 +224,7 @@ static bool registerNatives(JNIEnv *env)
GET_AND_CHECK_STATIC_METHOD(registerSensorMethodId, sensorsClass, "registerSensor", "(II)Z");
GET_AND_CHECK_STATIC_METHOD(unregisterSensorMethodId, sensorsClass, "unregisterSensor", "(I)Z");
GET_AND_CHECK_STATIC_METHOD(getSensorDescriptionMethodId, sensorsClass, "getSensorDescription", "(I)Ljava/lang/String;");
+ GET_AND_CHECK_STATIC_METHOD(getSensorMaximumRangeMethodId, sensorsClass, "getSensorMaximumRange", "(I)F");
return true;
}
diff --git a/src/plugins/sensors/android/src/androidjnisensors.h b/src/plugins/sensors/android/src/androidjnisensors.h
index 53ca58d..30aab6c 100644
--- a/src/plugins/sensors/android/src/androidjnisensors.h
+++ b/src/plugins/sensors/android/src/androidjnisensors.h
@@ -53,17 +53,21 @@ namespace AndroidSensors
enum AndroidSensorType
{
TYPE_ACCELEROMETER = 1,
- TYPE_AMBIENT_TEMPERATURE = 13,
+ TYPE_AMBIENT_TEMPERATURE = 13, //Added in API level 14
+ TYPE_GAME_ROTATION_VECTOR = 15, //Added in API level 18
TYPE_GRAVITY = 9,
TYPE_GYROSCOPE = 4,
+ TYPE_GYROSCOPE_UNCALIBRATED = 16, //Added in API level 18
TYPE_LIGHT = 5,
TYPE_LINEAR_ACCELERATION = 10,
TYPE_MAGNETIC_FIELD = 2,
+ TYPE_MAGNETIC_FIELD_UNCALIBRATED = 14, //Added in API level 18
TYPE_ORIENTATION = 3, //This constant was deprecated in API level 8. use SensorManager.getOrientation() instead.
TYPE_PRESSURE = 6,
TYPE_PROXIMITY = 8,
- TYPE_RELATIVE_HUMIDITY = 12,
+ TYPE_RELATIVE_HUMIDITY = 12, //Added in API level 14
TYPE_ROTATION_VECTOR = 11,
+ TYPE_SIGNIFICANT_MOTION = 17, //Added in API level 18
TYPE_TEMPERATURE = 7 //This constant was deprecated in API level 14. use Sensor.TYPE_AMBIENT_TEMPERATURE instead.
};
@@ -76,6 +80,7 @@ namespace AndroidSensors
QVector<AndroidSensorType> availableSensors();
QString sensorDescription(AndroidSensorType sensor);
+ qreal sensorMaximumRange(AndroidSensorType sensor);
bool registerListener(AndroidSensorType sensor, AndroidSensorsListenerInterface *listener, int dataRate = 0);
bool unregisterListener(AndroidSensorType sensor, AndroidSensorsListenerInterface *listener);
}
diff --git a/src/plugins/sensors/android/src/androidpressure.cpp b/src/plugins/sensors/android/src/androidpressure.cpp
new file mode 100644
index 0000000..1cabecb
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidpressure.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidpressure.h"
+
+AndroidPressure::AndroidPressure(AndroidSensors::AndroidSensorType type, QSensor *sensor)
+ : AndroidCommonSensor<QPressureReading>(type, sensor)
+{}
+
+
+void AndroidPressure::onAccuracyChanged(jint accuracy)
+{
+ Q_UNUSED(accuracy)
+}
+
+void AndroidPressure::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
+{
+ if (size < 1)
+ return;
+ m_reader.setTimestamp(timestamp/1000);
+ // check https://developer.android.com/reference/android/hardware/SensorEvent.html#values
+ m_reader.setPressure(values[0]*100); //Android uses hPa, we use Pa
+ newReadingAvailable();
+}
diff --git a/src/plugins/sensors/android/src/androidpressure.h b/src/plugins/sensors/android/src/androidpressure.h
new file mode 100644
index 0000000..44f1d53
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidpressure.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDPRESSURE_H
+#define ANDROIDPRESSURE_H
+#include <qpressuresensor.h>
+
+#include "androidcommonsensor.h"
+
+class AndroidPressure : public AndroidCommonSensor<QPressureReading>
+{
+public:
+ AndroidPressure(AndroidSensors::AndroidSensorType type, QSensor *sensor);
+private:
+ virtual void onAccuracyChanged(jint accuracy);
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size);
+};
+
+#endif // ANDROIDPRESSURE_H
diff --git a/src/plugins/sensors/android/src/androidproximity.cpp b/src/plugins/sensors/android/src/androidproximity.cpp
new file mode 100644
index 0000000..9d10f77
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidproximity.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidproximity.h"
+#include "androidjnisensors.h"
+
+AndroidProximity::AndroidProximity(AndroidSensors::AndroidSensorType type, QSensor *sensor)
+ : AndroidCommonSensor<QProximityReading>(type, sensor)
+{
+ m_maximumRange = AndroidSensors::sensorMaximumRange(type);
+
+ // if we can't get the range, we arbitrarily define anything closer than 10 cm as "close"
+ if (m_maximumRange <= 0)
+ m_maximumRange = 10.0;
+}
+
+
+void AndroidProximity::onAccuracyChanged(jint accuracy)
+{
+ Q_UNUSED(accuracy)
+}
+
+void AndroidProximity::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
+{
+ if (size < 1)
+ return;
+ m_reader.setTimestamp(timestamp/1000);
+
+ qreal reading = values[0];
+ bool close = (reading < m_maximumRange);
+ m_reader.setClose(close);
+ newReadingAvailable();
+}
diff --git a/src/plugins/sensors/android/src/androidproximity.h b/src/plugins/sensors/android/src/androidproximity.h
new file mode 100644
index 0000000..1911798
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidproximity.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDPROXIMITY_H
+#define ANDROIDPROXIMITY_H
+#include <qproximitysensor.h>
+
+#include "androidcommonsensor.h"
+
+class AndroidProximity : public AndroidCommonSensor<QProximityReading>
+{
+public:
+ AndroidProximity(AndroidSensors::AndroidSensorType type, QSensor *sensor);
+private:
+ virtual void onAccuracyChanged(jint accuracy);
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size);
+ qreal m_maximumRange;
+};
+
+#endif // ANDROIDPROXIMITY_H
diff --git a/src/plugins/sensors/android/src/androidtemperature.cpp b/src/plugins/sensors/android/src/androidtemperature.cpp
new file mode 100644
index 0000000..b3f41da
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidtemperature.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidtemperature.h"
+
+AndroidTemperature::AndroidTemperature(AndroidSensors::AndroidSensorType type, QSensor *sensor)
+ : AndroidCommonSensor<QAmbientTemperatureReading>(type, sensor)
+{}
+
+
+void AndroidTemperature::onAccuracyChanged(jint accuracy)
+{
+ Q_UNUSED(accuracy)
+}
+
+void AndroidTemperature::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
+{
+ if (size < 1)
+ return;
+ m_reader.setTimestamp(timestamp/1000);
+
+ // TODO: I was unable to test this since the devices I was testing this with did not have
+ // a temperature sensor. Verify that this works and check that the units are correct.
+
+ m_reader.setTemperature(values[0]);
+ newReadingAvailable();
+}
diff --git a/src/plugins/sensors/android/src/androidtemperature.h b/src/plugins/sensors/android/src/androidtemperature.h
new file mode 100644
index 0000000..667169c
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidtemperature.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDTEMPERATURE_H
+#define ANDROIDTEMPERATURE_H
+#include <qambienttemperaturesensor.h>
+
+#include "androidcommonsensor.h"
+
+class AndroidTemperature : public AndroidCommonSensor<QAmbientTemperatureReading>
+{
+public:
+ AndroidTemperature(AndroidSensors::AndroidSensorType type, QSensor *sensor);
+private:
+ virtual void onAccuracyChanged(jint accuracy);
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size);
+};
+
+#endif // ANDROIDTEMPERATURE_H
diff --git a/src/plugins/sensors/android/src/main.cpp b/src/plugins/sensors/android/src/main.cpp
index 0cb4de4..17d499e 100644
--- a/src/plugins/sensors/android/src/main.cpp
+++ b/src/plugins/sensors/android/src/main.cpp
@@ -47,7 +47,10 @@
#include "androidgyroscope.h"
#include "androidlight.h"
#include "androidmagnetometer.h"
+#include "androidpressure.h"
+#include "androidproximity.h"
#include "androidrotation.h"
+#include "androidtemperature.h"
using namespace AndroidSensors;
@@ -66,7 +69,8 @@ public:
break;
case TYPE_AMBIENT_TEMPERATURE:
case TYPE_TEMPERATURE:
- break; // add the temperature sensor backend
+ QSensorManager::registerBackend(QAmbientTemperatureSensor::type, QByteArray::number(sensor), this);
+ break;
case TYPE_GRAVITY:
break; // add the gravity sensor backend
case TYPE_GYROSCOPE:
@@ -83,14 +87,22 @@ public:
case TYPE_ORIENTATION:
break; // add the orientation sensor backend
case TYPE_PRESSURE:
- break; // add the pressure sensor backend
+ QSensorManager::registerBackend(QPressureSensor::type, QByteArray::number(sensor), this);
+ break;
case TYPE_PROXIMITY:
- break; // add the proximity sensor backend
+ QSensorManager::registerBackend(QProximitySensor::type, QByteArray::number(sensor), this);
+ break;
case TYPE_RELATIVE_HUMIDITY:
break; // add the relative humidity sensor backend
case TYPE_ROTATION_VECTOR:
QSensorManager::registerBackend(QRotationSensor::type, QByteArray::number(sensor), this);
break;
+
+ case TYPE_GAME_ROTATION_VECTOR:
+ case TYPE_GYROSCOPE_UNCALIBRATED:
+ case TYPE_MAGNETIC_FIELD_UNCALIBRATED:
+ case TYPE_SIGNIFICANT_MOTION:
+ break; // add backends for API level 18 sensors
}
}
}
@@ -103,7 +115,7 @@ public:
return new AndroidAccelerometer(type, sensor);
case TYPE_AMBIENT_TEMPERATURE:
case TYPE_TEMPERATURE:
- break; // add the temperature sensor backend
+ return new AndroidTemperature(type, sensor);
case TYPE_GRAVITY:
break; // add the gravity sensor backend
case TYPE_GYROSCOPE:
@@ -117,13 +129,19 @@ public:
case TYPE_ORIENTATION:
break; // add the orientation sensor backend
case TYPE_PRESSURE:
- break; // add the pressure sensor backend
+ return new AndroidPressure(type, sensor);
case TYPE_PROXIMITY:
- break; // add the proximity sensor backend
+ return new AndroidProximity(type, sensor);
case TYPE_RELATIVE_HUMIDITY:
break; // add the relative humidity sensor backend
case TYPE_ROTATION_VECTOR:
return new AndroidRotation(type, sensor);
+
+ case TYPE_GAME_ROTATION_VECTOR:
+ case TYPE_GYROSCOPE_UNCALIBRATED:
+ case TYPE_MAGNETIC_FIELD_UNCALIBRATED:
+ case TYPE_SIGNIFICANT_MOTION:
+ break; // add backends for API level 18 sensors
}
return 0;
}
diff --git a/src/plugins/sensors/android/src/src.pro b/src/plugins/sensors/android/src/src.pro
index 715a011..a184aae 100644
--- a/src/plugins/sensors/android/src/src.pro
+++ b/src/plugins/sensors/android/src/src.pro
@@ -14,7 +14,10 @@ HEADERS = \
androidcommonsensor.h \
androidgyroscope.h \
androidmagnetometer.h \
+ androidpressure.h \
+ androidproximity.h \
androidrotation.h \
+ androidtemperature.h \
androidlight.h
SOURCES = \
@@ -23,7 +26,10 @@ SOURCES = \
androidaccelerometer.cpp \
androidgyroscope.cpp \
androidmagnetometer.cpp \
+ androidpressure.cpp \
+ androidproximity.cpp \
androidrotation.cpp \
+ androidtemperature.cpp \
androidlight.cpp
OTHER_FILES = plugin.json
diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.cpp b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
index 8cb9b1e..edbb392 100644
--- a/src/plugins/sensors/blackberry/bbpressuresensor.cpp
+++ b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
@@ -53,8 +53,7 @@ QString BbPressureSensor::devicePath()
bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading)
{
- // TODO: I was unable to test this since the device I was testing this with did not have
- // a pressure sensor. Verify that this works and check that the units are correct.
reading->setPressure(event.pressure_s.pressure);
+ reading->setTemperature(event.pressure_s.temperature);
return true;
}
diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.cpp b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
index 6b614a8..7822dd8 100644
--- a/src/plugins/sensors/blackberry/bbsensorbackend.cpp
+++ b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
@@ -303,6 +303,7 @@ bool BbSensorBackendBase::isFeatureSupported(QSensor::Feature feature) const
case QSensor::Buffering:
case QSensor::AccelerationMode:
case QSensor::SkipDuplicates:
+ case QSensor::PressureSensorTemperature:
return true;
case QSensor::GeoValues:
#ifndef Q_OS_BLACKBERRY_TABLET
diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.h b/src/plugins/sensors/blackberry/bbsensorbackend.h
index 4e7b810..953d7bc 100644
--- a/src/plugins/sensors/blackberry/bbsensorbackend.h
+++ b/src/plugins/sensors/blackberry/bbsensorbackend.h
@@ -45,8 +45,8 @@
#include <QtCore/QFile>
#include <QtCore/QSocketNotifier>
-// Earlier NDK versions did not ship sensor.h, that is why we have our own copy in
-// here.
+// Earlier NDK versions did not ship sensor.h and the Playbook NDK still
+// doesn't include it, that is why we have our own copy in here.
// We prefer the NDK version if that exists, as that is more up-to-date.
#ifdef HAVE_NDK_SENSOR_H
#include <sensor/sensor.h>
diff --git a/src/plugins/sensors/blackberry/sensor.h b/src/plugins/sensors/blackberry/sensor.h
index fb5b935..7317f07 100644
--- a/src/plugins/sensors/blackberry/sensor.h
+++ b/src/plugins/sensors/blackberry/sensor.h
@@ -40,8 +40,12 @@
****************************************************************************/
//
-// This file is a temporary copy until it becomes available in the Blackberry NDK.
+// This file is a copy of the "sensor.h" header for the BlackBerry Playbook OS.
+// It is only inclulded here, because it is not available in the the Playbook NDK.
//
+#if !defined(Q_OS_BLACKBERRY_TABLET)
+#error "This file is supposed to be used only for BlackBerry Playbook OS."
+#endif
#ifndef SENSOR_H_
#define SENSOR_H_
diff --git a/src/plugins/sensors/ios/iosaccelerometer.h b/src/plugins/sensors/ios/iosaccelerometer.h
index 5fcac19..1a6560b 100644
--- a/src/plugins/sensors/ios/iosaccelerometer.h
+++ b/src/plugins/sensors/ios/iosaccelerometer.h
@@ -42,29 +42,28 @@
#ifndef IOSACCELEROMETER_H
#define IOSACCELEROMETER_H
-#include <Foundation/Foundation.h>
+#include <CoreMotion/CMMotionManager.h>
#include <qsensorbackend.h>
#include <qaccelerometer.h>
QT_BEGIN_NAMESPACE
-@class QtIoAccelListener;
-
class IOSAccelerometer : public QSensorBackend
{
public:
static char const * const id;
explicit IOSAccelerometer(QSensor *sensor);
- ~IOSAccelerometer();
+ void timerEvent(QTimerEvent *);
void start();
void stop();
private:
- NSOperationQueue *m_updateQueue;
+ CMMotionManager *m_motionManager;
QAccelerometerReading m_reading;
+ int m_timer;
};
QT_END_NAMESPACE
diff --git a/src/plugins/sensors/ios/iosaccelerometer.mm b/src/plugins/sensors/ios/iosaccelerometer.mm
index b657b50..5f9c0f1 100644
--- a/src/plugins/sensors/ios/iosaccelerometer.mm
+++ b/src/plugins/sensors/ios/iosaccelerometer.mm
@@ -40,8 +40,6 @@
****************************************************************************/
#include <UIKit/UIAccelerometer.h>
-#include <CoreMotion/CMMotionManager.h>
-#include <QPointer>
#include "iosaccelerometer.h"
#include "iosmotionmanager.h"
@@ -52,49 +50,39 @@ QT_BEGIN_NAMESPACE
IOSAccelerometer::IOSAccelerometer(QSensor *sensor)
: QSensorBackend(sensor)
- , m_updateQueue([[NSOperationQueue alloc] init])
+ , m_motionManager([QIOSMotionManager sharedManager])
+ , m_timer(0)
{
setReading<QAccelerometerReading>(&m_reading);
addDataRate(1, 100); // 100Hz
addOutputRange(-22.418, 22.418, 0.17651); // 2G
}
-IOSAccelerometer::~IOSAccelerometer()
-{
- [m_updateQueue release];
-}
-
void IOSAccelerometer::start()
{
- CMMotionManager *motionManager = [QIOSMotionManager sharedManager];
- // Convert from Hz to NSTimeInterval:
int hz = sensor()->dataRate();
- motionManager.accelerometerUpdateInterval = (hz == 0) ? 0 : 1. / hz;
-
- QPointer<QObject> self = this;
- [motionManager startAccelerometerUpdatesToQueue:m_updateQueue withHandler:^(CMAccelerometerData *data, NSError *error) {
- // NSOperationQueue is multi-threaded, so we process the data by queuing a callback to
- // the main application queue. By the time the callback executes, IOSAccelerometer might
- // have been deleted, so we need an extra QPointer check for that:
- dispatch_async(dispatch_get_main_queue(), ^{
- if (self) {
- Q_UNUSED(error);
- // Convert from NSTimeInterval to microseconds and G to m/s2, and flip axes:
- CMAcceleration acc = data.acceleration;
- const qreal G = 9.8066;
- m_reading.setTimestamp(quint64(data.timestamp * 1000000));
- m_reading.setX(qreal(acc.x) * G * -1);
- m_reading.setY(qreal(acc.y) * G * -1);
- m_reading.setZ(qreal(acc.z) * G * -1);
- newReadingAvailable();
- }
- });
- }];
+ m_timer = startTimer(1000 / (hz == 0 ? 60 : hz));
+ [m_motionManager startAccelerometerUpdates];
}
void IOSAccelerometer::stop()
{
- [[QIOSMotionManager sharedManager] stopAccelerometerUpdates];
+ [m_motionManager stopAccelerometerUpdates];
+ killTimer(m_timer);
+ m_timer = 0;
+}
+
+void IOSAccelerometer::timerEvent(QTimerEvent *)
+{
+ // Convert from NSTimeInterval to microseconds and G to m/s2, and flip axes:
+ CMAccelerometerData *data = m_motionManager.accelerometerData;
+ CMAcceleration acc = data.acceleration;
+ static const qreal G = 9.8066;
+ m_reading.setTimestamp(quint64(data.timestamp * 1e6));
+ m_reading.setX(qreal(acc.x) * G * -1);
+ m_reading.setY(qreal(acc.y) * G * -1);
+ m_reading.setZ(qreal(acc.z) * G * -1);
+ newReadingAvailable();
}
QT_END_NAMESPACE
diff --git a/src/plugins/sensors/ios/iosgyroscope.h b/src/plugins/sensors/ios/iosgyroscope.h
index ed46241..4f4c399 100644
--- a/src/plugins/sensors/ios/iosgyroscope.h
+++ b/src/plugins/sensors/ios/iosgyroscope.h
@@ -42,7 +42,7 @@
#ifndef IOSGYROSCOPE_H
#define IOSGYROSCOPE_H
-#include <Foundation/Foundation.h>
+#include <CoreMotion/CMMotionManager.h>
#include <qsensorbackend.h>
#include <qgyroscope.h>
@@ -55,14 +55,15 @@ public:
static char const * const id;
explicit IOSGyroscope(QSensor *sensor);
- ~IOSGyroscope();
+ void timerEvent(QTimerEvent *);
void start();
void stop();
private:
- NSOperationQueue *m_updateQueue;
+ CMMotionManager *m_motionManager;
QGyroscopeReading m_reading;
+ int m_timer;
};
QT_END_NAMESPACE
diff --git a/src/plugins/sensors/ios/iosgyroscope.mm b/src/plugins/sensors/ios/iosgyroscope.mm
index 700755d..8dfa3a4 100644
--- a/src/plugins/sensors/ios/iosgyroscope.mm
+++ b/src/plugins/sensors/ios/iosgyroscope.mm
@@ -39,9 +39,6 @@
**
****************************************************************************/
-#include <CoreMotion/CMMotionManager.h>
-#include <QPointer>
-
#include "iosmotionmanager.h"
#include "iosgyroscope.h"
@@ -51,48 +48,38 @@ QT_BEGIN_NAMESPACE
IOSGyroscope::IOSGyroscope(QSensor *sensor)
: QSensorBackend(sensor)
- , m_updateQueue([[NSOperationQueue alloc] init])
+ , m_motionManager([QIOSMotionManager sharedManager])
+ , m_timer(0)
{
setReading<QGyroscopeReading>(&m_reading);
addDataRate(1, 100); // 100Hz is max it seems
addOutputRange(-360, 360, 0.01);
}
-IOSGyroscope::~IOSGyroscope()
-{
- [m_updateQueue release];
-}
-
void IOSGyroscope::start()
{
- CMMotionManager *motionManager = [QIOSMotionManager sharedManager];
- // Convert Hz to NSTimeInterval:
int hz = sensor()->dataRate();
- motionManager.gyroUpdateInterval = (hz == 0) ? 0 : 1. / hz;
-
- QPointer<QObject> self = this;
- [motionManager startGyroUpdatesToQueue:m_updateQueue withHandler:^(CMGyroData *data, NSError *error) {
- // NSOperationQueue is multi-threaded, so we process the data by queuing a callback to
- // the main application queue. By the time the callback executes, IOSAccelerometer might
- // have been deleted, so we need an extra QPointer check for that:
- dispatch_async(dispatch_get_main_queue(), ^{
- if (self) {
- Q_UNUSED(error);
- // Convert NSTimeInterval to microseconds and radians to degrees:
- CMRotationRate rate = data.rotationRate;
- m_reading.setTimestamp(quint64(data.timestamp * 1000000));
- m_reading.setX((qreal(rate.x) / M_PI) * 180);
- m_reading.setY((qreal(rate.y) / M_PI) * 180);
- m_reading.setZ((qreal(rate.z) / M_PI) * 180);
- newReadingAvailable();
- }
- });
- }];
+ m_timer = startTimer(1000 / (hz == 0 ? 60 : hz));
+ [m_motionManager startGyroUpdates];
}
void IOSGyroscope::stop()
{
- [[QIOSMotionManager sharedManager] stopGyroUpdates];
+ [m_motionManager stopGyroUpdates];
+ killTimer(m_timer);
+ m_timer = 0;
+}
+
+void IOSGyroscope::timerEvent(QTimerEvent *)
+{
+ // Convert NSTimeInterval to microseconds and radians to degrees:
+ CMGyroData *data = m_motionManager.gyroData;
+ CMRotationRate rate = data.rotationRate;
+ m_reading.setTimestamp(quint64(data.timestamp * 1e6));
+ m_reading.setX((qreal(rate.x) / M_PI) * 180);
+ m_reading.setY((qreal(rate.y) / M_PI) * 180);
+ m_reading.setZ((qreal(rate.z) / M_PI) * 180);
+ newReadingAvailable();
}
QT_END_NAMESPACE
diff --git a/src/plugins/sensors/ios/iosmagnetometer.h b/src/plugins/sensors/ios/iosmagnetometer.h
index 72ceab6..b0dc848 100644
--- a/src/plugins/sensors/ios/iosmagnetometer.h
+++ b/src/plugins/sensors/ios/iosmagnetometer.h
@@ -42,7 +42,7 @@
#ifndef IOSMAGNETOMETER_H
#define IOSMAGNETOMETER_H
-#include <Foundation/Foundation.h>
+#include <CoreMotion/CMMotionManager.h>
#include <qsensorbackend.h>
#include <qmagnetometer.h>
@@ -55,7 +55,7 @@ public:
static char const * const id;
explicit IOSMagnetometer(QSensor *sensor);
- ~IOSMagnetometer();
+ void timerEvent(QTimerEvent *);
void start();
void stop();
@@ -64,8 +64,10 @@ public:
void startDeviceMotion();
private:
- NSOperationQueue *m_updateQueue;
+ CMMotionManager *m_motionManager;
QMagnetometerReading m_reading;
+ int m_timer;
+ bool m_returnGeoValues;
};
QT_END_NAMESPACE
diff --git a/src/plugins/sensors/ios/iosmagnetometer.mm b/src/plugins/sensors/ios/iosmagnetometer.mm
index f46d7d5..95f85ae 100644
--- a/src/plugins/sensors/ios/iosmagnetometer.mm
+++ b/src/plugins/sensors/ios/iosmagnetometer.mm
@@ -39,9 +39,6 @@
**
****************************************************************************/
-#include <CoreMotion/CMMotionManager.h>
-#include <QPointer>
-
#include "iosmotionmanager.h"
#include "iosmagnetometer.h"
@@ -51,7 +48,9 @@ char const * const IOSMagnetometer::id("ios.magnetometer");
IOSMagnetometer::IOSMagnetometer(QSensor *sensor)
: QSensorBackend(sensor)
- , m_updateQueue([[NSOperationQueue alloc] init])
+ , m_motionManager([QIOSMotionManager sharedManager])
+ , m_timer(0)
+ , m_returnGeoValues(false)
{
setReading<QMagnetometerReading>(&m_reading);
// Technical information about data rate is not found, but
@@ -62,94 +61,64 @@ IOSMagnetometer::IOSMagnetometer(QSensor *sensor)
addOutputRange(-0.0002, 0.0002, 1e-08);
}
-IOSMagnetometer::~IOSMagnetometer()
-{
- [m_updateQueue release];
-}
-
void IOSMagnetometer::start()
{
- if (static_cast<QMagnetometer *>(sensor())->returnGeoValues())
- startDeviceMotion();
+ int hz = sensor()->dataRate();
+ m_timer = startTimer(1000 / (hz == 0 ? 60 : hz));
+ m_returnGeoValues = static_cast<QMagnetometer *>(sensor())->returnGeoValues();
+
+ if (m_returnGeoValues)
+ [m_motionManager startDeviceMotionUpdates];
else
- startMagnetometer();
+ [m_motionManager startMagnetometerUpdates];
}
-void IOSMagnetometer::startMagnetometer()
+void IOSMagnetometer::stop()
{
- CMMotionManager *motionManager = [QIOSMotionManager sharedManager];
- // Convert Hz to NSTimeInterval:
- int hz = sensor()->dataRate();
- motionManager.magnetometerUpdateInterval = (hz == 0) ? 0 : 1. / hz;
-
- QPointer<QObject> self = this;
- [motionManager startMagnetometerUpdatesToQueue:m_updateQueue withHandler:^(CMMagnetometerData *data, NSError *error) {
- // NSOperationQueue is multi-threaded, so we process the data by queuing a callback to
- // the main application queue. By the time the callback executes, IOSMagnetometer might
- // have been deleted, so we need an extra QPointer check for that:
- dispatch_async(dispatch_get_main_queue(), ^{
- if (self) {
- Q_UNUSED(error);
- CMMagneticField field = data.magneticField;
- // Convert NSTimeInterval to microseconds and microtesla to tesla:
- m_reading.setTimestamp(quint64(data.timestamp * 1e6));
- m_reading.setX(qreal(field.x) / 1e6);
- m_reading.setY(qreal(field.y) / 1e6);
- m_reading.setZ(qreal(field.z) / 1e6);
- m_reading.setCalibrationLevel(1.0);
- newReadingAvailable();
- }
- });
- }];
+ if (m_returnGeoValues)
+ [m_motionManager stopDeviceMotionUpdates];
+ else
+ [m_motionManager stopMagnetometerUpdates];
+ killTimer(m_timer);
+ m_timer = 0;
}
-void IOSMagnetometer::startDeviceMotion()
+void IOSMagnetometer::timerEvent(QTimerEvent *)
{
- CMMotionManager *motionManager = [QIOSMotionManager sharedManager];
- // Convert Hz to NSTimeInterval:
- int hz = sensor()->dataRate();
- motionManager.deviceMotionUpdateInterval = (hz == 0) ? 0 : 1. / hz;
- QPointer<QObject> self = this;
+ CMMagneticField field;
- [motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryCorrectedZVertical
- toQueue:m_updateQueue withHandler:^(CMDeviceMotion *data, NSError *error) {
- dispatch_async(dispatch_get_main_queue(), ^{
- if (self) {
- Q_UNUSED(error);
- CMCalibratedMagneticField calibratedField = data.magneticField;
- CMMagneticField field = calibratedField.field;
- field = motionManager.deviceMotion.magneticField.field;
- // Convert NSTimeInterval to microseconds and microtesla to tesla:
- m_reading.setTimestamp(quint64(data.timestamp * 1e6));
- m_reading.setX(qreal(field.x) / 1e6);
- m_reading.setY(qreal(field.y) / 1e6);
- m_reading.setZ(qreal(field.z) / 1e6);
+ if (m_returnGeoValues) {
+ CMDeviceMotion *deviceMotion = m_motionManager.deviceMotion;
+ CMCalibratedMagneticField calibratedField = deviceMotion.magneticField;
+ field = calibratedField.field;
+ m_reading.setTimestamp(quint64(deviceMotion.timestamp * 1e6));
- switch (calibratedField.accuracy) {
- case CMMagneticFieldCalibrationAccuracyUncalibrated:
- m_reading.setCalibrationLevel(0.0);
- break;
- case CMMagneticFieldCalibrationAccuracyLow:
- m_reading.setCalibrationLevel(0.3);
- break;
- case CMMagneticFieldCalibrationAccuracyMedium:
- m_reading.setCalibrationLevel(0.6);
- break;
- case CMMagneticFieldCalibrationAccuracyHigh:
- m_reading.setCalibrationLevel(1.0);
- break;
- }
+ switch (calibratedField.accuracy) {
+ case CMMagneticFieldCalibrationAccuracyUncalibrated:
+ m_reading.setCalibrationLevel(0.0);
+ break;
+ case CMMagneticFieldCalibrationAccuracyLow:
+ m_reading.setCalibrationLevel(0.3);
+ break;
+ case CMMagneticFieldCalibrationAccuracyMedium:
+ m_reading.setCalibrationLevel(0.6);
+ break;
+ case CMMagneticFieldCalibrationAccuracyHigh:
+ m_reading.setCalibrationLevel(1.0);
+ break;
+ }
+ } else {
+ CMMagnetometerData *data = m_motionManager.magnetometerData;
+ field = data.magneticField;
+ m_reading.setTimestamp(quint64(data.timestamp * 1e6));
+ m_reading.setCalibrationLevel(1.0);
+ }
- newReadingAvailable();
- }
- });
- }];
-}
-
-void IOSMagnetometer::stop()
-{
- [[QIOSMotionManager sharedManager] stopMagnetometerUpdates];
- [[QIOSMotionManager sharedManager] stopDeviceMotionUpdates];
+ // Convert NSTimeInterval to microseconds and microtesla to tesla:
+ m_reading.setX(qreal(field.x) / 1e6);
+ m_reading.setY(qreal(field.y) / 1e6);
+ m_reading.setZ(qreal(field.z) / 1e6);
+ newReadingAvailable();
}
QT_END_NAMESPACE
diff --git a/src/sensors/doc/qtsensors.qdocconf b/src/sensors/doc/qtsensors.qdocconf
index b84d3fa..af17ad3 100644
--- a/src/sensors/doc/qtsensors.qdocconf
+++ b/src/sensors/doc/qtsensors.qdocconf
@@ -52,3 +52,7 @@ examplesinstallpath = sensors
imagedirs += images
depends += qtcore qtdoc qtgui
+
+navigation.landingpage = "Qt Sensors"
+navigation.cppclassespage = "Qt Sensors C++ Classes"
+navigation.qmltypespage = "Qt Sensors QML Types"
diff --git a/src/sensors/doc/src/compatmap.qdoc b/src/sensors/doc/src/compatmap.qdoc
index 5e541de..e3a3530 100644
--- a/src/sensors/doc/src/compatmap.qdoc
+++ b/src/sensors/doc/src/compatmap.qdoc
@@ -90,7 +90,7 @@
<tr>
<td nowrap="nowrap">Ambient Temperature Sensor</td>
<td bgcolor="gray"></td>
- <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
@@ -162,7 +162,7 @@
<tr>
<td nowrap="nowrap">Pressure Sensor</td>
<td bgcolor="green"></td>
- <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
@@ -171,7 +171,7 @@
<tr>
<td nowrap="nowrap">Proximity Sensor</td>
<td bgcolor="green"></td>
- <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
diff --git a/src/sensors/doc/src/qtsensors-cpp.qdoc b/src/sensors/doc/src/qtsensors-cpp.qdoc
index 2f60592..5157dda 100644
--- a/src/sensors/doc/src/qtsensors-cpp.qdoc
+++ b/src/sensors/doc/src/qtsensors-cpp.qdoc
@@ -56,7 +56,9 @@ Where rotation around an axis is used, the rotation shall be expressed as a Righ
\image sensors-coordinates3.jpg
-In general, sensor data is oriented to the top of the device. If values are to be displayed on
+In general, sensor data is oriented relative to \l QPlatformScreen::nativeOrientation, i.e
+to the top of the device when the device is held in its natural orientation (normally
+when the device logo appears the right side up). If values are to be displayed on
the screen the values may need to be transformed so that they match the user interface orientation. A sensor
may define its data as being oriented to the UI. This will be noted in the documentation for the
sensor.
diff --git a/src/sensors/doc/src/qtsensors5.qdoc b/src/sensors/doc/src/qtsensors5.qdoc
index 90af5f6..0be75e8 100644
--- a/src/sensors/doc/src/qtsensors5.qdoc
+++ b/src/sensors/doc/src/qtsensors5.qdoc
@@ -30,6 +30,7 @@
\module QtSensors
\title Qt Sensors C++ Classes
\ingroup modules
+ \qtvariable sensors
\brief The QtSensors module provides classes for reading sensor data.
@@ -75,4 +76,3 @@
\annotatedlist qml-sensors_reading
*/
-
diff --git a/src/sensors/qpressuresensor.cpp b/src/sensors/qpressuresensor.cpp
index ceb77df..1aea843 100644
--- a/src/sensors/qpressuresensor.cpp
+++ b/src/sensors/qpressuresensor.cpp
@@ -79,6 +79,33 @@ void QPressureReading::setPressure(qreal pressure)
d->pressure = pressure;
}
+/*!
+ \property QPressureReading::temperature
+ \brief The pressure sensor's temperature.
+ \since 5.2
+
+ The temperature is returned in degree Celsius.
+ This property, if supported, provides the pressure sensor die temperature.
+ Note that this temperature may be (and usually is) different than the temperature
+ reported from QAmbientTemperatureSensor.
+ Use QSensor::isFeatureSupported() with the QSensor::PressureSensorTemperature
+ flag to determine its availability.
+*/
+
+qreal QPressureReading::temperature() const
+{
+ return d->temperature;
+}
+
+/*!
+ Sets the pressure sensor's temperature to \a temperature.
+ \since 5.2
+*/
+void QPressureReading::setTemperature(qreal temperature)
+{
+ d->temperature = temperature;
+}
+
// =====================================================================
/*!
diff --git a/src/sensors/qpressuresensor.h b/src/sensors/qpressuresensor.h
index 2a544cb..8a14d41 100644
--- a/src/sensors/qpressuresensor.h
+++ b/src/sensors/qpressuresensor.h
@@ -51,10 +51,14 @@ class Q_SENSORS_EXPORT QPressureReading : public QSensorReading
{
Q_OBJECT
Q_PROPERTY(qreal pressure READ pressure)
+ Q_PROPERTY(qreal temperature READ temperature)
DECLARE_READING(QPressureReading)
public:
qreal pressure() const;
void setPressure(qreal pressure);
+
+ qreal temperature() const;
+ void setTemperature(qreal temperature);
};
class Q_SENSORS_EXPORT QPressureFilter : public QSensorFilter
diff --git a/src/sensors/qpressuresensor_p.h b/src/sensors/qpressuresensor_p.h
index 1c74e7f..f91b3ba 100644
--- a/src/sensors/qpressuresensor_p.h
+++ b/src/sensors/qpressuresensor_p.h
@@ -58,11 +58,12 @@ class QPressureReadingPrivate
{
public:
QPressureReadingPrivate()
- : pressure(0)
+ : pressure(0), temperature(0)
{
}
qreal pressure;
+ qreal temperature;
};
QT_END_NAMESPACE
diff --git a/src/sensors/qsensor.cpp b/src/sensors/qsensor.cpp
index 473c459..7f05189 100644
--- a/src/sensors/qsensor.cpp
+++ b/src/sensors/qsensor.cpp
@@ -245,6 +245,10 @@ void QSensorPrivate::init(const QByteArray &sensorType)
\value AccelerationMode The backend supports switching the acceleration mode
of the acceleromter with the QAccelerometer::accelerationMode property.
+ The features of QPressureSensor are:
+
+ \value PressureSensorTemperature The backend provides the pressure sensor's die temperature
+
The features of all orientable sensors are:
\value AxesOrientation The backend supports changing the axes orientation from the default of
diff --git a/src/sensors/qsensor.h b/src/sensors/qsensor.h
index 2b60248..b83d736 100644
--- a/src/sensors/qsensor.h
+++ b/src/sensors/qsensor.h
@@ -107,6 +107,7 @@ public:
AccelerationMode,
SkipDuplicates,
AxesOrientation,
+ PressureSensorTemperature,
Reserved = 257 // Make sure at least 2 bytes are used for the enum to avoid breaking BC later
};
diff --git a/sync.profile b/sync.profile
index 666e42e..ce08463 100644
--- a/sync.profile
+++ b/sync.profile
@@ -7,5 +7,4 @@
"qtbase" => "",
"qtxmlpatterns" => "",
"qtdeclarative" => "",
- "qtjsbackend" => "",
);
diff --git a/tests/auto/qsensor/test_backends.h b/tests/auto/qsensor/test_backends.h
index b76d412..674abf8 100644
--- a/tests/auto/qsensor/test_backends.h
+++ b/tests/auto/qsensor/test_backends.h
@@ -135,6 +135,7 @@ PREPARE_SENSORINTERFACE(QOrientationSensor, QOrientationReading, QOrientationFil
})
PREPARE_SENSORINTERFACE(QPressureSensor, QPressureReading, QPressureFilter, {
reading->setPressure(1.0);
+ reading->setTemperature(1.0);
})
PREPARE_SENSORINTERFACE(QProximitySensor, QProximityReading, QProximityFilter, {
reading->setClose(true);
diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp
index a410f71..ce5f8e3 100644
--- a/tests/auto/qsensor/tst_qsensor.cpp
+++ b/tests/auto/qsensor/tst_qsensor.cpp
@@ -891,6 +891,7 @@ private slots:
TEST_SENSORINTERFACE(QPressureSensor, QPressureReading, {
QCOMPARE(reading->pressure(), 1.0);
+ QCOMPARE(reading->temperature(), 1.0);
})
TEST_SENSORINTERFACE(QProximitySensor, QProximityReading, {
diff --git a/tests/manual/sensor_explorer/sensor_explorer.pro b/tests/manual/sensor_explorer/sensor_explorer.pro
index c8de3f2..f14709c 100644
--- a/tests/manual/sensor_explorer/sensor_explorer.pro
+++ b/tests/manual/sensor_explorer/sensor_explorer.pro
@@ -1,7 +1,7 @@
TEMPLATE=app
TARGET=sensor_explorer
-QT = core gui sensors
+QT = widgets sensors
FORMS=\
explorer.ui
diff --git a/tests/manual/sensorclerk/collector.cpp b/tests/manual/sensorclerk/collector.cpp
new file mode 100644
index 0000000..afe195f
--- /dev/null
+++ b/tests/manual/sensorclerk/collector.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Lorn Potter.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqml.h>
+#include <QtCore/QFile>
+#include <QFileInfo>
+
+#include <QTextStream>
+#include <QtSensors>
+#include <QDir>
+#include <QtSensors/QAccelerometer>
+#include <QtSensors/QIRProximitySensor>
+#include <QtSensors/QOrientationSensor>
+#include <QtSensors/QProximitySensor>
+#include <QDebug>
+
+#include "collector.h"
+
+Collector::Collector(QObject *parent)
+ : QObject(parent),
+ accel(0),
+ orientation(0),
+ proximity(0),
+ irProx(0),
+ tapSensor(0),
+ dataFile(QDir::tempPath()+"/sensordump_0.dat")
+ , isActive(0),
+ fileCounter(0)
+{
+ accel = new QAccelerometer(this);
+ accel->connectToBackend();
+ accel->setDataRate(100);
+ connect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+
+ orientation = new QOrientationSensor(this);
+ orientation->connectToBackend();
+ orientation->setDataRate(100);
+ connect(orientation,SIGNAL(readingChanged()),this,SLOT(orientationChanged()));
+
+ proximity = new QProximitySensor(this);
+ proximity->connectToBackend();
+ connect(proximity,SIGNAL(readingChanged()),this,SLOT(proximityChanged()));
+
+ irProx = new QIRProximitySensor(this);
+ irProx->connectToBackend();
+ irProx->setDataRate(50);
+ connect(irProx,SIGNAL(readingChanged()),this,SLOT(irProximityChanged()));
+
+ tapSensor = new QTapSensor(this);
+ tapSensor->connectToBackend();
+ connect(tapSensor,SIGNAL(readingChanged()),this,SLOT(tapChanged()));
+}
+
+Collector::~Collector()
+{
+}
+
+void Collector::accelChanged()
+{
+ const qreal x = accel->reading()->x();
+ const qreal y = accel->reading()->y();
+ const qreal z = accel->reading()->z();
+ const quint64 ts = accel->reading()->timestamp();
+
+ QTextStream out(&dataFile);
+ out << QString("accelerometer: %1,%2,%3,%4").arg(ts).arg(x).arg(y).arg(z) << "\n";
+}
+
+void Collector::orientationChanged()
+{
+ const QOrientationReading *orientationReading = orientation->reading();
+ QOrientationReading::Orientation o = orientationReading->orientation();
+ const quint64 ts = orientationReading->timestamp();
+
+ QTextStream out(&dataFile);
+ out << QString("orientation: %1,%2").arg(ts).arg(o) << "\n";
+}
+
+void Collector::proximityChanged()
+{
+ const QProximityReading *proximityReading = proximity->reading();
+ const quint64 ts = proximityReading->timestamp();
+ const bool prox = proximityReading->close();
+
+ QTextStream out(&dataFile);
+ out << QString("proximity: %1,%2").arg(ts).arg(prox) << "\n";
+}
+
+void Collector::irProximityChanged()
+{
+ const QIRProximityReading *irProximityReading = irProx->reading();
+ const quint64 ts = irProximityReading->timestamp();
+ const qreal ref = irProximityReading->reflectance();
+
+ QTextStream out(&dataFile);
+ out << QString("irProximity: %1,%2").arg(ts).arg(ref) << "\n";
+}
+
+void Collector::tapChanged()
+{
+ const QTapReading *tapReading = tapSensor->reading();
+ const quint64 ts = tapReading->timestamp();
+ const bool dTap = tapReading->isDoubleTap();
+
+ QTextStream out(&dataFile);
+ out << QString("tap: %1,%2").arg(ts).arg(dTap) << "\n";
+}
+
+void Collector::startCollecting()
+{
+ if (dataFile.exists()) {
+ fileCounter++;
+ for (int i = 0; i < fileCounter; i++) {
+ if (!QFileInfo(QString(QDir::tempPath()+"/sensordump_%1.dat").arg(fileCounter)).exists())
+ dataFile.setFileName(QString(QDir::tempPath()+"/sensordump_%1.dat").arg(fileCounter));
+ break;
+ fileCounter++;
+ }
+ }
+ if (!dataFile.exists()) {
+ if (dataFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ accel->start();
+ orientation->start();
+ proximity->start();
+ irProx->start();
+ tapSensor->start();
+
+ isActive = true;
+ } else {
+ qDebug() << "dump file not opened";
+ }
+ } else {
+ startCollecting();
+ }
+}
+
+void Collector::stopCollecting()
+{
+ if (isActive) {
+ accel->stop();
+ orientation->stop();
+ proximity->stop();
+ irProx->stop();
+ tapSensor->stop();
+ isActive = !isActive;
+ }
+ if (dataFile.isOpen())
+ dataFile.close();
+}
+
+
+QML_DECLARE_TYPE(Collector)
+
diff --git a/tests/manual/sensorclerk/collector.h b/tests/manual/sensorclerk/collector.h
new file mode 100644
index 0000000..15854bf
--- /dev/null
+++ b/tests/manual/sensorclerk/collector.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Lorn Potter.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COLLECTOR_H
+#define COLLECTOR_H
+
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QFile>
+
+class QAccelerometer;
+class QOrientationSensor;
+class QProximitySensor;
+class QIRProximitySensor;
+class QTapSensor;
+
+class Collector : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit Collector(QObject *parent = 0);
+ ~Collector();
+
+public slots:
+ void startCollecting();
+ void stopCollecting();
+
+private Q_SLOTS:
+ void accelChanged();
+ void orientationChanged();
+ void proximityChanged();
+ void irProximityChanged();
+ void tapChanged();
+
+private:
+
+ QAccelerometer *accel;
+ QOrientationSensor *orientation;
+ QProximitySensor *proximity;
+ QIRProximitySensor *irProx;
+ QTapSensor *tapSensor;
+ QFile dataFile;
+
+ bool isActive;
+ int fileCounter;
+
+ Q_DISABLE_COPY(Collector)
+};
+
+#endif // COLLECTOR_H
+
diff --git a/tests/manual/sensorclerk/main.cpp b/tests/manual/sensorclerk/main.cpp
new file mode 100644
index 0000000..d56c1f7
--- /dev/null
+++ b/tests/manual/sensorclerk/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Lorn Potter.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+
+#include "collector.h"
+
+int main( int argc, char** argv )
+{
+ QGuiApplication app( argc, argv );
+ qmlRegisterType<Collector>("Collector", 1, 0, "Collector");
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+#if defined(Q_OS_QNX)
+ view.setSource( QUrl( "app/native/qml/main.qml" ) );
+#else
+ view.setSource( QUrl( "qml/main.qml" ) );
+#endif
+ view.show();
+ return app.exec();
+}
+
diff --git a/tests/manual/sensorclerk/qml/Button.qml b/tests/manual/sensorclerk/qml/Button.qml
new file mode 100644
index 0000000..3565a5b
--- /dev/null
+++ b/tests/manual/sensorclerk/qml/Button.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+
+//Implementation of the Button control.
+Item {
+ id: button
+ width: 250
+ height: 150
+ property alias text: innerText.text;
+ property color color: "white"
+ property color hoverColor: "#aaaaaa"
+ property color pressColor: "slategray"
+ property int fontSize: 10
+ property int borderWidth: 1
+ property int borderRadius: 2
+ scale: state === "Pressed" ? 0.96 : 1.0
+ onEnabledChanged: state = ""
+ signal clicked
+
+ //define a scale animation
+ Behavior on scale {
+ NumberAnimation {
+ duration: 100
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ //Rectangle to draw the button
+ Rectangle {
+ id: rectangleButton
+ anchors.fill: parent
+ radius: borderRadius
+ color: button.enabled ? button.color : "grey"
+ border.width: borderWidth
+ border.color: "black"
+
+ Text {
+ id: innerText
+ font.pointSize: fontSize
+ anchors.centerIn: parent
+ }
+ }
+
+ //change the color of the button in differen button states
+ states: [
+ State {
+ name: "Hovering"
+ PropertyChanges {
+ target: rectangleButton
+ color: hoverColor
+ }
+ },
+ State {
+ name: "Pressed"
+ PropertyChanges {
+ target: rectangleButton
+ color: pressColor
+ }
+ }
+ ]
+
+ //define transmission for the states
+ transitions: [
+ Transition {
+ from: ""; to: "Hovering"
+ ColorAnimation { duration: 200 }
+ },
+ Transition {
+ from: "*"; to: "Pressed"
+ ColorAnimation { duration: 10 }
+ }
+ ]
+
+ //Mouse area to react on click events
+ MouseArea {
+ hoverEnabled: true
+ anchors.fill: button
+ onEntered: { button.state='Hovering'}
+ onExited: { button.state=''}
+ onClicked: { button.clicked();}
+ onPressed: { button.state="Pressed" }
+ onReleased: {
+ if (containsMouse)
+ button.state="Hovering";
+ else
+ button.state="";
+ }
+ }
+}
diff --git a/tests/manual/sensorclerk/qml/main.qml b/tests/manual/sensorclerk/qml/main.qml
new file mode 100644
index 0000000..a49f21a
--- /dev/null
+++ b/tests/manual/sensorclerk/qml/main.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Lorn Potter.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Collector 1.0
+import QtSensors 5.0
+
+Rectangle {
+ Collector {
+ id: writer
+ }
+
+ Text {
+ id: label
+ text: "Sensor Clerk<br> push to start and stop<br> sensor dump";
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Button {
+ id: startCollectingButton
+ text: depressed ? "Stop" : "Start"
+ property bool depressed: false
+ anchors.top: label.bottom
+ enabled: true;
+ anchors.horizontalCenter: parent
+ onClicked: {
+ if (!depressed) {
+ writer.startCollecting()
+ depressed = true
+ } else {
+ writer.stopCollecting()
+ depressed = false
+ }
+ }
+ }
+
+}
+
+
diff --git a/tests/manual/sensorclerk/sensorclerk.pro b/tests/manual/sensorclerk/sensorclerk.pro
new file mode 100644
index 0000000..61eeef1
--- /dev/null
+++ b/tests/manual/sensorclerk/sensorclerk.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+
+QT += quick sensors
+
+SOURCES += main.cpp \
+ collector.cpp
+
+HEADERS += collector.h
+
+OTHER_FILES += qml/main.qml \
+ qml/Button.qml