1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-31 16:52:10 +01:00

OP-1781 Add UI stuff and basic definitions

This commit is contained in:
samguns 2015-03-17 15:51:06 +08:00
parent 5c9b6fac29
commit 22e0b88a8f
3 changed files with 46 additions and 5 deletions

View File

@ -349,6 +349,12 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
ManualControlSettings::CHANNELGROUPS_ACCESSORY1 << ManualControlSettings::CHANNELGROUPS_ACCESSORY1 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY2; ManualControlSettings::CHANNELGROUPS_ACCESSORY2;
groundChannelOrder << ManualControlSettings::CHANNELGROUPS_THROTTLE <<
ManualControlSettings::CHANNELGROUPS_YAW <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY0 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY1 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY2;
updateEnableControls(); updateEnableControls();
} }
@ -629,6 +635,8 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
wizardUi->wzBack->setEnabled(true); wizardUi->wzBack->setEnabled(true);
if (transmitterType == heli) { if (transmitterType == heli) {
wizardUi->typeHeli->setChecked(true); wizardUi->typeHeli->setChecked(true);
} else if (transmitterType == ground) {
wizardUi->typeGround->setChecked(true);
} else { } else {
wizardUi->typeAcro->setChecked(true); wizardUi->typeAcro->setChecked(true);
} }
@ -687,6 +695,9 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
case wizardIdentifyCenter: case wizardIdentifyCenter:
setTxMovement(centerAll); setTxMovement(centerAll);
wizardUi->pagesStack->setCurrentWidget(wizardUi->identifyCenterPage); wizardUi->pagesStack->setCurrentWidget(wizardUi->identifyCenterPage);
if (transmitterType == ground) {
wizardUi->identifyCenterInstructions->setText(QString(tr("Please center all controls and trims and press Next when ready.")));
}
break; break;
case wizardIdentifyLimits: case wizardIdentifyLimits:
{ {
@ -752,6 +763,8 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
case wizardChooseType: case wizardChooseType:
if (wizardUi->typeAcro->isChecked()) { if (wizardUi->typeAcro->isChecked()) {
transmitterType = acro; transmitterType = acro;
} else if (wizardUi->typeGround->isChecked()) {
transmitterType = ground;
} else { } else {
transmitterType = heli; transmitterType = heli;
} }
@ -885,7 +898,14 @@ void ConfigInputWidget::setChannel(int newChan)
*/ */
void ConfigInputWidget::nextChannel() void ConfigInputWidget::nextChannel()
{ {
QList <int> order = (transmitterType == heli) ? heliChannelOrder : acroChannelOrder; QList <int> order;
if (transmitterType == heli) {
order = heliChannelOrder;
} else if (transmitterType == ground) {
order = groundChannelOrder;
} else {
order = acroChannelOrder;
}
if (currentChannelNum == -1) { if (currentChannelNum == -1) {
setChannel(order[0]); setChannel(order[0]);
@ -906,7 +926,14 @@ void ConfigInputWidget::nextChannel()
*/ */
void ConfigInputWidget::prevChannel() void ConfigInputWidget::prevChannel()
{ {
QList <int> order = transmitterType == heli ? heliChannelOrder : acroChannelOrder; QList <int> order;
if (transmitterType == heli) {
order = heliChannelOrder;
} else if (transmitterType == ground) {
order = groundChannelOrder;
} else {
order = acroChannelOrder;
}
// No previous from unset channel or next state // No previous from unset channel or next state
if (currentChannelNum == -1) { if (currentChannelNum == -1) {
@ -1672,6 +1699,12 @@ void ConfigInputWidget::adjustSpecialNeutrals()
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE] + manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE] +
((manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE] - ((manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE] -
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]) * 0.04); manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]) * 0.04);
if (transmitterType == ground) {
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE] =
(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE] +
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]) / 2;
}
} }
void ConfigInputWidget::checkThrottleRange() void ConfigInputWidget::checkThrottleRange()

View File

@ -62,7 +62,7 @@ public:
enum txMode { mode1, mode2, mode3, mode4 }; enum txMode { mode1, mode2, mode3, mode4 };
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 }; enum txType { acro, heli, ground };
void startInputWizard() void startInputWizard()
{ {
goToWizard(); goToWizard();
@ -111,6 +111,7 @@ private:
int currentChannelNum; int currentChannelNum;
QList<int> heliChannelOrder; QList<int> heliChannelOrder;
QList<int> acroChannelOrder; QList<int> acroChannelOrder;
QList<int> groundChannelOrder;
UAVObject::Metadata manualControlMdata; UAVObject::Metadata manualControlMdata;
ManualControlCommand *manualCommandObj; ManualControlCommand *manualCommandObj;

View File

@ -14,7 +14,7 @@
<item> <item>
<widget class="QStackedWidget" name="pagesStack"> <widget class="QStackedWidget" name="pagesStack">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="welcomePage"> <widget class="QWidget" name="welcomePage">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
@ -64,6 +64,13 @@ You can press 'back' at any time to return to the previous screen or press 'Canc
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QRadioButton" name="typeGround">
<property name="text">
<string>Ground vehicle: has at least two channels for throttle and steering (yaw)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QRadioButton" name="typeHeli"> <widget class="QRadioButton" name="typeHeli">
<property name="text"> <property name="text">
@ -89,7 +96,7 @@ You can press 'back' at any time to return to the previous screen or press 'Canc
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>23</height>
</size> </size>
</property> </property>
</spacer> </spacer>