|
1 /* |
|
2 * Name : Magnetometer.h |
|
3 * Description : Magnetometer helper class |
|
4 * Project : This file is part of OpenMAR, an Open Mobile Augmented Reality browser |
|
5 * Website : http://OpenMAR.org |
|
6 * |
|
7 * Copyright (c) 2010 David Caabeiro |
|
8 * |
|
9 * All rights reserved. This program and the accompanying materials are made available |
|
10 * under the terms of the Eclipse Public License v1.0 which accompanies this |
|
11 * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html |
|
12 * |
|
13 */ |
|
14 |
|
15 #ifndef MAGNETOMETER_H_ |
|
16 #define MAGNETOMETER_H_ |
|
17 |
|
18 #include "Vector3d.h" |
|
19 |
|
20 #include <SensrvDataListener.h> |
|
21 #include <SensrvPropertyListener.h> |
|
22 |
|
23 class CSensrvChannel; |
|
24 |
|
25 /** |
|
26 * @brief Wrapper class over sensor channel to retrieve data from 3-axis magnetometer |
|
27 * |
|
28 * This class also implements a simple lowpass filter |
|
29 */ |
|
30 class CMagnetometer : public CBase, |
|
31 public MSensrvDataListener, |
|
32 public MSensrvPropertyListener |
|
33 { |
|
34 public: |
|
35 static CMagnetometer* NewL(); |
|
36 ~CMagnetometer(); |
|
37 |
|
38 protected: |
|
39 CMagnetometer(); |
|
40 void ConstructL(); |
|
41 |
|
42 public: |
|
43 void StartL(); |
|
44 void Stop(); |
|
45 |
|
46 const Vector3d GetValue() const { return Vector3d(iX, iY, iZ); } |
|
47 |
|
48 enum TCalibration { |
|
49 ENone, |
|
50 ELow, |
|
51 EModerate, |
|
52 EHigh |
|
53 }; |
|
54 |
|
55 TCalibration Calibration() const { return iCalibration; } |
|
56 |
|
57 protected: |
|
58 // From MSensrvDataListener |
|
59 void DataReceived(CSensrvChannel& aChannel, TInt aCount, TInt aDataLost); |
|
60 void DataError(CSensrvChannel& aChannel, TSensrvErrorSeverity aError); |
|
61 void GetDataListenerInterfaceL(TUid aInterfaceUid, TAny*& aInterface); |
|
62 |
|
63 // From MSensrvPropertyListener |
|
64 void PropertyChanged(CSensrvChannel& aChannel, const TSensrvProperty& aChangedProperty); |
|
65 void PropertyError(CSensrvChannel& aChannel, TSensrvErrorSeverity aError); |
|
66 void SetPropertySuccessIndicationChanged(TSetPropertySuccessIndicator aIndication); |
|
67 void GetPropertyListenerInterfaceL(TUid aInterfaceUid, TAny*& aInterface); |
|
68 |
|
69 private: |
|
70 CSensrvChannel* iSensorChannel; |
|
71 |
|
72 TReal iX; |
|
73 TReal iY; |
|
74 TReal iZ; |
|
75 |
|
76 TCalibration iCalibration; |
|
77 }; |
|
78 |
|
79 #endif |