|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qcompass.h" |
|
43 #include "qcompass_p.h" |
|
44 |
|
45 QTM_BEGIN_NAMESPACE |
|
46 |
|
47 IMPLEMENT_READING(QCompassReading) |
|
48 |
|
49 /*! |
|
50 \class QCompassReading |
|
51 \ingroup sensors_reading |
|
52 |
|
53 \brief The QCompassReading class represents one reading from a |
|
54 compass. |
|
55 |
|
56 \section2 QCompassReading Units |
|
57 The compass returns the azimuth of the device as degrees from |
|
58 magnetic north in a clockwise direction based on the top of the UI. |
|
59 There is also a value to indicate the calibration status of the device. |
|
60 If the device is not calibrated the azimuth may not be accurate. |
|
61 |
|
62 Digital compasses are susceptible to magnetic interference and may need |
|
63 calibration after being placed near anything that emits a magnetic force. |
|
64 Accuracy of the compass can be affected by any ferrous materials that are nearby. |
|
65 |
|
66 The calibration status of the device is measured as a number from 0 to 1. |
|
67 A value of 1 is the highest level that the device can support and 0 is |
|
68 the worst. |
|
69 */ |
|
70 |
|
71 /*! |
|
72 \property QCompassReading::azimuth |
|
73 \brief the azimuth of the device. |
|
74 |
|
75 Measured in degrees from magnetic north in a clockwise direction based |
|
76 the top of the UI. |
|
77 \sa {QCompassReading Units} |
|
78 */ |
|
79 |
|
80 qreal QCompassReading::azimuth() const |
|
81 { |
|
82 return d->azimuth; |
|
83 } |
|
84 |
|
85 /*! |
|
86 Sets the \a azimuth of the device. |
|
87 |
|
88 \sa {QCompassReading Units} |
|
89 */ |
|
90 void QCompassReading::setAzimuth(qreal azimuth) |
|
91 { |
|
92 d->azimuth = azimuth; |
|
93 } |
|
94 |
|
95 /*! |
|
96 \property QCompassReading::calibrationLevel |
|
97 \brief the calibration level of the reading. |
|
98 |
|
99 Measured as a value from 0 to 1 with higher values being better. |
|
100 \sa {QCompassReading Units} |
|
101 */ |
|
102 |
|
103 qreal QCompassReading::calibrationLevel() const |
|
104 { |
|
105 return d->calibrationLevel; |
|
106 } |
|
107 |
|
108 /*! |
|
109 Sets the calibration level of the reading to \a calibrationLevel. |
|
110 */ |
|
111 void QCompassReading::setCalibrationLevel(qreal calibrationLevel) |
|
112 { |
|
113 d->calibrationLevel = calibrationLevel; |
|
114 } |
|
115 |
|
116 // ===================================================================== |
|
117 |
|
118 /*! |
|
119 \class QCompassFilter |
|
120 \ingroup sensors_filter |
|
121 |
|
122 \brief The QCompassFilter class is a convenience wrapper around QSensorFilter. |
|
123 |
|
124 The only difference is that the filter() method features a pointer to QCompassReading |
|
125 instead of QSensorReading. |
|
126 */ |
|
127 |
|
128 /*! |
|
129 \fn QCompassFilter::filter(QCompassReading *reading) |
|
130 |
|
131 Called when \a reading changes. Returns false to prevent the reading from propagating. |
|
132 |
|
133 \sa QSensorFilter::filter() |
|
134 */ |
|
135 |
|
136 char const * const QCompass::type("QCompass"); |
|
137 |
|
138 /*! |
|
139 \class QCompass |
|
140 \ingroup sensors_type |
|
141 |
|
142 \brief The QCompass 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 QCompassReading instead of a QSensorReading. |
|
147 |
|
148 For details about how the sensor works, see \l QCompassReading. |
|
149 |
|
150 \sa QCompassReading |
|
151 */ |
|
152 |
|
153 /*! |
|
154 \fn QCompass::QCompass(QObject *parent) |
|
155 |
|
156 Construct the sensor as a child of \a parent. |
|
157 */ |
|
158 |
|
159 /*! |
|
160 \fn QCompass::~QCompass() |
|
161 |
|
162 Destroy the sensor. Stops the sensor if it has not already been stopped. |
|
163 */ |
|
164 |
|
165 /*! |
|
166 \fn QCompass::reading() const |
|
167 |
|
168 Returns the reading class for this sensor. |
|
169 |
|
170 \sa QSensor::reading() |
|
171 */ |
|
172 |
|
173 #include "moc_qcompass.cpp" |
|
174 QTM_END_NAMESPACE |
|
175 |