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

Added support for Mode 3 and Mode 4 to the TX Configuration Wizard. Fixed a number of bugs and issues in the wizard. Made some changes to wizard text and layouts as well.

This commit is contained in:
Richard Flay (Hyper) 2012-10-19 20:30:42 +10:30 committed by Oleg Semyonov
parent 5f80268396
commit b620c6ebc8
3 changed files with 243 additions and 171 deletions

View File

@ -49,7 +49,15 @@
#define STICK_MIN_MOVE -8
#define STICK_MAX_MOVE 8
ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent),wizardStep(wizardNone),transmitterType(heli),loop(NULL),skipflag(false)
ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
ConfigTaskWidget(parent),
wizardStep(wizardNone),
// not currently stored in the settings UAVO
transmitterMode(mode2),
transmitterType(acro),
//
loop(NULL),
skipflag(false)
{
manualCommandObj = ManualControlCommand::GetInstance(getObjectManager());
manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager());
@ -295,7 +303,7 @@ void ConfigInputWidget::openHelp()
void ConfigInputWidget::goToWizard()
{
QMessageBox msgBox;
msgBox.setText(tr("Arming Settings are now set to Always Disarmed for your safety."));
msgBox.setText(tr("Arming Settings are now set to 'Always Disarmed' for your safety."));
msgBox.setDetailedText(tr("You will have to reconfigure the arming settings manually "
"when the wizard is finished. After the last step of the "
"wizard you will be taken to the Arming Settings screen."));
@ -307,16 +315,28 @@ void ConfigInputWidget::goToWizard()
if(m_config->tabWidget->currentIndex() != 0) {
m_config->tabWidget->setCurrentIndex(0);
}
// Stash current manual settings data in case the wizard is
// cancelled or the user proceeds far enough into the wizard such
// that the UAVO is changed, but then backs out to the start and
// chooses a different TX type (which could otherwise result in
// unexpected TX channels being enabled)
manualSettingsData=manualSettingsObj->getData();
previousManualSettingsData = manualSettingsData;
manualSettingsData.Arming=ManualControlSettings::ARMING_ALWAYSDISARMED;
manualSettingsObj->setData(manualSettingsData);
// start the wizard
wizardSetUpStep(wizardWelcome);
m_config->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio );
m_config->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio);
}
void ConfigInputWidget::disableWizardButton(int value)
{
if(value!=0)
m_config->configurationWizard->setVisible(false);
m_config->groupBox_3->setVisible(false);
else
m_config->configurationWizard->setVisible(true);
m_config->groupBox_3->setVisible(true);
}
void ConfigInputWidget::wzCancel()
@ -345,12 +365,12 @@ void ConfigInputWidget::wzNext()
// State transitions for next button
switch(wizardStep) {
case wizardWelcome:
wizardSetUpStep(wizardChooseMode);
break;
case wizardChooseMode:
wizardSetUpStep(wizardChooseType);
break;
case wizardChooseType:
wizardSetUpStep(wizardChooseMode);
break;
case wizardChooseMode:
wizardSetUpStep(wizardIdentifySticks);
break;
case wizardIdentifySticks:
@ -371,6 +391,25 @@ void ConfigInputWidget::wzNext()
break;
case wizardFinish:
wizardStep=wizardNone;
// Leave setting the throttle neutral until the final Next press,
// else the throttle scaling causes the graphical stick movement to not
// match the tx stick
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE]=
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]+
((manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE]-
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE])*0.02);
if((abs(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE] -
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE])<100) ||
(abs(manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE] -
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE])<100))
{
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE]=
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]+
(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE] -
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE])/2;
}
manualSettingsObj->setData(manualSettingsData);
// move to Arming Settings tab
m_config->stackedWidget->setCurrentIndex(0);
m_config->tabWidget->setCurrentIndex(2);
break;
@ -387,17 +426,17 @@ void ConfigInputWidget::wzBack()
// State transitions for next button
switch(wizardStep) {
case wizardChooseMode:
case wizardChooseType:
wizardSetUpStep(wizardWelcome);
break;
case wizardChooseType:
wizardSetUpStep(wizardChooseMode);
case wizardChooseMode:
wizardSetUpStep(wizardChooseType);
break;
case wizardIdentifySticks:
prevChannel();
if(currentChannelNum == -1) {
wizardTearDownStep(wizardIdentifySticks);
wizardSetUpStep(wizardChooseType);
wizardSetUpStep(wizardChooseMode);
}
break;
case wizardIdentifyCenter:
@ -419,6 +458,8 @@ void ConfigInputWidget::wzBack()
void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
{
m_config->wzText2->clear();
switch(step) {
case wizardWelcome:
foreach(QPointer<QWidget> wd,extraWidgets)
@ -429,53 +470,70 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
extraWidgets.clear();
m_config->graphicsView->setVisible(false);
setTxMovement(nothing);
manualSettingsData=manualSettingsObj->getData();
manualSettingsData.Arming=ManualControlSettings::ARMING_ALWAYSDISARMED;
previousManualSettingsData = manualSettingsData;
manualSettingsObj->setData(manualSettingsData);
m_config->wzText->setText(tr("Welcome to the inputs configuration wizard.\n"
m_config->wzText->setText(tr("Welcome to the inputs configuration wizard.\n\n"
"Please follow the instructions on the screen and only move your controls when asked to.\n"
"Make sure you already configured your hardware settings on the proper tab and restarted your board.\n"
"You can press 'back' at any time to return to the previous screeen or press 'Cancel' to quit the wizard.\n"));
"Make sure you already configured your hardware settings on the proper tab and restarted your board.\n\n"
"You can press 'back' at any time to return to the previous screen or press 'Cancel' to quit the wizard.\n"));
m_config->stackedWidget->setCurrentIndex(1);
m_config->wzBack->setEnabled(false);
break;
case wizardChooseMode:
{
m_config->graphicsView->setVisible(true);
m_config->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio );
setTxMovement(nothing);
m_config->wzText->setText(tr("Please choose your transmitter type.\n"
"Mode 1 means your throttle stick is on the right.\n"
"Mode 2 means your throttle stick is on the left.\n"));
m_config->wzBack->setEnabled(true);
QRadioButton * mode1=new QRadioButton(tr("Mode 1"),this);
QRadioButton * mode2=new QRadioButton(tr("Mode 2"),this);
mode2->setChecked(true);
extraWidgets.clear();
extraWidgets.append(mode1);
extraWidgets.append(mode2);
m_config->checkBoxesLayout->layout()->addWidget(mode1);
m_config->checkBoxesLayout->layout()->addWidget(mode2);
}
break;
case wizardChooseType:
{
m_config->wzText->setText(tr("Please choose your transmitter mode.\n"
"Acro means normal transmitter.\n"
"Heli means there is a collective pitch and throttle input.\n"
"If you are using a heli transmitter please engage throttle hold now.\n"));
m_config->graphicsView->setVisible(true);
m_config->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio);
setTxMovement(nothing);
m_config->wzText->setText(tr("Please choose your transmitter type:"));
m_config->wzBack->setEnabled(true);
QRadioButton * typeAcro=new QRadioButton(tr("Acro"),this);
QRadioButton * typeHeli=new QRadioButton(tr("Heli"),this);
typeAcro->setChecked(true);
typeHeli->setChecked(false);
QRadioButton * typeAcro=new QRadioButton(tr("Acro: normal transmitter for fixed-wing or quad"),this);
QRadioButton * typeHeli=new QRadioButton(tr("Helicopter: has collective pitch and throttle input"),this);
if (transmitterType == heli) {
typeHeli->setChecked(true);
}
else {
typeAcro->setChecked(true);
}
m_config->wzText2->setText(tr("If selecting the Helicopter option, please engage throttle hold now."));
extraWidgets.clear();
extraWidgets.append(typeAcro);
extraWidgets.append(typeHeli);
m_config->checkBoxesLayout->layout()->addWidget(typeAcro);
m_config->checkBoxesLayout->layout()->addWidget(typeHeli);
wizardStep=wizardChooseType;
m_config->radioButtonsLayout->layout()->addWidget(typeAcro);
m_config->radioButtonsLayout->layout()->addWidget(typeHeli);
}
break;
case wizardChooseMode:
{
m_config->wzBack->setEnabled(true);
extraWidgets.clear();
m_config->wzText->setText(tr("Please choose your transmitter mode:"));
for (int i = 0; i <= mode4; ++i) {
QString label;
txMode mode = static_cast<txMode>(i);
if (transmitterType == heli) {
switch (mode) {
case mode1: label = tr("Mode 1: Fore/Aft Cyclic and Yaw on the left, Throttle/Collective and Left/Right Cyclic on the right"); break;
case mode2: label = tr("Mode 2: Throttle/Collective and Yaw on the left, Cyclic on the right"); break;
case mode3: label = tr("Mode 3: Cyclic on the left, Throttle/Collective and Yaw on the right"); break;
case mode4: label = tr("Mode 4: Throttle/Collective and Left/Right Cyclic on the left, Fore/Aft Cyclic and Yaw on the right"); break;
default: Q_ASSERT(0); break;
} }
else {
switch (mode) {
case mode1: label = tr("Mode 1: Elevator and Rudder on the left, Throttle and Ailerons on the right"); break;
case mode2: label = tr("Mode 2: Throttle and Rudder on the left, Elevator and Ailerons on the right"); break;
case mode3: label = tr("Mode 3: Elevator and Ailerons on the left, Throttle and Rudder on the right"); break;
case mode4: label = tr("Mode 4: Throttle and Ailerons on the left, Elevator and Rudder on the right"); break;
default: Q_ASSERT(0); break;
}
m_config->wzText2->setText(tr("For a Quad: Elevator is Pitch, Ailerons are Roll, and Rudder is Yaw."));
}
QRadioButton * modeButton = new QRadioButton(label, this);
if (transmitterMode == mode) {
modeButton->setChecked(true);
}
extraWidgets.append(modeButton);
m_config->radioButtonsLayout->layout()->addWidget(modeButton);
}
}
break;
case wizardIdentifySticks:
@ -488,7 +546,8 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
break;
case wizardIdentifyCenter:
setTxMovement(centerAll);
m_config->wzText->setText(QString(tr("Please center all controls and press next when ready (if your FlightMode switch has only two positions, leave it in either position).")));
m_config->wzText->setText(QString(tr("Please center all controls and trims and press Next when ready.\n\n"
"If your FlightMode switch has only two positions, leave it in either position.")));
break;
case wizardIdentifyLimits:
{
@ -496,7 +555,7 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
accessoryDesiredObj1 = AccessoryDesired::GetInstance(getObjectManager(),1);
accessoryDesiredObj2 = AccessoryDesired::GetInstance(getObjectManager(),2);
setTxMovement(nothing);
m_config->wzText->setText(QString(tr("Please move all controls to their maximum extents on both directions and press next when ready.")));
m_config->wzText->setText(QString(tr("Please move all controls to their maximum extents on both directions.\n\nPress Next when ready.")));
fastMdata();
manualSettingsData=manualSettingsObj->getData();
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
@ -521,24 +580,22 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
dimOtherControls(true);
setTxMovement(nothing);
extraWidgets.clear();
for (int index = 0; index < manualSettingsObj->getField("ChannelMax")->getElementNames().length(); index++)
{
QString name = manualSettingsObj->getField("ChannelMax")->getElementNames().at(index);
if(!name.contains("Access") && !name.contains("Flight"))
if(!name.contains("Access") && !name.contains("Flight") &&
(!name.contains("Collective") || transmitterType == heli))
{
QCheckBox * cb=new QCheckBox(name,this);
// Make sure checked status matches current one
cb->setChecked(manualSettingsData.ChannelMax[index] < manualSettingsData.ChannelMin[index]);
dynamic_cast<QGridLayout*>(m_config->checkBoxesLayout->layout())->addWidget(cb, extraWidgets.size()/4, extraWidgets.size()%4);
extraWidgets.append(cb);
m_config->checkBoxesLayout->layout()->addWidget(cb);
connect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls()));
}
}
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
m_config->wzText->setText(QString(tr("Please check the picture below and correct all the sticks which show an inverted movement, press next when ready.")));
m_config->wzText->setText(QString(tr("Please check the picture below and correct all the sticks which show an inverted movement. Press Next when ready.")));
fastMdata();
break;
case wizardFinish:
@ -546,22 +603,10 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
connect(flightStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
connect(accessoryDesiredObj0, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
m_config->wzText->setText(QString(tr("You have completed this wizard, please check below if the picture mimics your sticks movement.\n"
"These new settings aren't saved to the board yet, after pressing next you will go to the Arming Settings "
"screen where you can set your desired arming sequence and save the configuration.")));
m_config->wzText->setText(QString(tr("You have completed this wizard, please check below if the picture mimics your sticks movement.\n\n"
"IMPORTANT: These new settings have not been saved to the board yet. After pressing Next you will go to the Arming Settings "
"tab where you can set your desired arming sequence and save the configuration.")));
fastMdata();
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE]=
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]+
((manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE]-
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE])*0.02);
if((abs(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE]-manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE])<100) ||
(abs(manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]-manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE])<100))
{
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE]=manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]+
(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE]-manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE])/2;
}
manualSettingsObj->setData(manualSettingsData);
break;
default:
Q_ASSERT(0);
@ -576,17 +621,7 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
switch(step) {
case wizardWelcome:
break;
case wizardChooseMode:
mode=qobject_cast<QRadioButton *>(extraWidgets.at(0));
if(mode->isChecked())
transmitterMode=mode1;
else
transmitterMode=mode2;
delete extraWidgets.at(0);
delete extraWidgets.at(1);
extraWidgets.clear();
break;
case wizardChooseType:
case wizardChooseType:
type=qobject_cast<QRadioButton *>(extraWidgets.at(0));
if(type->isChecked())
transmitterType=acro;
@ -596,6 +631,16 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
delete extraWidgets.at(1);
extraWidgets.clear();
break;
case wizardChooseMode:
for (int i = mode1; i <= mode4; ++i) {
mode=qobject_cast<QRadioButton *>(extraWidgets.first());
if(mode->isChecked()) {
transmitterMode=static_cast<txMode>(i);
}
delete mode;
extraWidgets.removeFirst();
}
break;
case wizardIdentifySticks:
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
m_config->wzNext->setEnabled(true);
@ -674,19 +719,19 @@ void ConfigInputWidget::restoreMdata()
void ConfigInputWidget::setChannel(int newChan)
{
if(newChan == ManualControlSettings::CHANNELGROUPS_COLLECTIVE)
m_config->wzText->setText(QString(tr("Please enable the throttle hold mode and move the collective pitch stick.")));
m_config->wzText->setText(QString(tr("Please enable throttle hold mode.\n\nMove the Collective Pitch stick.")));
else if (newChan == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE)
m_config->wzText->setText(QString(tr("Please toggle the flight mode switch. For switches you may have to repeat this rapidly.")));
m_config->wzText->setText(QString(tr("Please toggle the Flight Mode switch.\n\nFor switches you may have to repeat this rapidly.")));
else if((transmitterType == heli) && (newChan == ManualControlSettings::CHANNELGROUPS_THROTTLE))
m_config->wzText->setText(QString(tr("Please disable throttle hold mode and move the throttle stick.")));
m_config->wzText->setText(QString(tr("Please disable throttle hold mode.\n\nMove the Throttle stick.")));
else
m_config->wzText->setText(QString(tr("Please move each control once at a time according to the instructions and picture below.\n\n"
"Move the %1 stick")).arg(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan)));
m_config->wzText->setText(QString(tr("Please move each control one at a time according to the instructions and picture below.\n\n"
"Move the %1 stick.")).arg(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan)));
if(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("Accessory") ||
manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("FlightMode")) {
m_config->wzNext->setEnabled(true);
m_config->wzText->setText(m_config->wzText->text() + tr(" or click next to skip this channel."));
m_config->wzText->setText(m_config->wzText->text() + tr(" Alternatively, click Next to skip this channel."));
} else
m_config->wzNext->setEnabled(false);
@ -731,8 +776,11 @@ void ConfigInputWidget::prevChannel()
for (int i = 1; i < order.length(); i++) {
if(order[i] == currentChannelNum) {
if (!usedChannels.isEmpty() &&
usedChannels.back().channelIndex == currentChannelNum) {
usedChannels.removeLast();
}
setChannel(order[i-1]);
usedChannels.removeLast();
return;
}
}
@ -757,6 +805,7 @@ void ConfigInputWidget::identifyControls()
++debounce;
lastChannel.group= currentChannel.group;
lastChannel.number=currentChannel.number;
lastChannel.channelIndex = currentChannelNum;
if(!usedChannels.contains(lastChannel) && debounce>1)
{
channelDetected = true;
@ -771,7 +820,7 @@ void ConfigInputWidget::identifyControls()
return;
}
m_config->wzText->clear();
//m_config->wzText->clear();
setTxMovement(nothing);
QTimer::singleShot(2500, this, SLOT(wzNext()));
@ -800,53 +849,56 @@ void ConfigInputWidget::identifyLimits()
}
void ConfigInputWidget::setMoveFromCommand(int command)
{
//CHANNELNUMBER_ROLL=0, CHANNELNUMBER_PITCH=1, CHANNELNUMBER_YAW=2, CHANNELNUMBER_THROTTLE=3, CHANNELNUMBER_FLIGHTMODE=4, CHANNELNUMBER_ACCESSORY0=5, CHANNELNUMBER_ACCESSORY1=6, CHANNELNUMBER_ACCESSORY2=7 } ChannelNumberElem;
if(command==ManualControlSettings::CHANNELNUMBER_ROLL)
{
setTxMovement(moveRightHorizontalStick);
}
else if(command==ManualControlSettings::CHANNELNUMBER_PITCH)
{
if(transmitterMode==mode2)
setTxMovement(moveRightVerticalStick);
else
setTxMovement(moveLeftVerticalStick);
}
else if(command==ManualControlSettings::CHANNELNUMBER_YAW)
{
setTxMovement(moveLeftHorizontalStick);
}
else if(command==ManualControlSettings::CHANNELNUMBER_THROTTLE)
{
if(transmitterMode==mode2)
setTxMovement(moveLeftVerticalStick);
else
setTxMovement(moveRightVerticalStick);
}
else if(command==ManualControlSettings::CHANNELNUMBER_COLLECTIVE)
{
if(transmitterMode==mode2)
setTxMovement(moveLeftVerticalStick);
else
setTxMovement(moveRightVerticalStick);
}
else if(command==ManualControlSettings::CHANNELNUMBER_FLIGHTMODE)
{
setTxMovement(moveFlightMode);
}
else if(command==ManualControlSettings::CHANNELNUMBER_ACCESSORY0)
{
setTxMovement(moveAccess0);
}
else if(command==ManualControlSettings::CHANNELNUMBER_ACCESSORY1)
{
setTxMovement(moveAccess1);
}
else if(command==ManualControlSettings::CHANNELNUMBER_ACCESSORY2)
{
setTxMovement(moveAccess2);
}
// ManualControlSettings::ChannelNumberElem:
// CHANNELNUMBER_ROLL=0,
// CHANNELNUMBER_PITCH=1,
// CHANNELNUMBER_YAW=2,
// CHANNELNUMBER_THROTTLE=3,
// CHANNELNUMBER_FLIGHTMODE=4,
// CHANNELNUMBER_ACCESSORY0=5,
// CHANNELNUMBER_ACCESSORY1=6,
// CHANNELNUMBER_ACCESSORY2=7
txMovements movement;
switch (command) {
case ManualControlSettings::CHANNELNUMBER_ROLL:
movement = ((transmitterMode == mode3 || transmitterMode == mode4) ?
moveLeftHorizontalStick: moveRightHorizontalStick);
break;
case ManualControlSettings::CHANNELNUMBER_PITCH:
movement = (transmitterMode == mode1 || transmitterMode == mode3) ?
moveLeftVerticalStick: moveRightVerticalStick;
break;
case ManualControlSettings::CHANNELNUMBER_YAW:
movement = ((transmitterMode == mode1 || transmitterMode == mode2) ?
moveLeftHorizontalStick: moveRightHorizontalStick);
break;
case ManualControlSettings::CHANNELNUMBER_THROTTLE:
movement = (transmitterMode == mode2 || transmitterMode == mode4) ?
moveLeftVerticalStick: moveRightVerticalStick;
break;
case ManualControlSettings::CHANNELNUMBER_COLLECTIVE:
movement = (transmitterMode == mode2 || transmitterMode == mode4) ?
moveLeftVerticalStick: moveRightVerticalStick;
break;
case ManualControlSettings::CHANNELNUMBER_FLIGHTMODE:
movement = moveFlightMode;
break;
case ManualControlSettings::CHANNELNUMBER_ACCESSORY0:
movement = moveAccess0;
break;
case ManualControlSettings::CHANNELNUMBER_ACCESSORY1:
movement = moveAccess1;
break;
case ManualControlSettings::CHANNELNUMBER_ACCESSORY2:
movement = moveAccess2;
break;
default:
Q_ASSERT(0);
break;
}
setTxMovement(movement);
}
void ConfigInputWidget::setTxMovement(txMovements movement)
@ -918,6 +970,7 @@ void ConfigInputWidget::setTxMovement(txMovements movement)
animate->stop();
break;
default:
Q_ASSERT(0);
break;
}
}
@ -1111,19 +1164,34 @@ void ConfigInputWidget::moveSticks()
accessoryDesiredData1=accessoryDesiredObj1->getData();
accessoryDesiredData2=accessoryDesiredObj2->getData();
if(transmitterMode==mode2)
{
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);
}
else
{
trans=m_txRightStickOrig;
m_txRightStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
trans=m_txLeftStickOrig;
m_txLeftStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
switch (transmitterMode) {
case mode1:
trans=m_txLeftStickOrig;
m_txLeftStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
trans=m_txRightStickOrig;
m_txRightStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
break;
case mode2:
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);
break;
case mode3:
trans=m_txLeftStickOrig;
m_txLeftStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
trans=m_txRightStickOrig;
m_txRightStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
break;
case mode4:
trans=m_txLeftStickOrig;
m_txLeftStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
trans=m_txRightStickOrig;
m_txRightStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
break;
default:
Q_ASSERT(0);
break;
}
if(flightStatusData.FlightMode==manualSettingsData.FlightModePosition[0])
{
@ -1307,7 +1375,7 @@ void ConfigInputWidget::simpleCalibration(bool enable)
m_config->configurationWizard->setEnabled(false);
QMessageBox msgBox;
msgBox.setText(tr("Arming Settings are now set to Always Disarmed for your safety."));
msgBox.setText(tr("Arming Settings are now set to 'Always Disarmed' for your safety."));
msgBox.setDetailedText(tr("You will have to reconfigure the arming settings manually when the wizard is finished."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
@ -1337,7 +1405,7 @@ void ConfigInputWidget::simpleCalibration(bool enable)
restoreMdata();
for (int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++)
for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++)
manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i];
// Force flight mode neutral to middle

View File

@ -56,7 +56,7 @@ public:
ConfigInputWidget(QWidget *parent = 0);
~ConfigInputWidget();
enum wizardSteps{wizardWelcome,wizardChooseMode,wizardChooseType,wizardIdentifySticks,wizardIdentifyCenter,wizardIdentifyLimits,wizardIdentifyInverted,wizardFinish,wizardNone};
enum txMode{mode1,mode2};
enum txMode{mode1,mode2,mode3,mode4};
enum txMovements{moveLeftVerticalStick,moveRightVerticalStick,moveLeftHorizontalStick,moveRightHorizontalStick,moveAccess0,moveAccess1,moveAccess2,moveFlightMode,centerAll,moveAll,nothing};
enum txMovementType{vertical,horizontal,jump,mix};
enum txType {acro, heli};
@ -81,6 +81,7 @@ private:
}
int group;
int number;
int channelIndex;
}lastChannel;
channelsStruct currentChannel;
QList<channelsStruct> usedChannels;

View File

@ -249,36 +249,39 @@
<number>12</number>
</property>
<item>
<widget class="QLabel" name="wzText">
<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>90</height>
</size>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="radioButtonsLayout"/>
</item>
<item>
<layout class="QGridLayout" name="checkBoxesLayout"/>
</item>
<item>
<widget class="QLabel" name="wzText2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
<item>
<layout class="QVBoxLayout" name="checkBoxesLayout"/>
</item>
</layout>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">