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