Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unique Flight Modes Only #12311

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ArduCopterFirmwarePlugin : public APMFirmwarePlugin
QString autoDisarmParameter (Vehicle* vehicle) override { Q_UNUSED(vehicle); return QStringLiteral("DISARM_DELAY"); }
bool supportsSmartRTL (void) const override { return true; }

void updateAvailableFlightModes (FlightModeList modeList) final;
void updateAvailableFlightModes (FlightModeList modeList) override;
protected:
uint32_t _convertToCustomFlightModeEnum(uint32_t val) const override;

Expand Down
2 changes: 1 addition & 1 deletion src/FirmwarePlugin/APM/ArduPlaneFirmwarePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ArduPlaneFirmwarePlugin : public APMFirmwarePlugin
const FirmwarePlugin::remapParamNameMajorVersionMap_t& paramNameRemapMajorVersionMap(void) const final { return _remapParamName; }

QString stabilizedFlightMode (void) const override;
void updateAvailableFlightModes (FlightModeList modeList) final;
void updateAvailableFlightModes (FlightModeList modeList) override;

protected:
uint32_t _convertToCustomFlightModeEnum(uint32_t val) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/FirmwarePlugin/APM/ArduRoverFirmwarePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ArduRoverFirmwarePlugin : public APMFirmwarePlugin
QString offlineEditingParamFile (Vehicle* vehicle) override { Q_UNUSED(vehicle); return QStringLiteral(":/FirmwarePlugin/APM/Rover.OfflineEditing.params"); }

QString stabilizedFlightMode (void) const override;
void updateAvailableFlightModes (FlightModeList modeList) final;
void updateAvailableFlightModes (FlightModeList modeList) override;

protected:
uint32_t _convertToCustomFlightModeEnum(uint32_t val) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ArduSubFirmwarePlugin : public APMFirmwarePlugin

QString stabilizedFlightMode (void) const override;
QString motorDetectionFlightMode (void) const override;
void updateAvailableFlightModes (FlightModeList modeList) final;
void updateAvailableFlightModes (FlightModeList modeList) override;

protected:
uint32_t _convertToCustomFlightModeEnum(uint32_t val) const override;
Expand Down
13 changes: 12 additions & 1 deletion src/FirmwarePlugin/FirmwarePlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,17 @@ void FirmwarePlugin::_updateModeMappings(FlightModeList &modeList){
_modeEnumToString[mode.custom_mode] = nModeName;
}
mode.mode_name = nModeName;
_availableFlightModeList += mode;
_addNewFlightMode(mode);
}
}

void FirmwarePlugin::_addNewFlightMode(FirmwareFlightMode &mode)
{
for(auto &m:_availableFlightModeList){
if(m.custom_mode == mode.custom_mode){
// Already Exist
return;
}
}
_availableFlightModeList += mode;
}
1 change: 1 addition & 0 deletions src/FirmwarePlugin/FirmwarePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ class FirmwarePlugin : public QObject

// Update internal mappings for a list of flight modes
void _updateModeMappings(FlightModeList &modeList);
void _addNewFlightMode (FirmwareFlightMode &mode);

FlightModeList _availableFlightModeList;
FlightModeCustomModeMap _modeEnumToString;
Expand Down
Loading