From 15c2e619e53c9d3441abf6545c2573a942d2a57b Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 11 Feb 2018 21:29:33 +0100 Subject: [PATCH] LP-577 Ignore disabling GPS module for boards where the module is already built in. --- .../src/plugins/config/configrevohwwidget.cpp | 16 +++++++--------- .../plugins/config/configrevonanohwwidget.cpp | 16 +++++++--------- .../src/plugins/config/configsparky2hwwidget.cpp | 16 +++++++--------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/ground/gcs/src/plugins/config/configrevohwwidget.cpp b/ground/gcs/src/plugins/config/configrevohwwidget.cpp index 5cf2c7017..acfcea59a 100644 --- a/ground/gcs/src/plugins/config/configrevohwwidget.cpp +++ b/ground/gcs/src/plugins/config/configrevohwwidget.cpp @@ -108,16 +108,14 @@ void ConfigRevoHWWidget::refreshWidgetsValuesImpl(UAVObject *obj) void ConfigRevoHWWidget::updateObjectsFromWidgetsImpl() { // If any port is configured to be GPS port, enable GPS module if it is not enabled. - // Otherwise disable GPS module. - quint8 enableModule = HwSettings::OPTIONALMODULES_DISABLED; - - if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS) - || isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS)) { - enableModule = HwSettings::OPTIONALMODULES_ENABLED; - } - + // GPS module will be already built in for Revo board, keep this check just in case. HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); - hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_GPS, enableModule); + + if ((hwSettings->optionalModulesGPS() == HwSettings_OptionalModules::Disabled) && + (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS) || + isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS))) { + hwSettings->setOptionalModulesGPS(HwSettings_OptionalModules::Enabled); + } } void ConfigRevoHWWidget::usbVCPPortChanged(int index) diff --git a/ground/gcs/src/plugins/config/configrevonanohwwidget.cpp b/ground/gcs/src/plugins/config/configrevonanohwwidget.cpp index 064606cba..ec5b8ead9 100644 --- a/ground/gcs/src/plugins/config/configrevonanohwwidget.cpp +++ b/ground/gcs/src/plugins/config/configrevonanohwwidget.cpp @@ -98,16 +98,14 @@ void ConfigRevoNanoHWWidget::refreshWidgetsValuesImpl(UAVObject *obj) void ConfigRevoNanoHWWidget::updateObjectsFromWidgetsImpl() { // If any port is configured to be GPS port, enable GPS module if it is not enabled. - // Otherwise disable GPS module. - quint8 enableModule = HwSettings::OPTIONALMODULES_DISABLED; - - if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS) - || isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS)) { - enableModule = HwSettings::OPTIONALMODULES_ENABLED; - } - + // GPS module will be already built in for RevoNano board, keep this check just in case. HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); - hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_GPS, enableModule); + + if ((hwSettings->optionalModulesGPS() == HwSettings_OptionalModules::Disabled) && + (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS) || + isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS))) { + hwSettings->setOptionalModulesGPS(HwSettings_OptionalModules::Enabled); + } } void ConfigRevoNanoHWWidget::usbVCPPortChanged(int index) diff --git a/ground/gcs/src/plugins/config/configsparky2hwwidget.cpp b/ground/gcs/src/plugins/config/configsparky2hwwidget.cpp index bb98db062..e5be4f599 100644 --- a/ground/gcs/src/plugins/config/configsparky2hwwidget.cpp +++ b/ground/gcs/src/plugins/config/configsparky2hwwidget.cpp @@ -103,16 +103,14 @@ void ConfigSparky2HWWidget::refreshWidgetsValuesImpl(UAVObject *obj) void ConfigSparky2HWWidget::updateObjectsFromWidgetsImpl() { // If any port is configured to be GPS port, enable GPS module if it is not enabled. - // Otherwise disable GPS module. - quint8 enableModule = HwSettings::OPTIONALMODULES_DISABLED; - - if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::SPK2_FLEXIPORT_GPS) - || isComboboxOptionSelected(m_ui->cbMain, HwSettings::SPK2_MAINPORT_GPS)) { - enableModule = HwSettings::OPTIONALMODULES_ENABLED; - } - + // GPS will be already built in for Sparky2 board, keep this check just in case. HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); - hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_GPS, enableModule); + + if ((hwSettings->optionalModulesGPS() == HwSettings_OptionalModules::Disabled) && + (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS) || + isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS))) { + hwSettings->setOptionalModulesGPS(HwSettings_OptionalModules::Enabled); + } } void ConfigSparky2HWWidget::usbVCPPortChanged(int index)