summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/generic/generictiltsensor.h
blob: 3f7f438dd5d8abd0ad5062829306406b11a90cb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef GENERICTILTSENSOR_H
#define GENERICTILTSENSOR_H

#include <QtSensors/qsensorbackend.h>
#include <QtSensors/qtiltsensor.h>
#include <QtSensors/qaccelerometer.h>

QT_BEGIN_NAMESPACE

class GenericTiltSensor : public QSensorBackend, public QAccelerometerFilter
{
    Q_OBJECT
public:

    static char const * const id;

    GenericTiltSensor(QSensor *sensor);

    void start() override;
    void stop() override;

    Q_INVOKABLE void calibrate();

    bool filter(QAccelerometerReading *reading) override;

    bool isFeatureSupported(QSensor::Feature feature) const override;

private:
    QTiltReading m_reading;
    QAccelerometer *accelerometer;
    qreal radAccuracy;
    qreal pitch;
    qreal roll;
    qreal calibratedPitch;
    qreal calibratedRoll;
    qreal xRotation;
    qreal yRotation;
};

QT_END_NAMESPACE

#endif