diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2021-06-13 11:45:35 +0300 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@insta.fi> | 2021-06-21 10:02:07 +0300 |
commit | c255fe62f86598f48bd7e69e449aa95aa016f4fb (patch) | |
tree | e16d2acd0921daee507a68316f155a08f52a6eab /src/sensorsquick/qmlcompass.cpp | |
parent | 7cad8ab7ece1647afc67870d4cb65c9726192753 (diff) | |
download | qtsensors-c255fe62f86598f48bd7e69e449aa95aa016f4fb.tar.gz |
Add binding support for sensor readings
Many of the sensors' QML "reading" value properties change with high
frequency. This makes them candidates to benefit from the more
performant bindable support.
This commit adds the bindable support for QML sensor 'reading' classes:
pressure, gyroscope, tap, compass, proximity, orientation, distance,
magnetometer, lid reading, tilt, rotation, humidity, holster, ambient
temperature, light sensor, altimeter, IR proximity, accelerometer,
ambient light, and sensor reading baseclass (timestamp common to all)
In addition to the 'reading' classes, the commit adds bindable support
for QmlSensor::reading, as it's change signal is emitted with high
frequency, on every sensor reading change.
Pick-to: 6.2
Task-number: QTBUG-92513
Task-number: QTBUG-92503
Task-number: QTBUG-92505
Change-Id: I413ddd8a758142b9b93596e55b3bc8c3c2c98252
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/sensorsquick/qmlcompass.cpp')
-rw-r--r-- | src/sensorsquick/qmlcompass.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/sensorsquick/qmlcompass.cpp b/src/sensorsquick/qmlcompass.cpp index b3620d6..c1c110d 100644 --- a/src/sensorsquick/qmlcompass.cpp +++ b/src/sensorsquick/qmlcompass.cpp @@ -116,6 +116,11 @@ qreal QmlCompassReading::azimuth() const return m_azimuth; } +QBindable<qreal> QmlCompassReading::bindableAzimuth() const +{ + return &m_azimuth; +} + /*! \qmlproperty qreal CompassReading::calibrationLevel This property holds the calibration level of the reading. @@ -128,6 +133,11 @@ qreal QmlCompassReading::calibrationLevel() const return m_calibrationLevel; } +QBindable<qreal> QmlCompassReading::bindableCalibrationLevel() const +{ + return &m_calibrationLevel; +} + QSensorReading *QmlCompassReading::reading() const { return m_sensor->reading(); @@ -135,14 +145,6 @@ QSensorReading *QmlCompassReading::reading() const void QmlCompassReading::readingUpdate() { - qreal azm = m_sensor->reading()->azimuth(); - if (m_azimuth != azm) { - m_azimuth = azm; - Q_EMIT azimuthChanged(); - } - qreal calLevel = m_sensor->reading()->calibrationLevel(); - if (m_calibrationLevel != calLevel) { - m_calibrationLevel = calLevel; - Q_EMIT calibrationLevelChanged(); - } + m_azimuth = m_sensor->reading()->azimuth(); + m_calibrationLevel = m_sensor->reading()->calibrationLevel(); } |