| 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 QTILTSENSOR_H |
| 5 | #define QTILTSENSOR_H |
| 6 | |
| 7 | #include <QtSensors/qsensor.h> |
| 8 | |
| 9 | QT_BEGIN_NAMESPACE |
| 10 | |
| 11 | class QTiltReadingPrivate; |
| 12 | |
| 13 | class Q_SENSORS_EXPORT QTiltReading : public QSensorReading |
| 14 | { |
| 15 | Q_OBJECT |
| 16 | Q_PROPERTY(qreal yRotation READ yRotation) |
| 17 | Q_PROPERTY(qreal xRotation READ xRotation) |
| 18 | DECLARE_READING(QTiltReading) |
| 19 | |
| 20 | public: |
| 21 | qreal yRotation() const; |
| 22 | void setYRotation(qreal y); |
| 23 | |
| 24 | qreal xRotation() const; |
| 25 | void setXRotation(qreal x); |
| 26 | |
| 27 | }; |
| 28 | |
| 29 | class Q_SENSORS_EXPORT QTiltFilter : public QSensorFilter |
| 30 | { |
| 31 | public: |
| 32 | virtual bool filter(QTiltReading *reading) = 0; |
| 33 | private: |
| 34 | bool filter(QSensorReading *reading) override; |
| 35 | }; |
| 36 | |
| 37 | class Q_SENSORS_EXPORT QTiltSensor : public QSensor |
| 38 | { |
| 39 | Q_OBJECT |
| 40 | public: |
| 41 | explicit QTiltSensor(QObject *parent = nullptr); |
| 42 | ~QTiltSensor(); |
| 43 | QTiltReading *reading() const; |
| 44 | static char const * const sensorType; |
| 45 | |
| 46 | Q_INVOKABLE void calibrate(); |
| 47 | |
| 48 | private: |
| 49 | Q_DISABLE_COPY(QTiltSensor) |
| 50 | }; |
| 51 | |
| 52 | QT_END_NAMESPACE |
| 53 | #endif |
| 54 | |