mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
Input wizard: Make collective pitch come first for helicopter mode transmitters
and tell person to use throttle hold so it's detected correctly.
This commit is contained in:
parent
bbdb176409
commit
1a2750051a
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
QList<inputChannelForm*> inputList;
|
QList<inputChannelForm*> inputList;
|
||||||
|
|
||||||
ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent),wizardStep(wizardWelcome),loop(NULL),skipflag(false)
|
ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent),wizardStep(wizardWelcome),loop(NULL),skipflag(false),transmitterType(heli)
|
||||||
{
|
{
|
||||||
manualCommandObj = ManualControlCommand::GetInstance(getObjectManager());
|
manualCommandObj = ManualControlCommand::GetInstance(getObjectManager());
|
||||||
manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager());
|
manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager());
|
||||||
@ -296,6 +296,7 @@ void ConfigInputWidget::wzCancel()
|
|||||||
case wizardWelcome:
|
case wizardWelcome:
|
||||||
break;
|
break;
|
||||||
case wizardChooseMode:
|
case wizardChooseMode:
|
||||||
|
case wizardChooseType:
|
||||||
break;
|
break;
|
||||||
case wizardIdentifySticks:
|
case wizardIdentifySticks:
|
||||||
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
||||||
@ -323,6 +324,11 @@ void ConfigInputWidget::wzNext()
|
|||||||
|
|
||||||
void ConfigInputWidget::wzBack()
|
void ConfigInputWidget::wzBack()
|
||||||
{
|
{
|
||||||
|
if(wizardStep == wizardIdentifySticks && currentCommand != 0) {
|
||||||
|
currentCommand --;
|
||||||
|
usedChannels.removeLast();
|
||||||
|
getChannelFromStep(currentCommand);
|
||||||
|
} else
|
||||||
setupWizardWidget(wizardStep-1);
|
setupWizardWidget(wizardStep-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,9 +378,8 @@ void ConfigInputWidget::setupWizardWidget(int step)
|
|||||||
m_config->checkBoxesLayout->layout()->addWidget(mode2);
|
m_config->checkBoxesLayout->layout()->addWidget(mode2);
|
||||||
wizardStep=wizardChooseMode;
|
wizardStep=wizardChooseMode;
|
||||||
}
|
}
|
||||||
else if(step==wizardIdentifySticks && !isSimple)
|
else if(step==wizardChooseType)
|
||||||
{
|
{
|
||||||
usedChannels.clear();
|
|
||||||
if(wizardStep==wizardChooseMode)
|
if(wizardStep==wizardChooseMode)
|
||||||
{
|
{
|
||||||
QRadioButton * mode=qobject_cast<QRadioButton *>(extraWidgets.at(0));
|
QRadioButton * mode=qobject_cast<QRadioButton *>(extraWidgets.at(0));
|
||||||
@ -386,28 +391,45 @@ void ConfigInputWidget::setupWizardWidget(int step)
|
|||||||
delete extraWidgets.at(1);
|
delete extraWidgets.at(1);
|
||||||
extraWidgets.clear();
|
extraWidgets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_config->wzText->setText(tr("Please choose your transmiter mode.\n"
|
||||||
|
"Acro means normal transmitter\n"
|
||||||
|
"Heli means there is a collective pitch and throttle input\n"));
|
||||||
|
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);
|
||||||
|
extraWidgets.clear();
|
||||||
|
extraWidgets.append(typeAcro);
|
||||||
|
extraWidgets.append(typeHeli);
|
||||||
|
m_config->checkBoxesLayout->layout()->addWidget(typeAcro);
|
||||||
|
m_config->checkBoxesLayout->layout()->addWidget(typeHeli);
|
||||||
|
wizardStep=wizardChooseType;
|
||||||
|
} else if(step==wizardIdentifySticks && !isSimple) {
|
||||||
|
usedChannels.clear();
|
||||||
|
if(wizardStep==wizardChooseType)
|
||||||
|
{
|
||||||
|
qDebug() << "Chosing type";
|
||||||
|
QRadioButton * type=qobject_cast<QRadioButton *>(extraWidgets.at(0));
|
||||||
|
if(type->isChecked())
|
||||||
|
transmitterType=acro;
|
||||||
|
else
|
||||||
|
transmitterType=heli;
|
||||||
|
qDebug() << "Checked: " << type->isChecked() << " " << "type is" << transmitterType;
|
||||||
|
delete extraWidgets.at(0);
|
||||||
|
delete extraWidgets.at(1);
|
||||||
|
extraWidgets.clear();
|
||||||
|
}
|
||||||
wizardStep=wizardIdentifySticks;
|
wizardStep=wizardIdentifySticks;
|
||||||
currentCommand=0;
|
currentCommand=0;
|
||||||
setMoveFromCommand(currentCommand);
|
getChannelFromStep(currentCommand);
|
||||||
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(currentCommand)));
|
|
||||||
manualSettingsData=manualSettingsObj->getData();
|
manualSettingsData=manualSettingsObj->getData();
|
||||||
connect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
connect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
||||||
m_config->wzNext->setEnabled(false);
|
m_config->wzNext->setEnabled(false);
|
||||||
}
|
}
|
||||||
else if(step==wizardIdentifyCenter || (isSimple && step==wizardIdentifySticks))
|
else if(step==wizardIdentifyCenter || (isSimple && step==wizardIdentifySticks))
|
||||||
{
|
{
|
||||||
if(wizardStep==wizardChooseMode)
|
|
||||||
{
|
|
||||||
QRadioButton * 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();
|
|
||||||
}
|
|
||||||
setTxMovement(centerAll);
|
setTxMovement(centerAll);
|
||||||
if(wizardStep==wizardIdentifySticks)
|
if(wizardStep==wizardIdentifySticks)
|
||||||
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
||||||
@ -528,9 +550,41 @@ void ConfigInputWidget::setupWizardWidget(int step)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unfortunately order of channel should be different in different conditions
|
||||||
|
*/
|
||||||
|
int ConfigInputWidget::getChannelFromStep(int currentStep)
|
||||||
|
{
|
||||||
|
int channelToSet;
|
||||||
|
if(transmitterType == heli) {
|
||||||
|
// For heli swap order of collective to beginning
|
||||||
|
qDebug() << "Transmitter type: " << heli << " channelToSet: " << currentStep;
|
||||||
|
if(currentStep == 0)
|
||||||
|
channelToSet = ManualControlSettings::CHANNELGROUPS_COLLECTIVE;
|
||||||
|
else if(currentStep <= ManualControlSettings::CHANNELGROUPS_COLLECTIVE)
|
||||||
|
channelToSet = currentStep - 1;
|
||||||
|
else channelToSet = currentStep;
|
||||||
|
qDebug() << "Channel to set: " << channelToSet;
|
||||||
|
} else
|
||||||
|
channelToSet = currentStep;
|
||||||
|
|
||||||
|
Q_ASSERT(channelToSet >= 0 && channelToSet < ManualControlSettings::CHANNELGROUPS_NUMELEM);
|
||||||
|
|
||||||
|
if(channelToSet == ManualControlSettings::CHANNELGROUPS_COLLECTIVE)
|
||||||
|
m_config->wzText->setText(QString(tr("Please enable throttle hold mode and move the collective pitch 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(channelToSet)));
|
||||||
|
|
||||||
|
return channelToSet;
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigInputWidget::identifyControls()
|
void ConfigInputWidget::identifyControls()
|
||||||
{
|
{
|
||||||
static int debounce=0;
|
static int debounce=0;
|
||||||
|
|
||||||
|
int channelToSet = getChannelFromStep(currentCommand);
|
||||||
|
|
||||||
receiverActivityData=receiverActivityObj->getData();
|
receiverActivityData=receiverActivityObj->getData();
|
||||||
if(receiverActivityData.ActiveChannel==255)
|
if(receiverActivityData.ActiveChannel==255)
|
||||||
return;
|
return;
|
||||||
@ -548,22 +602,21 @@ void ConfigInputWidget::identifyControls()
|
|||||||
debounce=0;
|
debounce=0;
|
||||||
usedChannels.append(lastChannel);
|
usedChannels.append(lastChannel);
|
||||||
manualSettingsData=manualSettingsObj->getData();
|
manualSettingsData=manualSettingsObj->getData();
|
||||||
manualSettingsData.ChannelGroups[currentCommand]=currentChannel.group;
|
manualSettingsData.ChannelGroups[channelToSet]=currentChannel.group;
|
||||||
manualSettingsData.ChannelNumber[currentCommand]=currentChannel.number;
|
manualSettingsData.ChannelNumber[channelToSet]=currentChannel.number;
|
||||||
manualSettingsObj->setData(manualSettingsData);
|
manualSettingsObj->setData(manualSettingsData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
++currentCommand;
|
++currentCommand;
|
||||||
setMoveFromCommand(currentCommand);
|
channelToSet = getChannelFromStep(currentCommand);
|
||||||
|
setMoveFromCommand(channelToSet);
|
||||||
if(currentCommand>ManualControlSettings::CHANNELGROUPS_NUMELEM-1)
|
if(currentCommand>ManualControlSettings::CHANNELGROUPS_NUMELEM-1)
|
||||||
{
|
{
|
||||||
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
||||||
m_config->wzNext->setEnabled(true);
|
m_config->wzNext->setEnabled(true);
|
||||||
}
|
}
|
||||||
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->getFields().at(0)->getElementNames().at(currentCommand)));
|
|
||||||
if(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(currentCommand).contains("Accessory") ||
|
if(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(currentCommand).contains("Accessory") ||
|
||||||
manualSettingsObj->getField("ChannelGroups")->getElementNames().at(currentCommand).contains("Collective"))
|
manualSettingsObj->getField("ChannelGroups")->getElementNames().at(currentCommand).contains("Collective"))
|
||||||
{
|
{
|
||||||
@ -607,6 +660,13 @@ void ConfigInputWidget::setMoveFromCommand(int command)
|
|||||||
else
|
else
|
||||||
setTxMovement(moveRightVerticalStick);
|
setTxMovement(moveRightVerticalStick);
|
||||||
}
|
}
|
||||||
|
else if(command==ManualControlSettings::CHANNELNUMBER_COLLECTIVE)
|
||||||
|
{
|
||||||
|
if(transmitterMode==mode2)
|
||||||
|
setTxMovement(moveLeftVerticalStick);
|
||||||
|
else
|
||||||
|
setTxMovement(moveRightVerticalStick);
|
||||||
|
}
|
||||||
else if(command==ManualControlSettings::CHANNELNUMBER_FLIGHTMODE)
|
else if(command==ManualControlSettings::CHANNELNUMBER_FLIGHTMODE)
|
||||||
{
|
{
|
||||||
setTxMovement(moveFlightMode);
|
setTxMovement(moveFlightMode);
|
||||||
|
@ -52,10 +52,11 @@ class ConfigInputWidget: public ConfigTaskWidget
|
|||||||
public:
|
public:
|
||||||
ConfigInputWidget(QWidget *parent = 0);
|
ConfigInputWidget(QWidget *parent = 0);
|
||||||
~ConfigInputWidget();
|
~ConfigInputWidget();
|
||||||
enum wizardSteps{wizardWelcome,wizardChooseMode,wizardIdentifySticks,wizardIdentifyCenter,wizardIdentifyLimits,wizardIdentifyInverted,wizardFinish};
|
enum wizardSteps{wizardWelcome,wizardChooseMode,wizardChooseType,wizardIdentifySticks,wizardIdentifyCenter,wizardIdentifyLimits,wizardIdentifyInverted,wizardFinish};
|
||||||
enum txMode{mode1,mode2};
|
enum txMode{mode1,mode2};
|
||||||
enum txMovements{moveLeftVerticalStick,moveRightVerticalStick,moveLeftHorizontalStick,moveRightHorizontalStick,moveAccess0,moveAccess1,moveAccess2,moveFlightMode,centerAll,moveAll,nothing};
|
enum txMovements{moveLeftVerticalStick,moveRightVerticalStick,moveLeftHorizontalStick,moveRightHorizontalStick,moveAccess0,moveAccess1,moveAccess2,moveFlightMode,centerAll,moveAll,nothing};
|
||||||
enum txMovementType{vertical,horizontal,jump,mix};
|
enum txMovementType{vertical,horizontal,jump,mix};
|
||||||
|
enum txType {acro, heli};
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -68,6 +69,7 @@ private:
|
|||||||
void setupWizardWidget(int step);
|
void setupWizardWidget(int step);
|
||||||
QList<QWidget*> extraWidgets;
|
QList<QWidget*> extraWidgets;
|
||||||
txMode transmitterMode;
|
txMode transmitterMode;
|
||||||
|
txType transmitterType;
|
||||||
struct channelsStruct
|
struct channelsStruct
|
||||||
{
|
{
|
||||||
bool operator ==(const channelsStruct& rhs) const
|
bool operator ==(const channelsStruct& rhs) const
|
||||||
@ -118,6 +120,7 @@ private:
|
|||||||
void setMoveFromCommand(int command);
|
void setMoveFromCommand(int command);
|
||||||
bool isSimple;
|
bool isSimple;
|
||||||
void goToWizard();
|
void goToWizard();
|
||||||
|
int getChannelFromStep(int);
|
||||||
private slots:
|
private slots:
|
||||||
void wzNext();
|
void wzNext();
|
||||||
void wzBack();
|
void wzBack();
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="advancedPage">
|
<widget class="QWidget" name="advancedPage">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
@ -79,13 +79,6 @@
|
|||||||
<height>70</height>
|
<height>70</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>10</pointsize>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>TextLabel</string>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user