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 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | class GenericTiltSensor : public QSensorBackend, public QAccelerometerFilter |
14 | { |
15 | Q_OBJECT |
16 | public: |
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 | |
31 | private: |
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 | |
43 | QT_END_NAMESPACE |
44 | |
45 | #endif |
46 | |
47 |