summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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/blackberry/bbpressuresensor.cpp3
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.cpp1
-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/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
19 files changed, 216 insertions, 160 deletions
diff --git a/src/imports/sensors/qmlpressuresensor.cpp b/src/imports/sensors/qmlpressuresensor.cpp
index a21f7c0d..8f32b4e0 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 627915a6..c8c19fd2 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 77ad754a..abcb3812 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/blackberry/bbpressuresensor.cpp b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
index 8cb9b1ea..edbb3927 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 6b614a8a..7822dd86 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/ios/iosaccelerometer.h b/src/plugins/sensors/ios/iosaccelerometer.h
index 5fcac19f..1a6560b1 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 b657b507..5f9c0f16 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 ed46241c..4f4c399a 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 700755de..8dfa3a4a 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 72ceab6d..b0dc848a 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 f46d7d5b..95f85ae1 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 b84d3fa3..af17ad34 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/qtsensors-cpp.qdoc b/src/sensors/doc/src/qtsensors-cpp.qdoc
index 2f60592a..5157ddad 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 90af5f61..0be75e8b 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 ceb77dff..1aea843a 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 2a544cb0..8a14d410 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 1c74e7f1..f91b3bad 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 473c459a..7f05189f 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 2b602488..b83d736b 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
};