Commit d22a9bb1 authored by Tomaz Canabrava's avatar Tomaz Canabrava Committed by Daniel Agar

Lists should use brace initializer

parent 29b2077a
......@@ -31,16 +31,17 @@ PX4AdvancedFlightModesController::PX4AdvancedFlightModesController(void) :
_returnModeSelected(false),
_offboardModeSelected(false)
{
QStringList usedParams;
usedParams << "RC_MAP_THROTTLE" << "RC_MAP_YAW" << "RC_MAP_PITCH" << "RC_MAP_ROLL" << "RC_MAP_FLAPS" << "RC_MAP_AUX1" << "RC_MAP_AUX2" <<
"RC_MAP_MODE_SW" << "RC_MAP_RETURN_SW" << "RC_MAP_LOITER_SW" << "RC_MAP_POSCTL_SW" << "RC_MAP_OFFB_SW" << "RC_MAP_ACRO_SW";
QStringList usedParams = QStringList({
"RC_MAP_THROTTLE", "RC_MAP_YAW", "RC_MAP_PITCH", "RC_MAP_ROLL", "RC_MAP_FLAPS", "RC_MAP_AUX1", "RC_MAP_AUX2",
"RC_MAP_MODE_SW", "RC_MAP_RETURN_SW", "RC_MAP_LOITER_SW", "RC_MAP_POSCTL_SW", "RC_MAP_OFFB_SW", "RC_MAP_ACRO_SW"});
if (!_allParametersExists(FactSystem::defaultComponentId, usedParams)) {
return;
}
_init();
_validateConfiguration();
connect(_vehicle, &Vehicle::rcChannelsChanged, this, &PX4AdvancedFlightModesController::_rcChannelsChanged);
}
......@@ -96,20 +97,17 @@ void PX4AdvancedFlightModesController::_init(void)
// Auto mode is visible if Mission/Loiter are on separate channel from main Mode switch
_autoModeVisible = loiterChannel != modeChannel;
}
// Setup the channel combobox model
QList<int> usedChannels;
QStringList attitudeParams;
attitudeParams << "RC_MAP_THROTTLE" << "RC_MAP_YAW" << "RC_MAP_PITCH" << "RC_MAP_ROLL" << "RC_MAP_FLAPS" << "RC_MAP_AUX1" << "RC_MAP_AUX2";
foreach(const QString &attitudeParam, attitudeParams) {
QVector<int> usedChannels;
for (const QString &attitudeParam : {"RC_MAP_THROTTLE", "RC_MAP_YAW", "RC_MAP_PITCH", "RC_MAP_ROLL", "RC_MAP_FLAPS", "RC_MAP_AUX1", "RC_MAP_AUX2"}) {
int channel = getParameterFact(-1, attitudeParam)->rawValue().toInt();
if (channel != 0) {
usedChannels << channel;
}
}
_channelListModel << "Disabled";
_channelListModelChannel << 0;
for (int channel=1; channel<=_channelCount; channel++) {
......
......@@ -43,25 +43,19 @@ bool PX4RadioComponent::setupComplete(void) const
if (_vehicle->parameterManager()->getParameter(-1, "COM_RC_IN_MODE")->rawValue().toInt() != 1) {
// The best we can do to detect the need for a radio calibration is look for attitude
// controls to be mapped.
QStringList attitudeMappings;
attitudeMappings << "RC_MAP_ROLL" << "RC_MAP_PITCH" << "RC_MAP_YAW" << "RC_MAP_THROTTLE";
foreach(const QString &mapParam, attitudeMappings) {
for(const QString &mapParam : {"RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE"}) {
if (_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, mapParam)->rawValue().toInt() == 0) {
return false;
}
}
}
return true;
}
QStringList PX4RadioComponent::setupCompleteChangedTriggerList(void) const
{
QStringList triggers;
triggers << "COM_RC_IN_MODE" << "RC_MAP_ROLL" << "RC_MAP_PITCH" << "RC_MAP_YAW" << "RC_MAP_THROTTLE";
return triggers;
return {"COM_RC_IN_MODE", "RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE"};
}
QUrl PX4RadioComponent::setupSource(void) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment