|
|
|
@ -32,8 +32,6 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
@@ -32,8 +32,6 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
|
|
|
|
|
: _activeFlightMode(0) |
|
|
|
|
, _channelCount(Vehicle::cMaxRcChannels) |
|
|
|
|
, _fixedWing(_vehicle->vehicleType() == MAV_TYPE_FIXED_WING) |
|
|
|
|
, _flightModeChannel(5) |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
QStringList usedParams; |
|
|
|
|
usedParams << QStringLiteral("FLTMODE1") << QStringLiteral("FLTMODE2") << QStringLiteral("FLTMODE3") |
|
|
|
@ -42,10 +40,6 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
@@ -42,10 +40,6 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (parameterExists(FactSystem::defaultComponentId, QStringLiteral("FLTMODE_CH"))) { |
|
|
|
|
_flightModeChannel = getParameterFact(FactSystem::defaultComponentId, QStringLiteral("FLTMODE_CH"))->rawValue().toInt(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_rgChannelOptionEnabled << QVariant(false) << QVariant(false) << QVariant(false) << QVariant(false) << QVariant(false) << QVariant(false); |
|
|
|
|
|
|
|
|
|
connect(_vehicle, &Vehicle::rcChannelsChanged, this, &APMFlightModesComponentController::_rcChannelsChanged); |
|
|
|
@ -54,12 +48,18 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
@@ -54,12 +48,18 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
|
|
|
|
|
/// Connected to Vehicle::rcChannelsChanged signal
|
|
|
|
|
void APMFlightModesComponentController::_rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels]) |
|
|
|
|
{ |
|
|
|
|
if (_flightModeChannel > channelCount) { |
|
|
|
|
int flightModeChannel = 4; |
|
|
|
|
|
|
|
|
|
if (parameterExists(FactSystem::defaultComponentId, QStringLiteral("FLTMODE_CH"))) { |
|
|
|
|
flightModeChannel = getParameterFact(FactSystem::defaultComponentId, QStringLiteral("FLTMODE_CH"))->rawValue().toInt() - 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (flightModeChannel >= channelCount) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_activeFlightMode = 0; |
|
|
|
|
int channelValue = pwmValues[_flightModeChannel - 1]; |
|
|
|
|
int channelValue = pwmValues[flightModeChannel]; |
|
|
|
|
if (channelValue != -1) { |
|
|
|
|
bool found = false; |
|
|
|
|
int rgThreshold[] = { 1230, 1360, 1490, 1620, 1749 }; |
|
|
|
|