1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

LP-245 config: don't save HWSettings twice

This commit is contained in:
Philippe Renon 2016-09-20 01:44:26 +02:00 committed by Philippe Renon
parent f930e85175
commit b32ec8b9e9
3 changed files with 15 additions and 33 deletions

View File

@ -29,8 +29,6 @@
#include "ui_configrevohwwidget.h"
#include <uavobjecthelper.h>
#include "hwsettings.h"
#include <QDebug>
@ -102,21 +100,17 @@ void ConfigRevoHWWidget::refreshWidgetsValuesImpl(UAVObject *obj)
void ConfigRevoHWWidget::updateObjectsFromWidgetsImpl()
{
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
HwSettings::DataFields data = hwSettings->getData();
// 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)) {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_ENABLED;
} else {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_DISABLED;
enableModule = HwSettings::OPTIONALMODULES_ENABLED;
}
UAVObjectUpdaterHelper updateHelper;
hwSettings->setData(data, false);
updateHelper.doObjectAndWait(hwSettings);
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_GPS, enableModule);
}
void ConfigRevoHWWidget::usbVCPPortChanged(int index)

View File

@ -29,8 +29,6 @@
#include "ui_configrevonanohwwidget.h"
#include <uavobjecthelper.h>
#include "hwsettings.h"
#include <QDebug>
@ -94,21 +92,17 @@ void ConfigRevoNanoHWWidget::refreshWidgetsValuesImpl(UAVObject *obj)
void ConfigRevoNanoHWWidget::updateObjectsFromWidgetsImpl()
{
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
HwSettings::DataFields data = hwSettings->getData();
// 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)) {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_ENABLED;
} else {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_DISABLED;
enableModule = HwSettings::OPTIONALMODULES_ENABLED;
}
UAVObjectUpdaterHelper updateHelper;
hwSettings->setData(data, false);
updateHelper.doObjectAndWait(hwSettings);
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_GPS, enableModule);
}
void ConfigRevoNanoHWWidget::usbVCPPortChanged(int index)

View File

@ -29,8 +29,6 @@
#include "ui_configsparky2hwwidget.h"
#include <uavobjecthelper.h>
#include "hwsettings.h"
#include <QDebug>
@ -97,21 +95,17 @@ void ConfigSparky2HWWidget::refreshWidgetsValuesImpl(UAVObject *obj)
void ConfigSparky2HWWidget::updateObjectsFromWidgetsImpl()
{
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
HwSettings::DataFields data = hwSettings->getData();
// 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)) {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_ENABLED;
} else {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_DISABLED;
enableModule = HwSettings::OPTIONALMODULES_ENABLED;
}
UAVObjectUpdaterHelper updateHelper;
hwSettings->setData(data, false);
updateHelper.doObjectAndWait(hwSettings);
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_GPS, enableModule);
}
void ConfigSparky2HWWidget::usbVCPPortChanged(int index)