Skip to content

Commit

Permalink
Fix Unique Flight Modes Only
Browse files Browse the repository at this point in the history
  • Loading branch information
bytesByHarsh committed Jan 9, 2025
1 parent 0085c5c commit fa986ee
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
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

0 comments on commit fa986ee

Please sign in to comment.