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

OP-532 Started with GUI configuration save to OP hardware

This commit is contained in:
Andrew Thoms 2011-06-13 20:46:53 -04:00
parent c8939e6e4f
commit 651c65ad84
2 changed files with 51 additions and 21 deletions

View File

@ -46,6 +46,7 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent)
SwashLvlConfigurationInProgress=0;
SwashLvlState=0;
SwashLvlServoInterlock=0;
updatingFromHardware=FALSE;
// Now connect the widget to the ManualControlCommand / Channel UAVObject
//ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
@ -241,9 +242,9 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent)
connect(m_ccpm->SwashLvlCancelButton, SIGNAL(clicked()), this, SLOT(SwashLvlCancelButtonPressed()));
connect(m_ccpm->SwashLvlFinishButton, SIGNAL(clicked()), this, SLOT(SwashLvlFinishButtonPressed()));
connect(m_ccpm->ccpmCollectivePassthrough, SIGNAL(clicked()), this, SLOT(UpdatCCPMUIOptions()));
connect(m_ccpm->ccpmLinkCyclic, SIGNAL(clicked()), this, SLOT(UpdatCCPMUIOptions()));
connect(m_ccpm->ccpmLinkRoll, SIGNAL(clicked()), this, SLOT(UpdatCCPMUIOptions()));
connect(m_ccpm->ccpmCollectivePassthrough, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities()));
connect(m_ccpm->ccpmLinkCyclic, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities()));
connect(m_ccpm->ccpmLinkRoll, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities()));
@ -264,6 +265,7 @@ void ConfigccpmWidget::UpdateType()
double AdjustmentAngle=0;
UpdatCCPMUIOptions();
SetUIComponentVisibilities();
TypeInt = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1;
TypeText = m_ccpm->ccpmType->currentText();
@ -846,28 +848,36 @@ void ConfigccpmWidget::UpdateMixer()
*/
void ConfigccpmWidget::UpdatCCPMUIOptions()
{
int ccpmCollectivePassthroughState;
int ccpmLinkCyclicState;
int ccpmLinkRollState;
if (updatingFromHardware) return;
//get the user options
ccpmCollectivePassthroughState=m_ccpm->ccpmCollectivePassthrough->isChecked();
ccpmLinkCyclicState=m_ccpm->ccpmLinkCyclic->isChecked();
ccpmLinkRollState=m_ccpm->ccpmLinkRoll->isChecked();
//swashplate config
ccpmGUISettings.SwasplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1;
ccpmGUISettings.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();
}
void ConfigccpmWidget::SetUIComponentVisibilities()
{
UpdatCCPMUIOptions();
//set which sliders are user...
m_ccpm->ccpmRevoMixingBox->setVisible(0);
m_ccpm->ccpmPitchMixingBox->setVisible(!ccpmCollectivePassthroughState&&ccpmLinkCyclicState);
m_ccpm->ccpmCollectiveScalingBox->setVisible(ccpmCollectivePassthroughState||!ccpmLinkCyclicState);
m_ccpm->ccpmPitchMixingBox->setVisible(!ccpmGUISettings.ccpmCollectivePassthroughState && ccpmGUISettings.ccpmLinkCyclicState);
m_ccpm->ccpmCollectiveScalingBox->setVisible(ccpmGUISettings.ccpmCollectivePassthroughState || !ccpmGUISettings.ccpmLinkCyclicState);
m_ccpm->ccpmCollectiveChLabel->setVisible(ccpmCollectivePassthroughState);
m_ccpm->ccpmCollectiveChannel->setVisible(ccpmCollectivePassthroughState);
m_ccpm->ccpmCollectiveChLabel->setVisible(ccpmGUISettings.ccpmCollectivePassthroughState);
m_ccpm->ccpmCollectiveChannel->setVisible(ccpmGUISettings.ccpmCollectivePassthroughState);
m_ccpm->ccpmLinkCyclic->setVisible(!ccpmCollectivePassthroughState);
m_ccpm->ccpmLinkCyclic->setVisible(!ccpmGUISettings.ccpmCollectivePassthroughState);
m_ccpm->ccpmCyclicScalingBox->setVisible((ccpmCollectivePassthroughState||!ccpmLinkCyclicState)&&ccpmLinkRollState);
if (!ccpmCollectivePassthroughState&&ccpmLinkCyclicState)
m_ccpm->ccpmCyclicScalingBox->setVisible((ccpmGUISettings.ccpmCollectivePassthroughState || !ccpmGUISettings.ccpmLinkCyclicState) && ccpmGUISettings.ccpmLinkRollState);
if (!ccpmGUISettings.ccpmCollectivePassthroughState && ccpmGUISettings.ccpmLinkCyclicState)
{
m_ccpm->ccpmPitchScalingBox->setVisible(0);
m_ccpm->ccpmRollScalingBox->setVisible(0);
@ -876,8 +886,8 @@ void ConfigccpmWidget::UpdatCCPMUIOptions()
}
else
{
m_ccpm->ccpmPitchScalingBox->setVisible(!ccpmLinkRollState);
m_ccpm->ccpmRollScalingBox->setVisible(!ccpmLinkRollState);
m_ccpm->ccpmPitchScalingBox->setVisible(!ccpmGUISettings.ccpmLinkRollState);
m_ccpm->ccpmRollScalingBox->setVisible(!ccpmGUISettings.ccpmLinkRollState);
m_ccpm->ccpmLinkRoll->setVisible(1);
}
@ -898,7 +908,8 @@ void ConfigccpmWidget::requestccpmUpdate()
int isCCPM=0;
if (SwashLvlConfigurationInProgress)return;
updatingFromHardware=TRUE;
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
int i,j;
@ -1151,6 +1162,7 @@ void ConfigccpmWidget::requestccpmUpdate()
updatingFromHardware=FALSE;
ccpmSwashplateUpdate();

View File

@ -49,6 +49,20 @@ typedef struct {
int Min[CCPM_MAX_SWASH_SERVOS];
} SwashplateServoSettingsStruct;
typedef struct {
uint SwasplateType:3;
uint FirstServoIndex:2;
uint CorrectionAngle:9;
uint ccpmCollectivePassthroughState:1;
uint ccpmLinkCyclicState:1;
uint ccpmLinkRollState:1;
uint CollectiveChannel:3;
uint padding:12;
uint padding2:32;
} __attribute__((packed)) ccpmGUISettingsStruct;
class ConfigccpmWidget: public ConfigTaskWidget
{
Q_OBJECT
@ -82,10 +96,13 @@ private:
SwashplateServoSettingsStruct oldSwashLvlConfiguration;
SwashplateServoSettingsStruct newSwashLvlConfiguration;
ccpmGUISettingsStruct ccpmGUISettings;
int MixerChannelData[6];
int ShowDisclaimer(int messageID);
virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget
bool updatingFromHardware;
private slots:
void ccpmSwashplateUpdate();
@ -105,6 +122,7 @@ private:
void SwashLvlFinishButtonPressed();
void UpdatCCPMUIOptions();
void SetUIComponentVisibilities();
void enableSwashplateLevellingControl(bool state);
void setSwashplateLevel(int percent);