1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

Finished the new input configuration wizard. Fixed some bugs along the way.

Sending it for review now.
This commit is contained in:
zedamota 2011-08-17 12:43:08 +01:00
parent 6a103ed332
commit 0a0d405fc1
8 changed files with 78 additions and 7 deletions

View File

@ -163,3 +163,10 @@ void ConfigCCAttitudeWidget::openHelp()
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/CopterControl+Attitude+Configuration", QUrl::StrictMode) );
}
void ConfigCCAttitudeWidget::enableControls(bool enable)
{
if(ui->zeroBias)
ui->zeroBias->setEnabled(enable);
ConfigTaskWidget::enableControls(enable);
}

View File

@ -66,6 +66,8 @@ private:
static const int NUM_ACCEL_UPDATES = 60;
static const float ACCEL_SCALE = 0.004f * 9.81f;
protected:
virtual void enableControls(bool enable);
};

View File

@ -117,6 +117,15 @@ void ConfigGadgetWidget::resizeEvent(QResizeEvent *event)
}
void ConfigGadgetWidget::onAutopilotDisconnect() {
ftw->setCurrentIndex(ConfigGadgetWidget::hardware);
ftw->removeTab(ConfigGadgetWidget::ins);
QWidget *qwd = new DefaultAttitudeWidget(this);
ftw->insertTab(ConfigGadgetWidget::ins, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS"));
ftw->removeTab(ConfigGadgetWidget::hardware);
qwd = new DefaultHwSettingsWidget(this);
ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.png"), QString("HW Settings"));
ftw->setCurrentIndex(ConfigGadgetWidget::hardware);
emit autopilotDisconnected();
}

View File

@ -45,7 +45,7 @@
#define STICK_MIN_MOVE -8
#define STICK_MAX_MOVE 8
ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent),wizardStep(wizardWelcome),loop(NULL),skipflag(false)
ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent),wizardStep(wizardWelcome),loop(NULL),skipflag(false),goWizard(NULL)
{
manualCommandObj = ManualControlCommand::GetInstance(getObjectManager());
manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager());
@ -68,7 +68,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMax",inp->ui->channelMax,index);
++index;
}
QPushButton * goWizard=new QPushButton(tr("Start Wizard"),this);
goWizard=new QPushButton(tr("Start Wizard"),this);
m_config->advancedPage->layout()->addWidget(goWizard);
connect(goWizard,SIGNAL(clicked()),this,SLOT(goToWizard()));
connect(m_config->wzNext,SIGNAL(clicked()),this,SLOT(wzNext()));
@ -92,6 +92,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
addUAVObjectToWidgetRelation("ManualControlSettings","Arming",m_config->armControl);
addUAVObjectToWidgetRelation("ManualControlSettings","armTimeout",m_config->armTimeout,0,1000);
addWidget(goWizard);
enableControls(false);
populateWidgets();
@ -258,6 +260,7 @@ void ConfigInputWidget::goToWizard()
void ConfigInputWidget::wzCancel()
{
dimOtherControls(false);
manualCommandObj->setMetadata(manualCommandObj->getDefaultMetadata());
m_config->stackedWidget->setCurrentIndex(0);
foreach (QWidget * wd, extraWidgets)
@ -305,6 +308,7 @@ void ConfigInputWidget::setupWizardWidget(int step)
{
if(step==wizardWelcome)
{
m_config->graphicsView->setVisible(false);
setTxMovement(nothing);
if(wizardStep==wizardChooseMode)
{
@ -317,7 +321,8 @@ void ConfigInputWidget::setupWizardWidget(int step)
manualSettingsObj->setData(manualSettingsData);
m_config->wzText->setText(tr("Welcome to the inputs configuration wizard.\n"
"Please follow the instruction on the screen and only move your controls when asked to.\n"
"At any time you can press 'back' to return to the previous screeen or 'Cancel' to cancel the wizard"
"Make sure you already configured your hardware settings on the proper tab and restarted your board.\n"
"At any time you can press 'back' to return to the previous screeen or 'Cancel' to cancel the wizard \n"
"For your safety your arming setting is now 'Always Disarmed' please reenable it after this wizard."));
m_config->stackedWidget->setCurrentIndex(1);
m_config->wzBack->setEnabled(false);
@ -325,6 +330,7 @@ void ConfigInputWidget::setupWizardWidget(int step)
}
else if(step==wizardChooseMode)
{
m_config->graphicsView->setVisible(true);
setTxMovement(nothing);
if(wizardStep==wizardIdentifySticks)
{
@ -384,6 +390,7 @@ void ConfigInputWidget::setupWizardWidget(int step)
}
else if(step==wizardIdentifyLimits)
{
dimOtherControls(false);
setTxMovement(moveAll);
if(wizardStep==wizardIdentifyCenter)
{
@ -396,6 +403,13 @@ void ConfigInputWidget::setupWizardWidget(int step)
}
manualSettingsObj->setData(manualSettingsData);
}
foreach (QWidget * wd, extraWidgets)
{
if(wd)
delete wd;
}
extraWidgets.clear();
disconnect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
wizardStep=wizardIdentifyLimits;
m_config->wzText->setText(QString(tr("Please move all controls to their maximum extends on both directions and press next when ready")));
UAVObject::Metadata mdata= manualCommandObj->getMetadata();
@ -412,6 +426,7 @@ void ConfigInputWidget::setupWizardWidget(int step)
}
else if(step==wizardIdentifyInverted)
{
dimOtherControls(true);
setTxMovement(nothing);
if(wizardStep==wizardIdentifyLimits)
{
@ -644,6 +659,7 @@ void ConfigInputWidget::setTxMovement(txMovements movement)
animate->start(50);
break;
case nothing:
movePos=0;
animate->stop();
break;
default:
@ -840,14 +856,34 @@ void ConfigInputWidget::moveSticks()
trans=m_txLeftStickOrig;
m_txLeftStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
trans=m_txRightStickOrig;
m_txRightStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
m_txRightStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
}
else
{
trans=m_txRightStickOrig;
m_txRightStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
trans=m_txLeftStickOrig;
m_txLeftStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
m_txLeftStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
}
}
void ConfigInputWidget::dimOtherControls(bool value)
{
qreal opac;
if(value)
opac=0.1;
else
opac=1;
m_txAccess0->setOpacity(opac);
m_txAccess1->setOpacity(opac);
m_txAccess2->setOpacity(opac);
m_txFlightMode->setOpacity(opac);
}
void ConfigInputWidget::enableControls(bool enable)
{
if(goWizard)
goWizard->setEnabled(enable);
ConfigTaskWidget::enableControls(enable);
}

View File

@ -116,6 +116,7 @@ private:
QTimer * animate;
void resetTxControls();
void setMoveFromCommand(int command);
QPushButton * goWizard;
private slots:
void wzNext();
void wzBack();
@ -125,9 +126,11 @@ private slots:
void identifyControls();
void identifyLimits();
void moveTxControls();
void moveSticks();
void moveSticks();
void dimOtherControls(bool value);
protected:
void resizeEvent(QResizeEvent *event);
virtual void enableControls(bool enable);
};

View File

@ -238,6 +238,7 @@ void ConfigTaskWidget::setupButtons(QPushButton *update, QPushButton *save)
connect(smartsave,SIGNAL(saveSuccessfull()),this,SLOT(clearDirty()));
connect(smartsave,SIGNAL(beginOp()),this,SLOT(disableObjUpdates()));
connect(smartsave,SIGNAL(endOp()),this,SLOT(enableObjUpdates()));
enableControls(false);
}
void ConfigTaskWidget::enableControls(bool enable)

View File

@ -36,6 +36,18 @@
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="wzText">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>70</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>

View File

@ -92,7 +92,8 @@ void smartSaveButton::setObjects(QList<UAVObject *> list)
void smartSaveButton::addObject(UAVObject * obj)
{
objects.append(obj);
if(!objects.contains(obj))
objects.append(obj);
}
void smartSaveButton::clearObjects()