|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 \preliminary |
|
54 \brief The QCompassReading class represents one reading from a |
|
55 compass. |
|
56 |
|
57 \section2 QCompassReading Units |
|
58 The compass returns the azimuth of the device as degrees from |
|
59 magnetic north in a clockwise direction based on the top of the UI. |
|
60 There is also a value to indicate the calibration status of the device. |
|
61 If the device is not calibrated the azimuth may not be accurate. |
|
62 |
|
63 Digital compasses are susceptible to magnetic interference and may need |
|
64 calibration after being placed near anything that emits a magnetic force. |
|
65 Accuracy of the compass can be affected by any ferrous materials that are nearby. |
|
66 */ |
|
67 |
|
68 /*! |
|
69 \enum QCompassReading::CalibrationLevel |
|
70 |
|
71 \value Undefined The calibration level is not defined or is too low. |
|
72 \value Low The reported azimuth may be off by up to 15.4 degrees. |
|
73 \value Middle The reported azimuth may be off by up to 11.8 degrees. |
|
74 \value High The reported azimuth may be off by up to 7.4 degrees. |
|
75 */ |
|
76 |
|
77 /*! |
|
78 \property QCompassReading::azimuth |
|
79 \brief the azimuth of the device. |
|
80 |
|
81 Measured in degrees from magnetic north in a clockwise direction based |
|
82 the top of the UI. |
|
83 \sa {QCompassReading Units} |
|
84 */ |
|
85 |
|
86 qreal QCompassReading::azimuth() const |
|
87 { |
|
88 return d->azimuth; |
|
89 } |
|
90 |
|
91 /*! |
|
92 Sets the \a azimuth of the device. |
|
93 */ |
|
94 void QCompassReading::setAzimuth(qreal azimuth) |
|
95 { |
|
96 d->azimuth = azimuth; |
|
97 } |
|
98 |
|
99 /*! |
|
100 \property QCompassReading::calibrationLevel |
|
101 \brief the calibration level of the reading. |
|
102 |
|
103 The higher the calibration, the more accurate the measurement is. |
|
104 \sa {QCompassReading Units} |
|
105 */ |
|
106 |
|
107 QCompassReading::CalibrationLevel QCompassReading::calibrationLevel() const |
|
108 { |
|
109 return static_cast<QCompassReading::CalibrationLevel>(d->calibrationLevel); |
|
110 } |
|
111 |
|
112 /*! |
|
113 Sets the calibration level of the reading to \a calibrationLevel. |
|
114 */ |
|
115 void QCompassReading::setCalibrationLevel(QCompassReading::CalibrationLevel calibrationLevel) |
|
116 { |
|
117 d->calibrationLevel = calibrationLevel; |
|
118 } |
|
119 |
|
120 // ===================================================================== |
|
121 |
|
122 // begin generated code |
|
123 |
|
124 /*! |
|
125 \class QCompassFilter |
|
126 \ingroup sensors_filter |
|
127 |
|
128 \preliminary |
|
129 \brief The QCompassFilter class is a convenience wrapper around QSensorFilter. |
|
130 |
|
131 The only difference is that the filter() method features a pointer to QCompassReading |
|
132 instead of QSensorReading. |
|
133 */ |
|
134 |
|
135 /*! |
|
136 \fn QCompassFilter::filter(QCompassReading *reading) |
|
137 |
|
138 Called when \a reading changes. Returns false to prevent the reading from propagating. |
|
139 |
|
140 \sa QSensorFilter::filter() |
|
141 */ |
|
142 |
|
143 const char *QCompass::type("QCompass"); |
|
144 |
|
145 /*! |
|
146 \class QCompass |
|
147 \ingroup sensors_type |
|
148 |
|
149 \preliminary |
|
150 \brief The QCompass class is a convenience wrapper around QSensor. |
|
151 |
|
152 The only behavioural difference is that this class sets the type properly. |
|
153 |
|
154 This class also features a reading() function that returns a QCompassReading instead of a QSensorReading. |
|
155 |
|
156 For details about how the sensor works, see \l QCompassReading. |
|
157 |
|
158 \sa QCompassReading |
|
159 */ |
|
160 |
|
161 /*! |
|
162 \fn QCompass::QCompass(QObject *parent) |
|
163 |
|
164 Construct the sensor as a child of \a parent. |
|
165 */ |
|
166 |
|
167 /*! |
|
168 \fn QCompass::~QCompass() |
|
169 |
|
170 Destroy the sensor. Stops the sensor if it has not already been stopped. |
|
171 */ |
|
172 |
|
173 /*! |
|
174 \fn QCompass::reading() const |
|
175 |
|
176 Returns the reading class for this sensor. |
|
177 |
|
178 \sa QSensor::reading() |
|
179 */ |
|
180 // end generated code |
|
181 |
|
182 #include "moc_qcompass.cpp" |
|
183 QTM_END_NAMESPACE |
|
184 |