QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
APMFlightModesComponentController.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QStringList>
4#include <QtCore/QVariantList>
5#include <QtQmlIntegration/QtQmlIntegration>
6
8#include "QGCMAVLink.h"
9
12{
13 Q_OBJECT
14 QML_ELEMENT
15 Q_PROPERTY(QString modeParamPrefix MEMBER _modeParamPrefix CONSTANT)
16 Q_PROPERTY(QString modeChannelParam MEMBER _modeChannelParam CONSTANT)
17 Q_PROPERTY(int activeFlightMode READ activeFlightMode NOTIFY activeFlightModeChanged)
18 Q_PROPERTY(int channelCount MEMBER _channelCount CONSTANT)
19 Q_PROPERTY(QVariantList channelOptionEnabled READ channelOptionEnabled NOTIFY channelOptionEnabledChanged)
20 Q_PROPERTY(bool simpleModesSupported MEMBER _simpleModesSupported CONSTANT)
21 Q_PROPERTY(QStringList simpleModeNames MEMBER _simpleModeNames CONSTANT)
22 Q_PROPERTY(int simpleMode MEMBER _simpleMode NOTIFY simpleModeChanged)
23 Q_PROPERTY(QVariantList simpleModeEnabled MEMBER _simpleModeEnabled NOTIFY simpleModeEnabledChanged)
24 Q_PROPERTY(QVariantList superSimpleModeEnabled MEMBER _superSimpleModeEnabled NOTIFY superSimpleModeEnabledChanged)
25
26public:
27 explicit APMFlightModesComponentController(QObject *parent = nullptr);
28
29 enum SimpleModeValues {
30 SimpleModeStandard = 0,
31 SimpleModeSimple,
32 SimpleModeSuperSimple,
33 SimpleModeCustom
34 };
35 Q_ENUM(SimpleModeValues)
36
37 Q_INVOKABLE void setSimpleMode(int fltModeIndex, bool enabled);
38 Q_INVOKABLE void setSuperSimpleMode(int fltModeIndex, bool enabled);
39
40 int activeFlightMode() const { return _activeFlightMode; }
41 QVariantList channelOptionEnabled() const { return _rgChannelOptionEnabled; }
42
43signals:
44 void activeFlightModeChanged(int activeFlightMode);
46 void simpleModeChanged(int simpleMode);
49
50private slots:
51 void channelValuesChanged(QVector<int> pwmValues);
52 void _updateSimpleParamsFromSimpleMode();
53 void _setupSimpleModeEnabled();
54
55private:
56 Fact *_simpleModeFact = nullptr;
57 Fact *_superSimpleModeFact = nullptr;
58 const bool _simpleModesSupported = false;
59 int _activeFlightMode = 0;
60 int _channelCount = QGCMAVLink::maxRcChannels;
61 int _simpleMode = SimpleModeStandard;
62 QString _modeChannelParam;
63 QString _modeParamPrefix;
64 const QStringList _simpleModeNames = { tr("Off"), tr("Simple"), tr("Super-Simple"), tr("Custom") };
65 QVariantList _rgChannelOptionEnabled;
66
67 QVariantList _simpleModeEnabled;
68 QVariantList _superSimpleModeEnabled;
69
70 static constexpr uint8_t _allSimpleBits = 0x3F;
71 static constexpr int _cChannelOptions = 11;
72 static constexpr int _cSimpleModeBits = 8;
73 static constexpr int _cFltModes = 6;
74
75 static constexpr const char *_simpleParamName = "SIMPLE";
76 static constexpr const char *_superSimpleParamName = "SUPER_SIMPLE";
77};
MVC Controller for FlightModesComponent.qml.
void simpleModeChanged(int simpleMode)
void activeFlightModeChanged(int activeFlightMode)
Used for handling missing Facts from C++ code.
A Fact is used to hold a single value within the system.
Definition Fact.h:19