QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
DeviceInfo.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QLoggingCategory>
4#include <QtPositioning/QGeoPositionInfo>
5#include <QtSensors/QAmbientTemperatureSensor>
6#include <QtSensors/QCompass>
7#include <QtSensors/QPressureSensor>
8
9Q_DECLARE_LOGGING_CATEGORY(QGCDeviceInfoLog)
10
12{
13
15
16class QGCAmbientTemperatureFilter : public QAmbientTemperatureFilter
17{
18public:
21
22 bool filter(QAmbientTemperatureReading *reading) final;
23
24private:
25 static constexpr const qreal s_minValidTemperatureC = -40.;
26 static constexpr const qreal s_maxValidTemperatureC = 85.;
27};
28
29class QGCAmbientTemperature : public QObject
30{
31 Q_OBJECT
32
33public:
34 QGCAmbientTemperature(QObject* parent = nullptr);
36
38
39 qreal temperature() const { return _temperatureC; }
40
41 bool init();
42 void quit();
43
44signals:
45 void temperatureUpdated(qreal temperature);
46
47private:
48 QAmbientTemperatureSensor* _ambientTemperature = nullptr;
49 std::shared_ptr<QGCAmbientTemperatureFilter> _ambientTemperatureFilter = nullptr;
50
51 QMetaObject::Connection _readingChangedConnection;
52
53 qreal _temperatureC = 0;
54};
55
57
58class QGCPressureFilter : public QPressureFilter
59{
60public:
63
64 bool filter(QPressureReading *reading) final;
65
66private:
67 static constexpr const qreal s_minValidPressurePa = 45000.;
68 static constexpr const qreal s_maxValidPressurePa = 110000.;
69
70 static constexpr const qreal s_minValidTemperatureC = -40.;
71 static constexpr const qreal s_maxValidTemperatureC = 85.;
72};
73
74class QGCPressure : public QObject
75{
76 Q_OBJECT
77
78public:
79 QGCPressure(QObject* parent = nullptr);
81
83
84 qreal pressure() const { return _pressurePa; }
85 qreal temperature() const { return _temperatureC; }
86
87 bool init();
88 void quit();
89
90signals:
91 void pressureUpdated(qreal pressure, qreal temperature);
92
93private:
94 QPressureSensor* _pressure = nullptr;
95 std::shared_ptr<QGCPressureFilter> _pressureFilter = nullptr;
96
97 QMetaObject::Connection _readingChangedConnection;
98
99 qreal _temperatureC = 0;
100 qreal _pressurePa = 0;
101};
102
104
105class QGCCompassFilter : public QCompassFilter
106{
107public:
110
111 bool filter(QCompassReading *reading) final;
112
113private:
114 static constexpr qreal s_minCompassCalibrationLevel = 0.65;
115};
116
117class QGCCompass : public QObject
118{
119 Q_OBJECT
120
121public:
122 QGCCompass(QObject *parent = nullptr);
124
126
127 bool init();
128 void quit();
129
130signals:
131 void compassUpdated(qreal azimuth);
132 void positionUpdated(QGeoPositionInfo update);
133
134private:
135 QCompass *_compass = nullptr;
136 std::shared_ptr<QGCCompassFilter> _compassFilter = nullptr;
137
138 QMetaObject::Connection _readingChangedConnection;
139
140 qreal _azimuth = 0;
141 qreal _calibrationLevel = 0;
142};
143
145
146} /* namespace QGCDeviceInfo */
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
bool filter(QAmbientTemperatureReading *reading) final
void temperatureUpdated(qreal temperature)
QGCAmbientTemperature(QObject *parent=nullptr)
static QGCAmbientTemperature * instance()
bool filter(QCompassReading *reading) final
void positionUpdated(QGeoPositionInfo update)
QGCCompass(QObject *parent=nullptr)
void compassUpdated(qreal azimuth)
static QGCCompass * instance()
bool filter(QPressureReading *reading) final
QGCPressure(QObject *parent=nullptr)
void pressureUpdated(qreal pressure, qreal temperature)
qreal temperature() const
Definition DeviceInfo.h:85
static QGCPressure * instance()