mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
LP-245 config: simplify access to HWSettings
This commit is contained in:
parent
b32ec8b9e9
commit
80e2bd72e9
@ -84,9 +84,8 @@ ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
// Add Gps protocol configuration
|
||||
|
||||
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||
|
||||
if (hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_GPS] != HwSettings::OPTIONALMODULES_ENABLED) {
|
||||
if (hwSettings->getOptionalModules(HwSettings::OPTIONALMODULES_GPS) != HwSettings::OPTIONALMODULES_ENABLED) {
|
||||
m_telemetry->gpsProtocol->setEnabled(false);
|
||||
m_telemetry->gpsProtocol->setToolTip(tr("Enable GPS module and reboot the board to be able to select GPS protocol"));
|
||||
} else {
|
||||
|
@ -157,18 +157,17 @@ void ConfigAutotuneWidget::refreshWidgetsValuesImpl(UAVObject *obj)
|
||||
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||
|
||||
if (obj == hwSettings) {
|
||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||
m_autotune->enableAutoTune->setChecked(
|
||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_AUTOTUNE] == HwSettings::OPTIONALMODULES_ENABLED);
|
||||
bool enabled = (hwSettings->getOptionalModules(HwSettings::OPTIONALMODULES_AUTOTUNE) == HwSettings::OPTIONALMODULES_ENABLED);
|
||||
m_autotune->enableAutoTune->setChecked(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigAutotuneWidget::updateObjectsFromWidgetsImpl()
|
||||
{
|
||||
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||
|
||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_AUTOTUNE] =
|
||||
m_autotune->enableAutoTune->isChecked() ? HwSettings::OPTIONALMODULES_ENABLED : HwSettings::OPTIONALMODULES_DISABLED;
|
||||
hwSettings->setData(hwSettingsData);
|
||||
quint8 enableModule = (m_autotune->enableAutoTune->isChecked()) ? HwSettings::OPTIONALMODULES_ENABLED : HwSettings::OPTIONALMODULES_DISABLED;
|
||||
|
||||
hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_AUTOTUNE, enableModule);
|
||||
;
|
||||
}
|
||||
|
@ -107,10 +107,9 @@ void ConfigCameraStabilizationWidget::refreshWidgetsValuesImpl(UAVObject *obj)
|
||||
// It needs special processing because ConfigTaskWidget uses TRUE/FALSE
|
||||
// for QCheckBox, but OptionalModules uses Enabled/Disabled enum values.
|
||||
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||
|
||||
ui->enableCameraStabilization->setChecked(
|
||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED);
|
||||
hwSettings->getOptionalModules(HwSettings::OPTIONALMODULES_CAMERASTAB) == HwSettings::OPTIONALMODULES_ENABLED);
|
||||
|
||||
// Load mixer outputs which are mapped to camera controls
|
||||
MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
|
||||
@ -243,18 +242,6 @@ void ConfigCameraStabilizationWidget::defaultRequestedSlot(int group)
|
||||
{
|
||||
Q_UNUSED(group);
|
||||
|
||||
// Here is the example of how to reset the state of QCheckBox. It is
|
||||
// commented out because we normally don't want to reset the module
|
||||
// enable state to default "disabled" (or we don't care about values at all).
|
||||
// But if you want, you could use the dirtyClone() function to get default
|
||||
// values of an object and then use them to set a widget state.
|
||||
//
|
||||
// HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||
// HwSettings *hwSettingsDefault=(HwSettings*)hwSettings->dirtyClone();
|
||||
// HwSettings::DataFields hwSettingsData = hwSettingsDefault->getData();
|
||||
// m_camerastabilization->enableCameraStabilization->setChecked(
|
||||
// hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED);
|
||||
|
||||
// For outputs we set them all to none, so don't use any UAVObject to get defaults
|
||||
QComboBox *outputs[] = {
|
||||
ui->rollChannel,
|
||||
|
@ -108,10 +108,9 @@ void ConfigTxPIDWidget::refreshWidgetsValuesImpl(UAVObject *obj)
|
||||
// It needs special processing because ConfigTaskWidget uses TRUE/FALSE
|
||||
// for QCheckBox, but OptionalModules uses Enabled/Disabled enum values.
|
||||
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
|
||||
HwSettings::DataFields hwSettingsData = hwSettings->getData();
|
||||
|
||||
m_txpid->TxPIDEnable->setChecked(
|
||||
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_TXPID] == HwSettings::OPTIONALMODULES_ENABLED);
|
||||
hwSettings->getOptionalModules(HwSettings::OPTIONALMODULES_TXPID) == HwSettings::OPTIONALMODULES_ENABLED);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user