1/****************************************************************************
2**
3** Copyright (C) 2016 Research In Motion
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtSensors module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39#include <qpressuresensor.h>
40#include "qpressuresensor_p.h"
41
42QT_BEGIN_NAMESPACE
43
44IMPLEMENT_READING(QPressureReading)
45
46/*!
47 \class QPressureReading
48 \ingroup sensors_reading
49 \inmodule QtSensors
50 \since 5.1
51
52 \brief The QPressureReading class holds readings from the pressure sensor.
53
54 \section2 QPressureReading Units
55
56 The pressure sensor returns atmospheric pressure values in Pascals.
57*/
58
59/*!
60 \property QPressureReading::pressure
61 \brief The measured atmospheric pressure.
62
63 Returned as Pascals.
64 \sa {QPressureReading Units}
65*/
66
67qreal QPressureReading::pressure() const
68{
69 return d->pressure;
70}
71
72/*!
73 Sets the pressure to \a pressure.
74*/
75void QPressureReading::setPressure(qreal pressure)
76{
77 d->pressure = pressure;
78}
79
80/*!
81 \property QPressureReading::temperature
82 \brief The pressure sensor's temperature.
83 \since 5.2
84
85 The temperature is returned in degree Celsius.
86 This property, if supported, provides the pressure sensor die temperature.
87 Note that this temperature may be (and usually is) different than the temperature
88 reported from QAmbientTemperatureSensor.
89 Use QSensor::isFeatureSupported() with the QSensor::PressureSensorTemperature
90 flag to determine its availability.
91*/
92
93qreal QPressureReading::temperature() const
94{
95 return d->temperature;
96}
97
98/*!
99 Sets the pressure sensor's temperature to \a temperature.
100 \since 5.2
101*/
102void QPressureReading::setTemperature(qreal temperature)
103{
104 d->temperature = temperature;
105}
106
107// =====================================================================
108
109/*!
110 \class QPressureFilter
111 \ingroup sensors_filter
112 \inmodule QtSensors
113 \since 5.1
114
115 \brief The QPressureFilter class is a convenience wrapper around QSensorFilter.
116
117 The only difference is that the filter() method features a pointer to QPressureReading
118 instead of QSensorReading.
119*/
120
121/*!
122 \fn QPressureFilter::filter(QPressureReading *reading)
123
124 Called when \a reading changes. Returns false to prevent the reading from propagating.
125
126 \sa QSensorFilter::filter()
127*/
128
129bool QPressureFilter::filter(QSensorReading *reading)
130{
131 return filter(reading: static_cast<QPressureReading*>(reading));
132}
133
134char const * const QPressureSensor::type("QPressureSensor");
135
136/*!
137 \class QPressureSensor
138 \ingroup sensors_type
139 \inmodule QtSensors
140 \since 5.1
141
142 \brief The QPressureSensor class is a convenience wrapper around QSensor.
143
144 The only behavioural difference is that this class sets the type properly.
145
146 This class also features a reading() function that returns a QPressureReading instead of a QSensorReading.
147
148 For details about how the sensor works, see \l QPressureReading.
149
150 \sa QPressureReading
151*/
152
153/*!
154 Construct the sensor as a child of \a parent.
155*/
156QPressureSensor::QPressureSensor(QObject *parent)
157 : QSensor(QPressureSensor::type, parent)
158{
159}
160
161/*!
162 Destroy the sensor. Stops the sensor if it has not already been stopped.
163*/
164QPressureSensor::~QPressureSensor()
165{
166}
167
168/*!
169 \fn QPressureSensor::reading() const
170
171 Returns the reading class for this sensor.
172
173 \sa QSensor::reading()
174*/
175
176QPressureReading *QPressureSensor::reading() const
177{
178 return static_cast<QPressureReading*>(QSensor::reading());
179}
180
181QT_END_NAMESPACE
182
183#include "moc_qpressuresensor.cpp"
184

source code of qtsensors/src/sensors/qpressuresensor.cpp