mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
OP-1808 1.Make flight mode stick identification to be optional. 2. Refine some code.
This commit is contained in:
parent
4bd2e889ce
commit
5b76f4f96b
@ -416,18 +416,18 @@ void ConfigInputWidget::goToWizard()
|
|||||||
// chooses a different TX type (which could otherwise result in
|
// chooses a different TX type (which could otherwise result in
|
||||||
// unexpected TX channels being enabled)
|
// unexpected TX channels being enabled)
|
||||||
manualSettingsData = manualSettingsObj->getData();
|
manualSettingsData = manualSettingsObj->getData();
|
||||||
previousManualSettingsData = manualSettingsData;
|
memento.manualSettingsData = manualSettingsData;
|
||||||
flightModeSettingsData = flightModeSettingsObj->getData();
|
flightModeSettingsData = flightModeSettingsObj->getData();
|
||||||
previousFlightModeSettingsData = flightModeSettingsData;
|
memento.flightModeSettingsData = flightModeSettingsData;
|
||||||
flightModeSettingsData.Arming = FlightModeSettings::ARMING_ALWAYSDISARMED;
|
flightModeSettingsData.Arming = FlightModeSettings::ARMING_ALWAYSDISARMED;
|
||||||
flightModeSettingsObj->setData(flightModeSettingsData);
|
flightModeSettingsObj->setData(flightModeSettingsData);
|
||||||
// Stash actuatorSettings
|
// Stash actuatorSettings
|
||||||
actuatorSettingsData = actuatorSettingsObj->getData();
|
actuatorSettingsData = actuatorSettingsObj->getData();
|
||||||
previousActuatorSettingsData = actuatorSettingsData;
|
memento.actuatorSettingsData = actuatorSettingsData;
|
||||||
|
|
||||||
// Stash systemSettings
|
// Stash systemSettings
|
||||||
systemSettingsData = systemSettingsObj->getData();
|
systemSettingsData = systemSettingsObj->getData();
|
||||||
previousSystemSettingsData = systemSettingsData;
|
memento.systemSettingsData = systemSettingsData;
|
||||||
|
|
||||||
// Now reset channel and actuator settings (disable outputs)
|
// Now reset channel and actuator settings (disable outputs)
|
||||||
resetChannelSettings();
|
resetChannelSettings();
|
||||||
@ -469,10 +469,10 @@ void ConfigInputWidget::wzCancel()
|
|||||||
ui->stackedWidget->setCurrentIndex(0);
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
// Load settings back from beginning of wizard
|
// Load settings back from beginning of wizard
|
||||||
manualSettingsObj->setData(previousManualSettingsData);
|
manualSettingsObj->setData(memento.manualSettingsData);
|
||||||
flightModeSettingsObj->setData(previousFlightModeSettingsData);
|
flightModeSettingsObj->setData(memento.flightModeSettingsData);
|
||||||
actuatorSettingsObj->setData(previousActuatorSettingsData);
|
actuatorSettingsObj->setData(memento.actuatorSettingsData);
|
||||||
systemSettingsObj->setData(previousSystemSettingsData);
|
systemSettingsObj->setData(memento.systemSettingsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigInputWidget::registerControlActivity()
|
void ConfigInputWidget::registerControlActivity()
|
||||||
@ -555,7 +555,7 @@ void ConfigInputWidget::wzNext()
|
|||||||
restoreMdata();
|
restoreMdata();
|
||||||
|
|
||||||
// Load actuator settings back from beginning of wizard
|
// Load actuator settings back from beginning of wizard
|
||||||
actuatorSettingsObj->setData(previousActuatorSettingsData);
|
actuatorSettingsObj->setData(memento.actuatorSettingsData);
|
||||||
|
|
||||||
// Force flight mode neutral to middle and Throttle neutral at 4%
|
// Force flight mode neutral to middle and Throttle neutral at 4%
|
||||||
adjustSpecialNeutrals();
|
adjustSpecialNeutrals();
|
||||||
@ -802,6 +802,12 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
|
|||||||
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(identifyControls()));
|
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(identifyControls()));
|
||||||
wizardUi->wzNext->setEnabled(true);
|
wizardUi->wzNext->setEnabled(true);
|
||||||
setTxMovement(nothing);
|
setTxMovement(nothing);
|
||||||
|
/* If flight mode stick isn't identified, force flight mode number to be 1 */
|
||||||
|
manualSettingsData = manualSettingsObj->getData();
|
||||||
|
if (manualSettingsData.ChannelGroups[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE] ==
|
||||||
|
ManualControlSettings::CHANNELGROUPS_NONE) {
|
||||||
|
forceOneFlightMode();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case wizardIdentifyCenter:
|
case wizardIdentifyCenter:
|
||||||
manualCommandData = manualCommandObj->getData();
|
manualCommandData = manualCommandObj->getData();
|
||||||
@ -882,21 +888,32 @@ void ConfigInputWidget::restoreMdata()
|
|||||||
*/
|
*/
|
||||||
void ConfigInputWidget::setChannel(int newChan)
|
void ConfigInputWidget::setChannel(int newChan)
|
||||||
{
|
{
|
||||||
|
bool canBeSkipped(false);
|
||||||
|
|
||||||
if (newChan == ManualControlSettings::CHANNELGROUPS_COLLECTIVE) {
|
if (newChan == ManualControlSettings::CHANNELGROUPS_COLLECTIVE) {
|
||||||
wizardUi->identifyStickInstructions->setText(QString(tr("Please enable throttle hold mode.\n\nMove the Collective Pitch stick.")));
|
wizardUi->identifyStickInstructions->setText(QString(tr("<p>Please enable throttle hold mode.</p>"
|
||||||
|
"<p>Move the Collective Pitch stick.</p>")));
|
||||||
} else if (newChan == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE) {
|
} else if (newChan == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE) {
|
||||||
wizardUi->identifyStickInstructions->setText(QString(tr("Please toggle the Flight Mode switch.\n\nFor switches you may have to repeat this rapidly.")));
|
wizardUi->identifyStickInstructions->setText(QString(tr("<p>Please toggle the Flight Mode switch.</p>"
|
||||||
|
"<p>For switches you may have to repeat this rapidly.</p>"
|
||||||
|
"<p>Alternatively, you can click Next to skip this channel, but you will get only <b>ONE</b> Flight Mode.</p>")));
|
||||||
|
canBeSkipped = true;
|
||||||
} else if ((transmitterType == heli) && (newChan == ManualControlSettings::CHANNELGROUPS_THROTTLE)) {
|
} else if ((transmitterType == heli) && (newChan == ManualControlSettings::CHANNELGROUPS_THROTTLE)) {
|
||||||
wizardUi->identifyStickInstructions->setText(QString(tr("Please disable throttle hold mode.\n\nMove the Throttle stick.")));
|
wizardUi->identifyStickInstructions->setText(QString(tr("<p>Please disable throttle hold mode.</p>"
|
||||||
|
"<p>Move the Throttle stick.</p>")));
|
||||||
} else {
|
} else {
|
||||||
wizardUi->identifyStickInstructions->setText(QString(tr("Please move each control one at a time according to the instructions and picture below.\n\n"
|
wizardUi->identifyStickInstructions->setText(QString(tr("<p>Please move each control one at a time according to the instructions and picture below.</p>"
|
||||||
"Move the %1 stick.")).arg(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan)));
|
"<p>Move the %1 stick.</p>")).arg(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("Accessory")) {
|
if (manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("Accessory")) {
|
||||||
|
wizardUi->identifyStickInstructions->setText(wizardUi->identifyStickInstructions->text() + tr("<p>Alternatively, click Next to skip this channel.</p>"));
|
||||||
|
canBeSkipped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true == canBeSkipped) {
|
||||||
wizardUi->wzNext->setEnabled(true);
|
wizardUi->wzNext->setEnabled(true);
|
||||||
wizardUi->wzNext->setText(tr("Next / Skip"));
|
wizardUi->wzNext->setText(tr("Next / Skip"));
|
||||||
wizardUi->identifyStickInstructions->setText(wizardUi->identifyStickInstructions->text() + tr(" Alternatively, click Next to skip this channel."));
|
|
||||||
} else {
|
} else {
|
||||||
wizardUi->wzNext->setEnabled(false);
|
wizardUi->wzNext->setEnabled(false);
|
||||||
}
|
}
|
||||||
@ -1674,7 +1691,7 @@ void ConfigInputWidget::simpleCalibration(bool enable)
|
|||||||
|
|
||||||
// Stash actuatorSettings
|
// Stash actuatorSettings
|
||||||
actuatorSettingsData = actuatorSettingsObj->getData();
|
actuatorSettingsData = actuatorSettingsObj->getData();
|
||||||
previousActuatorSettingsData = actuatorSettingsData;
|
memento.actuatorSettingsData = actuatorSettingsData;
|
||||||
|
|
||||||
// Disable all actuators
|
// Disable all actuators
|
||||||
resetActuatorSettings();
|
resetActuatorSettings();
|
||||||
@ -1720,7 +1737,7 @@ void ConfigInputWidget::simpleCalibration(bool enable)
|
|||||||
manualSettingsObj->setData(manualSettingsData);
|
manualSettingsObj->setData(manualSettingsData);
|
||||||
|
|
||||||
// Load actuator settings back from beginning of manual calibration
|
// Load actuator settings back from beginning of manual calibration
|
||||||
actuatorSettingsObj->setData(previousActuatorSettingsData);
|
actuatorSettingsObj->setData(memento.actuatorSettingsData);
|
||||||
|
|
||||||
ui->configurationWizard->setEnabled(true);
|
ui->configurationWizard->setEnabled(true);
|
||||||
ui->saveRCInputToRAM->setEnabled(true);
|
ui->saveRCInputToRAM->setEnabled(true);
|
||||||
@ -1781,6 +1798,7 @@ void ConfigInputWidget::resetChannelSettings()
|
|||||||
for (unsigned int channel = 0; channel < 9; channel++) {
|
for (unsigned int channel = 0; channel < 9; channel++) {
|
||||||
manualSettingsData.ChannelGroups[channel] = ManualControlSettings::CHANNELGROUPS_NONE;
|
manualSettingsData.ChannelGroups[channel] = ManualControlSettings::CHANNELGROUPS_NONE;
|
||||||
manualSettingsData.ChannelNumber[channel] = 0;
|
manualSettingsData.ChannelNumber[channel] = 0;
|
||||||
|
manualSettingsData.FlightModeNumber = 3;
|
||||||
manualSettingsObj->setData(manualSettingsData);
|
manualSettingsObj->setData(manualSettingsData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1819,7 +1837,7 @@ void ConfigInputWidget::resetActuatorSettings()
|
|||||||
|
|
||||||
void ConfigInputWidget::forceOneFlightMode()
|
void ConfigInputWidget::forceOneFlightMode()
|
||||||
{
|
{
|
||||||
manualCommandData = manualCommandObj->getData();
|
manualSettingsData = manualSettingsObj->getData();
|
||||||
manualSettingsData.FlightModeNumber = 1;
|
manualSettingsData.FlightModeNumber = 1;
|
||||||
manualSettingsObj->setData(manualSettingsData);
|
manualSettingsObj->setData(manualSettingsData);
|
||||||
}
|
}
|
||||||
|
@ -128,21 +128,25 @@ private:
|
|||||||
|
|
||||||
ManualControlSettings *manualSettingsObj;
|
ManualControlSettings *manualSettingsObj;
|
||||||
ManualControlSettings::DataFields manualSettingsData;
|
ManualControlSettings::DataFields manualSettingsData;
|
||||||
ManualControlSettings::DataFields previousManualSettingsData;
|
|
||||||
|
|
||||||
ActuatorSettings *actuatorSettingsObj;
|
ActuatorSettings *actuatorSettingsObj;
|
||||||
ActuatorSettings::DataFields actuatorSettingsData;
|
ActuatorSettings::DataFields actuatorSettingsData;
|
||||||
ActuatorSettings::DataFields previousActuatorSettingsData;
|
|
||||||
|
|
||||||
FlightModeSettings *flightModeSettingsObj;
|
FlightModeSettings *flightModeSettingsObj;
|
||||||
FlightModeSettings::DataFields flightModeSettingsData;
|
FlightModeSettings::DataFields flightModeSettingsData;
|
||||||
FlightModeSettings::DataFields previousFlightModeSettingsData;
|
|
||||||
ReceiverActivity *receiverActivityObj;
|
ReceiverActivity *receiverActivityObj;
|
||||||
ReceiverActivity::DataFields receiverActivityData;
|
ReceiverActivity::DataFields receiverActivityData;
|
||||||
|
|
||||||
SystemSettings *systemSettingsObj;
|
SystemSettings *systemSettingsObj;
|
||||||
SystemSettings::DataFields systemSettingsData;
|
SystemSettings::DataFields systemSettingsData;
|
||||||
SystemSettings::DataFields previousSystemSettingsData;
|
|
||||||
|
typedef struct {
|
||||||
|
ManualControlSettings::DataFields manualSettingsData;
|
||||||
|
ActuatorSettings::DataFields actuatorSettingsData;
|
||||||
|
FlightModeSettings::DataFields flightModeSettingsData;
|
||||||
|
SystemSettings::DataFields systemSettingsData;
|
||||||
|
} Memento;
|
||||||
|
Memento memento;
|
||||||
|
|
||||||
QSvgRenderer *m_renderer;
|
QSvgRenderer *m_renderer;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user