|
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 "qaccelerometer.h" |
|
43 #include "qaccelerometer_p.h" |
|
44 |
|
45 QTM_BEGIN_NAMESPACE |
|
46 |
|
47 IMPLEMENT_READING(QAccelerometerReading) |
|
48 |
|
49 /*! |
|
50 \class QAccelerometerReading |
|
51 \ingroup sensors_reading |
|
52 |
|
53 \brief The QAccelerometerReading class reports on linear acceleration |
|
54 along the X, Y and Z axes. |
|
55 |
|
56 \section2 QAccelerometerReading Units |
|
57 The scale of the values is meters per second squared. |
|
58 The axes are arranged as follows. |
|
59 |
|
60 \image sensors-coordinates2.jpg |
|
61 |
|
62 A monoblock device sitting at rest, face up on a desk will experience |
|
63 a force of approximately 9.8 on the Z axis (ie. towards the roof). |
|
64 This is the proper acceleration the device experiences relative to |
|
65 freefall. |
|
66 */ |
|
67 |
|
68 /*! |
|
69 \property QAccelerometerReading::x |
|
70 \brief the acceleration on the X axis. |
|
71 |
|
72 The scale of the values is meters per second squared. |
|
73 \sa {QAccelerometerReading Units} |
|
74 */ |
|
75 |
|
76 qreal QAccelerometerReading::x() const |
|
77 { |
|
78 return d->x; |
|
79 } |
|
80 |
|
81 /*! |
|
82 Sets the acceleration on the X axis to \a x. |
|
83 */ |
|
84 void QAccelerometerReading::setX(qreal x) |
|
85 { |
|
86 d->x = x; |
|
87 } |
|
88 |
|
89 /*! |
|
90 \property QAccelerometerReading::y |
|
91 \brief the acceleration on the Y axis. |
|
92 |
|
93 The scale of the values is meters per second squared. |
|
94 \sa {QAccelerometerReading Units} |
|
95 */ |
|
96 |
|
97 qreal QAccelerometerReading::y() const |
|
98 { |
|
99 return d->y; |
|
100 } |
|
101 |
|
102 /*! |
|
103 Sets the acceleration on the Y axis to \a y. |
|
104 */ |
|
105 void QAccelerometerReading::setY(qreal y) |
|
106 { |
|
107 d->y = y; |
|
108 } |
|
109 |
|
110 /*! |
|
111 \property QAccelerometerReading::z |
|
112 \brief the acceleration on the Z axis. |
|
113 |
|
114 The scale of the values is meters per second squared. |
|
115 \sa {QAccelerometerReading Units} |
|
116 */ |
|
117 |
|
118 qreal QAccelerometerReading::z() const |
|
119 { |
|
120 return d->z; |
|
121 } |
|
122 |
|
123 /*! |
|
124 Sets the acceleration on the Z axis to \a z. |
|
125 */ |
|
126 void QAccelerometerReading::setZ(qreal z) |
|
127 { |
|
128 d->z = z; |
|
129 } |
|
130 |
|
131 // ===================================================================== |
|
132 |
|
133 /*! |
|
134 \class QAccelerometerFilter |
|
135 \ingroup sensors_filter |
|
136 |
|
137 \brief The QAccelerometerFilter class is a convenience wrapper around QSensorFilter. |
|
138 |
|
139 The only difference is that the filter() method features a pointer to QAccelerometerReading |
|
140 instead of QSensorReading. |
|
141 */ |
|
142 |
|
143 /*! |
|
144 \fn QAccelerometerFilter::filter(QAccelerometerReading *reading) |
|
145 |
|
146 Called when \a reading changes. Returns false to prevent the reading from propagating. |
|
147 |
|
148 \sa QSensorFilter::filter() |
|
149 */ |
|
150 |
|
151 char const * const QAccelerometer::type("QAccelerometer"); |
|
152 |
|
153 /*! |
|
154 \class QAccelerometer |
|
155 \ingroup sensors_type |
|
156 |
|
157 \brief The QAccelerometer class is a convenience wrapper around QSensor. |
|
158 |
|
159 The only behavioural difference is that this class sets the type properly. |
|
160 |
|
161 This class also features a reading() function that returns a QAccelerometerReading instead of a QSensorReading. |
|
162 |
|
163 For details about how the sensor works, see \l QAccelerometerReading. |
|
164 |
|
165 \sa QAccelerometerReading |
|
166 */ |
|
167 |
|
168 /*! |
|
169 \fn QAccelerometer::QAccelerometer(QObject *parent) |
|
170 |
|
171 Construct the sensor as a child of \a parent. |
|
172 */ |
|
173 |
|
174 /*! |
|
175 \fn QAccelerometer::~QAccelerometer() |
|
176 |
|
177 Destroy the sensor. Stops the sensor if it has not already been stopped. |
|
178 */ |
|
179 |
|
180 /*! |
|
181 \fn QAccelerometer::reading() const |
|
182 |
|
183 Returns the reading class for this sensor. |
|
184 |
|
185 \sa QSensor::reading() |
|
186 */ |
|
187 |
|
188 #include "moc_qaccelerometer.cpp" |
|
189 QTM_END_NAMESPACE |
|
190 |