mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
_GCS control
fixed options panel so that user can only select 1. axis for increase and decrease functions 2. armed/gcs control for toggle function git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2207 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
5f71795d67
commit
901725a9db
@ -195,68 +195,63 @@ void GCSControlGadget::buttonState(ButtonNumber number, bool pressed)
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("ManualControlCommand")) );
|
||||
|
||||
switch (buttonSettings[number].FunctionID)
|
||||
switch (buttonSettings[number].ActionID)
|
||||
{
|
||||
case 1://Roll
|
||||
if (buttonSettings[number].ActionID==1)
|
||||
{//increase
|
||||
obj->getField("Roll")->setValue(bound(obj->getField("Roll")->getValue().toDouble()+buttonSettings[number].Amount));
|
||||
}
|
||||
if (buttonSettings[number].ActionID==2)
|
||||
{//decrease
|
||||
obj->getField("Roll")->setValue(bound(obj->getField("Roll")->getValue().toDouble()-buttonSettings[number].Amount));
|
||||
case 1://increase
|
||||
switch (buttonSettings[number].FunctionID)
|
||||
{
|
||||
case 1://Roll
|
||||
obj->getField("Roll")->setValue(bound(obj->getField("Roll")->getValue().toDouble()+buttonSettings[number].Amount));
|
||||
break;
|
||||
case 2://Pitch
|
||||
obj->getField("Pitch")->setValue(bound(obj->getField("Pitch")->getValue().toDouble()+buttonSettings[number].Amount));
|
||||
break;
|
||||
case 3://Yaw
|
||||
obj->getField("Yaw")->setValue(wrap(obj->getField("Yaw")->getValue().toDouble()+buttonSettings[number].Amount));
|
||||
break;
|
||||
case 4://Throttle
|
||||
obj->getField("Throttle")->setValue(bound(obj->getField("Throttle")->getValue().toDouble()+buttonSettings[number].Amount));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2://Pitch
|
||||
if (buttonSettings[number].ActionID==1)
|
||||
{//increase
|
||||
obj->getField("Pitch")->setValue(bound(obj->getField("Pitch")->getValue().toDouble()+buttonSettings[number].Amount));
|
||||
}
|
||||
if (buttonSettings[number].ActionID==2)
|
||||
{//decrease
|
||||
obj->getField("Pitch")->setValue(bound(obj->getField("Pitch")->getValue().toDouble()-buttonSettings[number].Amount));
|
||||
case 2://decrease
|
||||
switch (buttonSettings[number].FunctionID)
|
||||
{
|
||||
case 1://Roll
|
||||
obj->getField("Roll")->setValue(bound(obj->getField("Roll")->getValue().toDouble()-buttonSettings[number].Amount));
|
||||
break;
|
||||
case 2://Pitch
|
||||
obj->getField("Pitch")->setValue(bound(obj->getField("Pitch")->getValue().toDouble()-buttonSettings[number].Amount));
|
||||
break;
|
||||
case 3://Yaw
|
||||
obj->getField("Yaw")->setValue(wrap(obj->getField("Yaw")->getValue().toDouble()-buttonSettings[number].Amount));
|
||||
break;
|
||||
case 4://Throttle
|
||||
obj->getField("Throttle")->setValue(bound(obj->getField("Throttle")->getValue().toDouble()-buttonSettings[number].Amount));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3://Yaw
|
||||
if (buttonSettings[number].ActionID==1)
|
||||
{//increase
|
||||
obj->getField("Yaw")->setValue(wrap(obj->getField("Yaw")->getValue().toDouble()+buttonSettings[number].Amount));
|
||||
case 3://toggle
|
||||
switch (buttonSettings[number].FunctionID)
|
||||
{
|
||||
case 1://Armed
|
||||
if(obj->getField("Armed")->getValue().toString().compare("True")==0)
|
||||
{
|
||||
obj->getField("Armed")->setValue("False");
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->getField("Armed")->setValue("True");
|
||||
}
|
||||
break;
|
||||
case 2://GCS Control
|
||||
break;
|
||||
}
|
||||
if (buttonSettings[number].ActionID==2)
|
||||
{//decrease
|
||||
obj->getField("Yaw")->setValue(wrap(obj->getField("Yaw")->getValue().toDouble()-buttonSettings[number].Amount));
|
||||
}
|
||||
break;
|
||||
case 4://Throttle
|
||||
if (buttonSettings[number].ActionID==1)
|
||||
{//increase
|
||||
obj->getField("Throttle")->setValue(bound(obj->getField("Throttle")->getValue().toDouble()+buttonSettings[number].Amount));
|
||||
}
|
||||
if (buttonSettings[number].ActionID==2)
|
||||
{//decrease
|
||||
obj->getField("Throttle")->setValue(bound(obj->getField("Throttle")->getValue().toDouble()-buttonSettings[number].Amount));
|
||||
}
|
||||
break;
|
||||
case 5://Armed
|
||||
if (buttonSettings[number].ActionID==3)
|
||||
{//toggle
|
||||
if(obj->getField("Armed")->getValue().toString().compare("True")==0)
|
||||
{
|
||||
obj->getField("Armed")->setValue("False");
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->getField("Armed")->setValue("True");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6://GCS Control
|
||||
if (buttonSettings[number].ActionID==3)
|
||||
{//toggle
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
obj->updated();
|
||||
}
|
||||
//buttonSettings[number].ActionID NIDT
|
||||
|
@ -41,6 +41,8 @@ GCSControlGadgetOptionsPage::GCSControlGadgetOptionsPage(GCSControlGadgetConfigu
|
||||
|
||||
sdlGamepad = dynamic_cast<GCSControlPlugin*>(parent)->sdlGamepad;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
GCSControlGadgetOptionsPage::~GCSControlGadgetOptionsPage()
|
||||
@ -102,6 +104,8 @@ QWidget *GCSControlGadgetOptionsPage::createPage(QWidget *parent)
|
||||
QWidget *optionsPageWidget = new QWidget;
|
||||
options_page->setupUi(optionsPageWidget);
|
||||
|
||||
|
||||
|
||||
QList<QComboBox*> chList;
|
||||
chList << options_page->channel0 << options_page->channel1 <<
|
||||
options_page->channel2 << options_page->channel3 <<
|
||||
@ -147,9 +151,20 @@ QWidget *GCSControlGadgetOptionsPage::createPage(QWidget *parent)
|
||||
buttonValueList.at(i)->setValue(m_config->getbuttonSettings(i).Amount);
|
||||
|
||||
connect(buttonFunctionList.at(i),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonFunction()));
|
||||
connect(buttonActionList.at(i),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonFunction()));
|
||||
//connect(buttonActionList.at(i),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonActions[i]()));
|
||||
updateButtonAction(i);
|
||||
buttonFunctionList.at(i)->setCurrentIndex(m_config->getbuttonSettings(i).FunctionID);
|
||||
}
|
||||
updateButtonFunction();
|
||||
connect(buttonActionList.at(0),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonAction_0()));
|
||||
connect(buttonActionList.at(1),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonAction_1()));
|
||||
connect(buttonActionList.at(2),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonAction_2()));
|
||||
connect(buttonActionList.at(3),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonAction_3()));
|
||||
connect(buttonActionList.at(4),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonAction_4()));
|
||||
connect(buttonActionList.at(5),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonAction_5()));
|
||||
connect(buttonActionList.at(6),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonAction_6()));
|
||||
connect(buttonActionList.at(7),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonAction_7()));
|
||||
|
||||
//updateButtonFunction();
|
||||
|
||||
|
||||
// Controls mode are from 1 to 4.
|
||||
@ -276,7 +291,7 @@ void GCSControlGadgetOptionsPage::updateButtonFunction()
|
||||
buttonFunctionList.at(i)->setVisible(1);
|
||||
buttonLabelList.at(i)->setVisible(0);
|
||||
buttonValueList.at(i)->setVisible(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonFunctionList.at(i)->setVisible(1);
|
||||
@ -287,3 +302,67 @@ void GCSControlGadgetOptionsPage::updateButtonFunction()
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GCSControlGadgetOptionsPage::updateButtonAction(int controlID)
|
||||
{
|
||||
int i;
|
||||
QStringList buttonOptions;
|
||||
QList<QComboBox*> buttonFunctionList;
|
||||
buttonFunctionList << options_page->buttonFunction0 << options_page->buttonFunction1 <<
|
||||
options_page->buttonFunction2 << options_page->buttonFunction3 <<
|
||||
options_page->buttonFunction4 << options_page->buttonFunction5 <<
|
||||
options_page->buttonFunction6 << options_page->buttonFunction7;
|
||||
QList<QComboBox*> buttonActionList;
|
||||
buttonActionList << options_page->buttonAction0 << options_page->buttonAction1 <<
|
||||
options_page->buttonAction2 << options_page->buttonAction3 <<
|
||||
options_page->buttonAction4 << options_page->buttonAction5 <<
|
||||
options_page->buttonAction6 << options_page->buttonAction7;
|
||||
QList<QDoubleSpinBox*> buttonValueList;
|
||||
buttonValueList << options_page->buttonAmount0 << options_page->buttonAmount1 <<
|
||||
options_page->buttonAmount2 << options_page->buttonAmount3 <<
|
||||
options_page->buttonAmount4 << options_page->buttonAmount5 <<
|
||||
options_page->buttonAmount6 << options_page->buttonAmount7;
|
||||
QList<QLabel*> buttonLabelList;
|
||||
buttonLabelList << options_page->buttonLabel0 << options_page->buttonLabel1 <<
|
||||
options_page->buttonLabel2 << options_page->buttonLabel3 <<
|
||||
options_page->buttonLabel4 << options_page->buttonLabel5 <<
|
||||
options_page->buttonLabel6 << options_page->buttonLabel7;
|
||||
|
||||
//for (i=0;i<8;i++)
|
||||
i=controlID;
|
||||
{
|
||||
if (buttonActionList.at(i)->currentText().compare("Does nothing")==0)
|
||||
{
|
||||
buttonFunctionList.at(i)->setVisible(0);
|
||||
buttonLabelList.at(i)->setVisible(0);
|
||||
buttonValueList.at(i)->setVisible(0);
|
||||
}
|
||||
else
|
||||
if (buttonActionList.at(i)->currentText().compare("Toggles")==0)
|
||||
{
|
||||
disconnect(buttonFunctionList.at(i),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonFunction()));
|
||||
buttonOptions <<"-" << "Armed" << "GCS Control" ;
|
||||
buttonFunctionList.at(i)->clear();
|
||||
buttonFunctionList.at(i)->insertItems(-1,buttonOptions);
|
||||
|
||||
buttonFunctionList.at(i)->setVisible(1);
|
||||
buttonLabelList.at(i)->setVisible(0);
|
||||
buttonValueList.at(i)->setVisible(0);
|
||||
connect(buttonFunctionList.at(i),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonFunction()));
|
||||
}
|
||||
else
|
||||
{
|
||||
disconnect(buttonFunctionList.at(i),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonFunction()));
|
||||
buttonOptions <<"-" << "Roll" << "Pitch" << "Yaw" << "Throttle" ;
|
||||
buttonFunctionList.at(i)->clear();
|
||||
buttonFunctionList.at(i)->addItems(buttonOptions);
|
||||
|
||||
buttonFunctionList.at(i)->setVisible(1);
|
||||
buttonLabelList.at(i)->setVisible(1);
|
||||
buttonValueList.at(i)->setVisible(1);
|
||||
connect(buttonFunctionList.at(i),SIGNAL(currentIndexChanged(int)),this,SLOT(updateButtonFunction()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -67,7 +67,15 @@ protected slots:
|
||||
void buttonState(ButtonNumber number, bool pressed);
|
||||
void axesValues(QListInt16 values);
|
||||
void updateButtonFunction();
|
||||
|
||||
void updateButtonAction(int controlID);
|
||||
void updateButtonAction_0(void){updateButtonAction(0);};
|
||||
void updateButtonAction_1(void){updateButtonAction(1);};
|
||||
void updateButtonAction_2(void){updateButtonAction(2);};
|
||||
void updateButtonAction_3(void){updateButtonAction(3);};
|
||||
void updateButtonAction_4(void){updateButtonAction(4);};
|
||||
void updateButtonAction_5(void){updateButtonAction(5);};
|
||||
void updateButtonAction_6(void){updateButtonAction(6);};
|
||||
void updateButtonAction_7(void){updateButtonAction(7);};
|
||||
};
|
||||
|
||||
#endif // GCSCONTROLGADGETOPTIONSPAGE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user