summaryrefslogtreecommitdiffstats
path: root/src/sensors/qsensor.cpp
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2013-01-09 13:57:16 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-23 18:33:03 +0100
commit1831170d56f32530e64bbd5484a6c2cc9e1817ca (patch)
tree3499dfc2e46b97d72b17a6cfc1087add660e6e8a /src/sensors/qsensor.cpp
parent02285d735e7d3bd8ddfb61b7ea5e16da4ad522d1 (diff)
Add API for duplicate skipping
Duplicate skipping enables omitting reading values that are very similar to the previous one, thus saving processing power. Implement this for the Blackberry backend. Change-Id: Ic608d8ca795b5a2e0bca5a75a62e8005c283c620 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src/sensors/qsensor.cpp')
-rw-r--r--src/sensors/qsensor.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/sensors/qsensor.cpp b/src/sensors/qsensor.cpp
index 4c3715c2..f93ef883 100644
--- a/src/sensors/qsensor.cpp
+++ b/src/sensors/qsensor.cpp
@@ -189,6 +189,9 @@ void QSensorPrivate::init(const QByteArray &sensorType)
QSensor::bufferSize property.
\value AlwaysOn The backend supports changing the policy on whether to suspend when idle,
controlled by the QSensor::alwaysOn property.
+ \value SkipDuplicates The backend supports skipping of same or very similar successive
+ readings. This can be enabled by setting the QSensor::skipDuplicates
+ property to true.
The features of QMagnetometer are:
@@ -434,6 +437,54 @@ bool QSensor::isAlwaysOn() const
}
/*!
+ \property QSensor::skipDuplicates
+ \brief Indicates whether duplicate reading values should be omitted.
+ \since 5.1
+
+ When duplicate skipping is enabled, successive readings with the same or very
+ similar values are omitted. This helps reducing the amount of processing done, as less sensor
+ readings are made available. As a consequence, readings arrive at an irregular interval.
+
+ Duplicate skipping is not just enabled for readings that are exactly the same, but also for
+ readings that are quite similar, as each sensor has a bit of jitter even if the device is
+ not moved.
+
+ Support for this property depends on the backend. Use isFeatureSupported() to check if it is
+ supported on the current platform.
+
+ Duplicate skipping is disabled by default.
+
+ Duplicate skipping takes effect when the sensor is started, changing the property while the
+ sensor is active has no immediate effect.
+*/
+bool QSensor::skipDuplicates() const
+{
+ Q_D(const QSensor);
+ return d->skipDuplicates;
+}
+
+/*!
+ Sets the duplicate skipping to \a skipDuplicates.
+
+ \since 5.1
+*/
+void QSensor::setSkipDuplicates(bool skipDuplicates)
+{
+ Q_D(QSensor);
+ if (d->skipDuplicates != skipDuplicates) {
+ d->skipDuplicates = skipDuplicates;
+ emit skipDuplicatesChanged(skipDuplicates);
+ }
+}
+
+/*!
+ \fn QSensor::skipDuplicatesChanged(bool skipDuplicates)
+ \since 5.1
+
+ This signal is emitted when the skipDuplicates property changes.
+*/
+
+/*!
\property QSensor::availableDataRates
\brief the data rates that the sensor supports.