14 _rcTimeoutTimer.setInterval(2000);
15 _rcTimeoutTimer.setSingleShot(
true);
16 (void) connect(&_rcTimeoutTimer, &QTimer::timeout,
this, &PX4FlightModesController::_clearRcChannelValues);
23 _updateExternalModeNames();
37 &PX4FlightModesController::_rcChannelsChanged);
40 &PX4FlightModesController::_rcChannelsChanged);
44 _rcTimeoutTimer.stop();
45 _clearRcChannelValues();
50void PX4FlightModesController::_rcChannelsChanged(QVector<int> pwmValues)
52 _rcChannelValues.clear();
53 _rcChannelValues.reserve(pwmValues.size());
54 for (
const int pwm : pwmValues) {
55 _rcChannelValues.append(pwm);
57 _rcTimeoutTimer.start();
61void PX4FlightModesController::_clearRcChannelValues()
63 if (_rcChannelValues.isEmpty()) {
66 _rcChannelValues.clear();
70void PX4FlightModesController::_updateExternalModeNames()
77 if (names != _externalModeNames) {
78 _externalModeNames = names;
87 return QStringLiteral(
"switch");
89 return QStringLiteral(
"buttons");
94 return QStringLiteral(
"none");
108 const QVariantList& enumValues,
const QStringList& externalNames,
109 int currentValue)
const
111 QVariantList choices;
114 choices.append(QVariantMap{{QStringLiteral(
"label"), choice.label}, {QStringLiteral(
"value"), choice.value}});
121 const QVariantList& enumValues,
const QStringList& externalNames,
127QVariantList PX4FlightModesController::_toVariantList(
const QList<int>& values)
130 for (
const int value : values) {
FactPanelController(QObject *parent=nullptr)
static QStringList externalFlightModeNames(const FlightModeList &modeList)
externalFlightModeName of each of External Mode 1-8, in order
void setMonitorRc(bool monitorRc)
Q_INVOKABLE QVariantList buttonChannels(int buttonMask) const
RC channels (1-based) of the mode buttons in RC_MAP_FLTM_BTN, lowest first. Button N selects slot N.
void externalModeNamesChanged()
PX4FlightModesController(QObject *parent=nullptr)
true: rcChannelValues follows the vehicle's RC input. Off by default, for users that only need the mo...
Q_INVOKABLE QVariantList modeChoices(const QString ¶mName, const QStringList &enumStrings, const QVariantList &enumValues, const QStringList &externalNames, int currentValue) const
void rcChannelValuesChanged()
Q_INVOKABLE QString modeName(const QString ¶mName, const QStringList &enumStrings, const QVariantList &enumValues, const QStringList &externalNames, int value) const
Label of the mode a parameter value selects, as modeChoices shows it. Empty for a value with no choic...
Q_INVOKABLE QVariantList ignoredButtonChannels(int buttonMask) const
Channels set in RC_MAP_FLTM_BTN that PX4 ignores, because only the lowest six get a slot.
Q_INVOKABLE QString selectionMethod(int modeChannel, int buttonMask) const
"switch", "buttons" or "none" from RC_MAP_FLTMODE and RC_MAP_FLTM_BTN
void rcChannelsRawChanged(QVector< int > channelValues)
void flightModesChanged()
QList< int > buttonChannels(int buttonMask)
QString modeName(const QString ¶mName, const QStringList &enumStrings, const QVariantList &enumValues, const QStringList &externalNames, int value)
Label of the mode a parameter value selects, as modeChoices shows it. Empty for a value with no choic...
SelectionMethod selectionMethod(int modeChannel, int buttonMask)
PX4 ignores the mode buttons while a mode channel is set.
QList< Choice > modeChoices(const QString ¶mName, const QStringList &enumStrings, const QVariantList &enumValues, const QStringList &externalNames, int currentValue)
QList< int > ignoredButtonChannels(int buttonMask)
Channels set in RC_MAP_FLTM_BTN that PX4 ignores, because only the lowest kModeSlotCount get a slot.