1 | // Copyright (C) 2016 Research In Motion |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | #include <qpressuresensor.h> |
4 | #include "qpressuresensor_p.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | IMPLEMENT_READING(QPressureReading) |
9 | |
10 | /*! |
11 | \class QPressureReading |
12 | \ingroup sensors_reading |
13 | \inmodule QtSensors |
14 | \since 5.1 |
15 | |
16 | \brief The QPressureReading class holds readings from the pressure sensor. |
17 | |
18 | \section2 QPressureReading Units |
19 | |
20 | The pressure sensor returns atmospheric pressure values in Pascals. |
21 | */ |
22 | |
23 | /*! |
24 | \property QPressureReading::pressure |
25 | \brief The measured atmospheric pressure. |
26 | |
27 | Returned as Pascals. |
28 | \sa {QPressureReading Units} |
29 | */ |
30 | |
31 | qreal QPressureReading::pressure() const |
32 | { |
33 | return d->pressure; |
34 | } |
35 | |
36 | /*! |
37 | Sets the pressure to \a pressure. |
38 | */ |
39 | void QPressureReading::setPressure(qreal pressure) |
40 | { |
41 | d->pressure = pressure; |
42 | } |
43 | |
44 | /*! |
45 | \property QPressureReading::temperature |
46 | \brief The pressure sensor's temperature. |
47 | \since 5.2 |
48 | |
49 | The temperature is returned in degree Celsius. |
50 | This property, if supported, provides the pressure sensor die temperature. |
51 | Note that this temperature may be (and usually is) different than the temperature |
52 | reported from QAmbientTemperatureSensor. |
53 | Use QSensor::isFeatureSupported() with the QSensor::PressureSensorTemperature |
54 | flag to determine its availability. |
55 | */ |
56 | |
57 | qreal QPressureReading::temperature() const |
58 | { |
59 | return d->temperature; |
60 | } |
61 | |
62 | /*! |
63 | Sets the pressure sensor's temperature to \a temperature. |
64 | \since 5.2 |
65 | */ |
66 | void QPressureReading::setTemperature(qreal temperature) |
67 | { |
68 | d->temperature = temperature; |
69 | } |
70 | |
71 | // ===================================================================== |
72 | |
73 | /*! |
74 | \class QPressureFilter |
75 | \ingroup sensors_filter |
76 | \inmodule QtSensors |
77 | \since 5.1 |
78 | |
79 | \brief The QPressureFilter class is a convenience wrapper around QSensorFilter. |
80 | |
81 | The only difference is that the filter() method features a pointer to QPressureReading |
82 | instead of QSensorReading. |
83 | */ |
84 | |
85 | /*! |
86 | \fn QPressureFilter::filter(QPressureReading *reading) |
87 | |
88 | Called when \a reading changes. Returns false to prevent the reading from propagating. |
89 | |
90 | \sa QSensorFilter::filter() |
91 | */ |
92 | |
93 | bool QPressureFilter::filter(QSensorReading *reading) |
94 | { |
95 | return filter(reading: static_cast<QPressureReading*>(reading)); |
96 | } |
97 | |
98 | char const * const QPressureSensor::sensorType("QPressureSensor" ); |
99 | |
100 | /*! |
101 | \class QPressureSensor |
102 | \ingroup sensors_type |
103 | \inmodule QtSensors |
104 | \since 5.1 |
105 | |
106 | \brief The QPressureSensor class is a convenience wrapper around QSensor. |
107 | |
108 | The only behavioural difference is that this class sets the type properly. |
109 | |
110 | This class also features a reading() function that returns a QPressureReading instead of a QSensorReading. |
111 | |
112 | For details about how the sensor works, see \l QPressureReading. |
113 | |
114 | \sa QPressureReading |
115 | */ |
116 | |
117 | /*! |
118 | Construct the sensor as a child of \a parent. |
119 | */ |
120 | QPressureSensor::QPressureSensor(QObject *parent) |
121 | : QSensor(QPressureSensor::sensorType, parent) |
122 | { |
123 | } |
124 | |
125 | /*! |
126 | Destroy the sensor. Stops the sensor if it has not already been stopped. |
127 | */ |
128 | QPressureSensor::~QPressureSensor() |
129 | { |
130 | } |
131 | |
132 | /*! |
133 | \fn QPressureSensor::reading() const |
134 | |
135 | Returns the reading class for this sensor. |
136 | |
137 | \sa QSensor::reading() |
138 | */ |
139 | |
140 | QPressureReading *QPressureSensor::reading() const |
141 | { |
142 | return static_cast<QPressureReading*>(QSensor::reading()); |
143 | } |
144 | |
145 | QT_END_NAMESPACE |
146 | |
147 | #include "moc_qpressuresensor.cpp" |
148 | |