diff options
author | Bernd Weimer <bweimer@blackberry.com> | 2013-04-02 18:53:03 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-09 09:05:55 +0200 |
commit | aac0603f0e49c99d146e00244b67d986eef52cdf (patch) | |
tree | 0bae20e1d41b672e1818a13640919eabd98045c7 /src/imports | |
parent | 75d32c08365b671116eb66b9c9ef7d1aec883442 (diff) | |
download | qtsensors-aac0603f0e49c99d146e00244b67d986eef52cdf.tar.gz |
Added temperature property to pressure sensor
Many air pressure sensors provide their temperature, as well. This can
be used for temperature compensation for instance.
The pressure sensor API has been extended and a BlackBerry backend has
been implemented.
Change-Id: I188e1276dff74601d757d0a356b28b4fea4594bd
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/sensors/qmlpressuresensor.cpp | 20 | ||||
-rw-r--r-- | src/imports/sensors/qmlpressuresensor.h | 4 | ||||
-rw-r--r-- | src/imports/sensors/sensors.cpp | 43 |
3 files changed, 67 insertions, 0 deletions
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"); } }; |