sensorfw: chains/magcalibrationchain/calibrationfilter.h Source File

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
34public:
35
36 static FilterBase* factoryMethod() {
37 return new CalibrationFilter;
38 }
39 void dropCalibration();
40
41protected:
42
43 CalibrationFilter();
44
45private:
46
47 Sink<CalibrationFilter, CalibratedMagneticFieldData> magDataSink;
48
49 Source<CalibratedMagneticFieldData> magSource;
50 void magDataAvailable(unsigned, const CalibratedMagneticFieldData * );
51
52 CalibratedMagneticFieldData magData;
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
CalibratedMagneticFieldData
Datatype for calibrated magnetometer measurements.
Definition: orientationdata.h:59
CalibrationFilter
Definition: calibrationfilter.h:31
CalibrationFilter::CalibrationFilter
CalibrationFilter()
CalibrationFilter::dropCalibration
void dropCalibration()
CalibrationFilter::factoryMethod
static FilterBase * factoryMethod()
Definition: calibrationfilter.h:36
orientationdata.h
Datatypes for different filters.