From 23f9dc42cc4ed475221c8c1145a84be8252ee6a2 Mon Sep 17 00:00:00 2001 From: Andrew Thoms Date: Mon, 13 Jun 2011 21:40:39 -0400 Subject: [PATCH] OP-532 Created union of struct to assist in type casting of GUI settings to UAVObject --- .../src/plugins/config/configccpmwidget.cpp | 28 +++++++++---------- .../src/plugins/config/configccpmwidget.h | 8 ++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/configccpmwidget.cpp index 7eff8e623..d9eb5c465 100644 --- a/ground/openpilotgcs/src/plugins/config/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configccpmwidget.cpp @@ -851,13 +851,13 @@ void ConfigccpmWidget::UpdatCCPMUIOptions() if (updatingFromHardware) return; //get the user options //swashplate config - ccpmGUISettings.SwasplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; - ccpmGUISettings.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex(); + GUIConfigData.heli.SwasplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; + GUIConfigData.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex(); //ccpm mixing options - ccpmGUISettings.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked(); - ccpmGUISettings.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked(); - ccpmGUISettings.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked(); + GUIConfigData.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked(); + GUIConfigData.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked(); + GUIConfigData.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked(); } @@ -868,16 +868,16 @@ void ConfigccpmWidget::SetUIComponentVisibilities() //set which sliders are user... m_ccpm->ccpmRevoMixingBox->setVisible(0); - m_ccpm->ccpmPitchMixingBox->setVisible(!ccpmGUISettings.ccpmCollectivePassthroughState && ccpmGUISettings.ccpmLinkCyclicState); - m_ccpm->ccpmCollectiveScalingBox->setVisible(ccpmGUISettings.ccpmCollectivePassthroughState || !ccpmGUISettings.ccpmLinkCyclicState); + m_ccpm->ccpmPitchMixingBox->setVisible(!GUIConfigData.heli.ccpmCollectivePassthroughState && GUIConfigData.heli.ccpmLinkCyclicState); + m_ccpm->ccpmCollectiveScalingBox->setVisible(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState); - m_ccpm->ccpmCollectiveChLabel->setVisible(ccpmGUISettings.ccpmCollectivePassthroughState); - m_ccpm->ccpmCollectiveChannel->setVisible(ccpmGUISettings.ccpmCollectivePassthroughState); + m_ccpm->ccpmCollectiveChLabel->setVisible(GUIConfigData.heli.ccpmCollectivePassthroughState); + m_ccpm->ccpmCollectiveChannel->setVisible(GUIConfigData.heli.ccpmCollectivePassthroughState); - m_ccpm->ccpmLinkCyclic->setVisible(!ccpmGUISettings.ccpmCollectivePassthroughState); + m_ccpm->ccpmLinkCyclic->setVisible(!GUIConfigData.heli.ccpmCollectivePassthroughState); - m_ccpm->ccpmCyclicScalingBox->setVisible((ccpmGUISettings.ccpmCollectivePassthroughState || !ccpmGUISettings.ccpmLinkCyclicState) && ccpmGUISettings.ccpmLinkRollState); - if (!ccpmGUISettings.ccpmCollectivePassthroughState && ccpmGUISettings.ccpmLinkCyclicState) + m_ccpm->ccpmCyclicScalingBox->setVisible((GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState) && GUIConfigData.heli.ccpmLinkRollState); + if (!GUIConfigData.heli.ccpmCollectivePassthroughState && GUIConfigData.heli.ccpmLinkCyclicState) { m_ccpm->ccpmPitchScalingBox->setVisible(0); m_ccpm->ccpmRollScalingBox->setVisible(0); @@ -886,8 +886,8 @@ void ConfigccpmWidget::SetUIComponentVisibilities() } else { - m_ccpm->ccpmPitchScalingBox->setVisible(!ccpmGUISettings.ccpmLinkRollState); - m_ccpm->ccpmRollScalingBox->setVisible(!ccpmGUISettings.ccpmLinkRollState); + m_ccpm->ccpmPitchScalingBox->setVisible(!GUIConfigData.heli.ccpmLinkRollState); + m_ccpm->ccpmRollScalingBox->setVisible(!GUIConfigData.heli.ccpmLinkRollState); m_ccpm->ccpmLinkRoll->setVisible(1); } diff --git a/ground/openpilotgcs/src/plugins/config/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/configccpmwidget.h index a79c016e1..8140f175d 100644 --- a/ground/openpilotgcs/src/plugins/config/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configccpmwidget.h @@ -61,7 +61,11 @@ typedef struct { uint padding2:32; } __attribute__((packed)) ccpmGUISettingsStruct; - +typedef union +{ + uint UAVObject; + ccpmGUISettingsStruct heli; +} GUIConfigDataUnion; class ConfigccpmWidget: public ConfigTaskWidget { @@ -96,7 +100,7 @@ private: SwashplateServoSettingsStruct oldSwashLvlConfiguration; SwashplateServoSettingsStruct newSwashLvlConfiguration; - ccpmGUISettingsStruct ccpmGUISettings; + GUIConfigDataUnion GUIConfigData; int MixerChannelData[6]; int ShowDisclaimer(int messageID);