Unverified Commit f6fa7ba2 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7419 from DonLakeFlyer/SaferSimpleMode

ArduPilot: Flight Mode setup - Safer handling of missing params
parents 40ebdbc2 d872da76
......@@ -16,13 +16,15 @@
bool APMFlightModesComponentController::_typeRegistered = false;
const char* APMFlightModesComponentController::_simpleParamName = "SIMPLE";
const char* APMFlightModesComponentController::_superSimpleParamName = "SUPER_SIMPLE";
APMFlightModesComponentController::APMFlightModesComponentController(void)
: _rover (_vehicle->rover())
, _activeFlightMode (0)
: _activeFlightMode (0)
, _channelCount (Vehicle::cMaxRcChannels)
, _simpleMode (SimpleModeStandard)
, _simpleModeFact (_rover ? nullptr : getParameterFact(-1, "SIMPLE"))
, _superSimpleModeFact (_rover ? nullptr : getParameterFact(-1, "SUPER_SIMPLE"))
, _simpleModeFact (parameterExists(-1, _simpleParamName) ? getParameterFact(-1, _simpleParamName) : nullptr)
, _superSimpleModeFact (parameterExists(-1, _superSimpleParamName) ? getParameterFact(-1, _superSimpleParamName) : nullptr)
, _simpleModesSupported (_simpleModeFact && _superSimpleModeFact)
{
if (!_typeRegistered) {
......@@ -38,7 +40,7 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
_superSimpleModeEnabled.append(QVariant(false));
}
if (!_rover) {
if (_simpleModesSupported) {
_setupSimpleModeEnabled();
uint8_t simpleModeValue = static_cast<uint8_t>(_simpleModeFact->rawValue().toUInt());
......
......@@ -67,7 +67,6 @@ private slots:
void _setupSimpleModeEnabled (void);
private:
bool _rover;
QString _modeParamPrefix;
QString _modeChannelParam;
int _activeFlightMode;
......@@ -86,6 +85,9 @@ private:
static const int _cSimpleModeBits = 8;
static const int _cFltModes = 6;
static const char* _simpleParamName;
static const char* _superSimpleParamName;
static bool _typeRegistered;
};
......
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