1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef GENERICTILTSENSOR_H
5#define GENERICTILTSENSOR_H
6
7#include <QtSensors/qsensorbackend.h>
8#include <QtSensors/qtiltsensor.h>
9#include <QtSensors/qaccelerometer.h>
10
11QT_BEGIN_NAMESPACE
12
13class GenericTiltSensor : public QSensorBackend, public QAccelerometerFilter
14{
15 Q_OBJECT
16public:
17
18 static char const * const id;
19
20 GenericTiltSensor(QSensor *sensor);
21
22 void start() override;
23 void stop() override;
24
25 Q_INVOKABLE void calibrate();
26
27 bool filter(QAccelerometerReading *reading) override;
28
29 bool isFeatureSupported(QSensor::Feature feature) const override;
30
31private:
32 QTiltReading m_reading;
33 QAccelerometer *accelerometer;
34 qreal radAccuracy;
35 qreal pitch;
36 qreal roll;
37 qreal calibratedPitch;
38 qreal calibratedRoll;
39 qreal xRotation;
40 qreal yRotation;
41};
42
43QT_END_NAMESPACE
44
45#endif
46
47

source code of qtsensors/src/plugins/sensors/generic/generictiltsensor.h