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 "QGCMAVLinkTypes.h"
9
13{
14 Q_OBJECT
15 QML_ELEMENT
16 Q_PROPERTY(QString modeParamPrefix MEMBER _modeParamPrefix CONSTANT)
17 Q_PROPERTY(QString modeChannelParam MEMBER _modeChannelParam CONSTANT)
19 Q_PROPERTY(int channelCount MEMBER _channelCount CONSTANT)
21 Q_PROPERTY(bool simpleModesSupported MEMBER _simpleModesSupported CONSTANT)
22 Q_PROPERTY(QStringList simpleModeNames MEMBER _simpleModeNames CONSTANT)
23 Q_PROPERTY(int simpleMode MEMBER _simpleMode NOTIFY simpleModeChanged)
24 Q_PROPERTY(QVariantList simpleModeEnabled MEMBER _simpleModeEnabled NOTIFY simpleModeEnabledChanged)
25 Q_PROPERTY(QVariantList superSimpleModeEnabled MEMBER _superSimpleModeEnabled NOTIFY superSimpleModeEnabledChanged)
26
27public:
28 explicit APMFlightModesComponentController(QObject *parent = nullptr);
29
36 Q_ENUM(SimpleModeValues)
37
38 Q_INVOKABLE void setSimpleMode(int fltModeIndex, bool enabled);
39 Q_INVOKABLE void setSuperSimpleMode(int fltModeIndex, bool enabled);
40
41 int activeFlightMode() const { return _activeFlightMode; }
42 QVariantList channelOptionEnabled() const { return _rgChannelOptionEnabled; }
43
44signals:
47 void simpleModeChanged(int simpleMode);
50
51private slots:
52 void channelValuesChanged(QVector<int> pwmValues);
53 void _updateSimpleParamsFromSimpleMode();
54 void _setupSimpleModeEnabled();
55
56private:
57 Fact *_simpleModeFact = nullptr;
58 Fact *_superSimpleModeFact = nullptr;
59 const bool _simpleModesSupported = false;
60 int _activeFlightMode = 0;
61 int _channelCount = QGCMAVLinkTypes::maxRcChannels;
62 int _simpleMode = SimpleModeStandard;
63 QString _modeChannelParam;
64 QString _modeParamPrefix;
65 const QStringList _simpleModeNames = { tr("Off"), tr("Simple"), tr("Super-Simple"), tr("Custom") };
66 QVariantList _rgChannelOptionEnabled;
67
68 QVariantList _simpleModeEnabled;
69 QVariantList _superSimpleModeEnabled;
70
71 static constexpr uint8_t _allSimpleBits = 0x3F;
72 static constexpr int _cChannelOptions = 11;
73 static constexpr int _cSimpleModeBits = 8;
74 static constexpr int _cFltModes = 6;
75
76 static constexpr const char *_simpleParamName = "SIMPLE";
77 static constexpr const char *_superSimpleParamName = "SUPER_SIMPLE";
78};
MVC Controller for FlightModesComponent.qml.
void simpleModeChanged(int simpleMode)
Q_INVOKABLE void setSimpleMode(int fltModeIndex, bool enabled)
void activeFlightModeChanged(int activeFlightMode)
Q_INVOKABLE void setSuperSimpleMode(int fltModeIndex, bool enabled)
Used for handling missing Facts from C++ code.
A Fact is used to hold a single value within the system.
Definition Fact.h:17
static constexpr uint8_t maxRcChannels