sensorfw
calibrationfilter.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Jolla Ltd
4 
5  This file is part of Sensord.
6 
7  Sensord is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License
9  version 2.1 as published by the Free Software Foundation.
10 
11  Sensord is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef MAGCALIBRATIONFILTER_H
21 #define MAGCALIBRATIONFILTER_H
22 
23 #include <QObject>
24 
25 #include "orientationdata.h"
26 #include "filter.h"
27 
28 #include <QFile>
29 
30 class CalibrationFilter : public QObject, public Filter<CalibratedMagneticFieldData, CalibrationFilter, CalibratedMagneticFieldData>
31 {
32  Q_OBJECT
33 
34 public:
35 
36  static FilterBase* factoryMethod() {
37  return new CalibrationFilter;
38  }
40 
41 protected:
42 
44 
45 private:
46 
47  Sink<CalibrationFilter, CalibratedMagneticFieldData> magDataSink;
48 
49  Source<CalibratedMagneticFieldData> magSource;
50  void magDataAvailable(unsigned, const CalibratedMagneticFieldData * );
51 
53  CalibratedMagneticFieldData transformed;
54 
55  QList <QPair<int,int> > minMaxList;
56 
57  qreal offsetX;
58  qreal offsetY;
59  qreal offsetZ;
60 
61  qreal xScale;
62  qreal yScale;
63  qreal zScale;
64 
65  qreal meanX;
66  qreal meanY;
67  qreal meanZ;
68 
69  qreal calLevel;
70  int lowPass(int newVal, int oldVal);
71  QList<const CalibratedMagneticFieldData *> *readingBuffer;
72  int bufferPos;
73 
74  QFile unCalibratedData;
75  QFile calibratedData;
76  QTextStream stream;
77  QTextStream calibratedStream;
78  int dataPoints;
79  bool manualCalibration;
80 
81 };
82 
83 #endif
Datatype for calibrated magnetometer measurements.
static FilterBase * factoryMethod()
Datatypes for different filters.