251 \property QSensor::dataRate |
248 \property QSensor::dataRate |
252 \brief the data rate that the sensor should be run at. |
249 \brief the data rate that the sensor should be run at. |
253 |
250 |
254 Measured in Hertz. |
251 Measured in Hertz. |
255 |
252 |
256 The default value is determined by the backend. |
253 The data rate is the maximum frequency at which the sensor can detect changes. |
|
254 |
|
255 Setting this property is not portable and can cause conflicts with other |
|
256 applications. Check with the sensor backend and platform documentation for |
|
257 any policy regarding multiple applications requesting a data rate. |
|
258 |
|
259 The default value (0) means that the app does not care what the data rate is. |
|
260 Applications should consider using a timer-based poll of the current value or |
|
261 ensure that the code that processes values can run very quickly as the platform |
|
262 may provide updates hundreds of times each second. |
257 |
263 |
258 This should be set before calling start() because the sensor may not |
264 This should be set before calling start() because the sensor may not |
259 notice changes to this value while it is running. |
265 notice changes to this value while it is running. |
260 |
266 |
|
267 Note that there is no mechanism to determine the current data rate in use by the |
|
268 platform. |
|
269 |
261 \sa QSensor::availableDataRates |
270 \sa QSensor::availableDataRates |
262 */ |
271 */ |
263 |
272 |
264 int QSensor::dataRate() const |
273 int QSensor::dataRate() const |
265 { |
274 { |
266 return d->dataRate; |
275 return d->dataRate; |
267 } |
276 } |
268 |
277 |
269 void QSensor::setDataRate(int rate) |
278 void QSensor::setDataRate(int rate) |
270 { |
279 { |
|
280 if (rate == 0) { |
|
281 d->dataRate = rate; |
|
282 return; |
|
283 } |
271 bool warn = true; |
284 bool warn = true; |
272 Q_FOREACH (const qrange &range, d->availableDataRates) { |
285 Q_FOREACH (const qrange &range, d->availableDataRates) { |
273 if (rate >= range.first && rate <= range.second) { |
286 if (rate >= range.first && rate <= range.second) { |
274 warn = false; |
287 warn = false; |
275 d->dataRate = rate; |
288 d->dataRate = rate; |
396 |
407 |
397 /*! |
408 /*! |
398 \property QSensor::outputRange |
409 \property QSensor::outputRange |
399 \brief the output range in use by the sensor. |
410 \brief the output range in use by the sensor. |
400 |
411 |
401 A sensor may have more than one output range. Typically this is done |
412 This value represents the index in the QSensor::outputRanges list to use. |
402 to give a greater measurement range at the cost of lowering accuracy. |
413 |
|
414 Setting this property is not portable and can cause conflicts with other |
|
415 applications. Check with the sensor backend and platform documentation for |
|
416 any policy regarding multiple applications requesting an output range. |
|
417 |
|
418 The default value (-1) means that the app does not care what the output range is. |
|
419 |
|
420 Note that there is no mechanism to determine the current output range in use by the |
|
421 platform. |
403 |
422 |
404 \sa QSensor::outputRanges |
423 \sa QSensor::outputRanges |
405 */ |
424 */ |
406 |
425 |
407 int QSensor::outputRange() const |
426 int QSensor::outputRange() const |
409 return d->outputRange; |
428 return d->outputRange; |
410 } |
429 } |
411 |
430 |
412 void QSensor::setOutputRange(int index) |
431 void QSensor::setOutputRange(int index) |
413 { |
432 { |
414 if (index < 0 || index >= d->outputRanges.count()) { |
433 if (index < -1 || index >= d->outputRanges.count()) { |
415 qWarning() << "ERROR: Output range" << index << "is not valid"; |
434 qWarning() << "ERROR: Output range" << index << "is not valid"; |
416 return; |
435 return; |
417 } |
436 } |
418 d->outputRange = index; |
437 d->outputRange = index; |
419 } |
438 } |
636 Copy values from other into this reading. Implemented by sub-classes |
650 Copy values from other into this reading. Implemented by sub-classes |
637 using the DECLARE_READING() and IMPLEMENT_READING() macros. |
651 using the DECLARE_READING() and IMPLEMENT_READING() macros. |
638 |
652 |
639 Note that this method should only be called by QSensorBackend. |
653 Note that this method should only be called by QSensorBackend. |
640 */ |
654 */ |
|
655 void QSensorReading::copyValuesFrom(QSensorReading *other) |
|
656 { |
|
657 QSensorReadingPrivate *my_ptr = d.data(); |
|
658 QSensorReadingPrivate *other_ptr = other->d.data(); |
|
659 /* Do a direct copy of the private class */ |
|
660 *(my_ptr) = *(other_ptr); |
|
661 } |
641 |
662 |
642 /*! |
663 /*! |
643 \macro DECLARE_READING(classname) |
664 \macro DECLARE_READING(classname) |
644 \relates QSensorReading |
665 \relates QSensorReading |
645 \brief The DECLARE_READING macro adds some required methods to a reading class. |
666 \brief The DECLARE_READING macro adds some required methods to a reading class. |