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#include "qmlgyroscope_p.h"
5#include <QtSensors/QGyroscope>
6
7/*!
8 \qmltype Gyroscope
9//! \instantiates QmlGyroscope
10 \ingroup qml-sensors_type
11 \inqmlmodule QtSensors
12 \since QtSensors 5.0
13 \inherits Sensor
14 \brief The Gyroscope element reports on rotational acceleration
15 around the X, Y and Z axes.
16
17 This element wraps the QGyroscope class. Please see the documentation for
18 QGyroscope for details.
19
20 \sa GyroscopeReading
21*/
22
23QmlGyroscope::QmlGyroscope(QObject *parent)
24 : QmlSensor(parent)
25 , m_sensor(new QGyroscope(this))
26{
27}
28
29QmlGyroscope::~QmlGyroscope()
30{
31}
32
33QmlSensorReading *QmlGyroscope::createReading() const
34{
35 return new QmlGyroscopeReading(m_sensor);
36}
37
38QSensor *QmlGyroscope::sensor() const
39{
40 return m_sensor;
41}
42
43/*!
44 \qmltype GyroscopeReading
45//! \instantiates QmlGyroscopeReading
46 \ingroup qml-sensors_reading
47 \inqmlmodule QtSensors
48 \since QtSensors 5.0
49 \inherits SensorReading
50 \brief The GyroscopeReading element holds the most recent Gyroscope reading.
51
52 The GyroscopeReading element holds the most recent Gyroscope reading.
53
54 This element wraps the QGyroscopeReading class. Please see the documentation for
55 QGyroscopeReading for details.
56
57 This element cannot be directly created.
58*/
59
60QmlGyroscopeReading::QmlGyroscopeReading(QGyroscope *sensor)
61 : m_sensor(sensor)
62{
63}
64
65QmlGyroscopeReading::~QmlGyroscopeReading()
66{
67}
68
69/*!
70 \qmlproperty qreal GyroscopeReading::x
71 This property holds the angular velocity around the x axis.
72
73 Please see QGyroscopeReading::x for information about this property.
74*/
75
76qreal QmlGyroscopeReading::x() const
77{
78 return m_x;
79}
80
81QBindable<qreal> QmlGyroscopeReading::bindableX() const
82{
83 return &m_x;
84}
85
86/*!
87 \qmlproperty qreal GyroscopeReading::y
88 This property holds the angular velocity around the y axis.
89
90 Please see QGyroscopeReading::y for information about this property.
91*/
92
93qreal QmlGyroscopeReading::y() const
94{
95 return m_y;
96}
97
98QBindable<qreal> QmlGyroscopeReading::bindableY() const
99{
100 return &m_y;
101}
102
103/*!
104 \qmlproperty qreal GyroscopeReading::z
105 This property holds the angular velocity around the z axis.
106
107 Please see QGyroscopeReading::z for information about this property.
108*/
109
110qreal QmlGyroscopeReading::z() const
111{
112 return m_z;
113}
114
115QBindable<qreal> QmlGyroscopeReading::bindableZ() const
116{
117 return &m_z;
118}
119
120QSensorReading *QmlGyroscopeReading::reading() const
121{
122 return m_sensor->reading();
123}
124
125void QmlGyroscopeReading::readingUpdate()
126{
127 m_x = m_sensor->reading()->x();
128 m_y = m_sensor->reading()->y();
129 m_z = m_sensor->reading()->z();
130}
131

source code of qtsensors/src/sensorsquick/qmlgyroscope.cpp