1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

OP-1222 Added code to handle port conflicts in configuration.

This commit is contained in:
m_thread 2014-09-05 17:31:41 +02:00
parent 1d50f9e949
commit 73d1217cc7
14 changed files with 102 additions and 48 deletions

View File

@ -35,6 +35,20 @@ AirSpeedPage::AirSpeedPage(SetupWizard *wizard, QWidget *parent) :
AirSpeedPage::~AirSpeedPage()
{}
void AirSpeedPage::initializePage(VehicleConfigurationSource *settings)
{
// Enable all
setItemDisabled(-1, false);
if (settings->getInputType() == VehicleConfigurationSource::INPUT_SBUS ||
settings->getInputType() == VehicleConfigurationSource::INPUT_DSM2 ||
settings->getInputType() == VehicleConfigurationSource::INPUT_DSMX10 ||
settings->getInputType() == VehicleConfigurationSource::INPUT_DSMX11) {
// Disable non estimated sensors if ports are taken by receivers
setItemDisabled(VehicleConfigurationSource::AIRSPEED_EAGLETREE, true);
setItemDisabled(VehicleConfigurationSource::AIRSPEED_MS4525, true);
}
}
bool AirSpeedPage::validatePage(SelectionItem *selectedItem)
{
getWizard()->setAirspeedType((SetupWizard::AIRSPEED_TYPE)selectedItem->id());
@ -46,7 +60,9 @@ void AirSpeedPage::setupSelection(Selection *selection)
selection->setTitle(tr("OpenPilot Airspeed Sensor Selection"));
selection->setText(tr("This part of the wizard will help you select and configure a way to obtain "
"airspeed data. OpenPilot support three methods to achieve this, one is a "
"software estimation technique and the other two utilize hardware sensors.\n\n"
"software estimation technique and the other two utilize hardware sensors.\n"
"Note: if previously selected input combinations use the Flexi-port for input, "
"only estimated airspeed will be avilible.\n\n"
"Please select how you wish to obtain airspeed data below:"));
selection->addItem(tr("Estimated"),
tr("This option uses an intelligent estimation algorithm which utilizes the OpenPilot INS/GPS "
@ -54,19 +70,20 @@ void AirSpeedPage::setupSelection(Selection *selection)
"This solution is highly accurate in normal level flight with the drawback of being less "
"accurate in rapid altitude changes.\n\n"),
"estimated-airspeed-sensor",
SetupWizard::ESTIMATE);
SetupWizard::AIRSPEED_ESTIMATE);
selection->addItem(tr("EagleTree"),
tr("Select this option to use the Airspeed MicroSensor V3 from EagleTree, this is an accurate "
"airspeed sensor that includes on-board Temperature Compensation.\n\n"
"Selecting this option will set your board's Flexi-Port in to I2C mode."),
"eagletree-speed-sensor",
SetupWizard::EAGLETREE);
SetupWizard::AIRSPEED_EAGLETREE);
selection->addItem(tr("MS4525 Based"),
tr("Select this option to use an airspeed sensor based on the MS4525DO pressure transducer "
"from Measurement Specialties. This includes the PixHawk sensor and their clones.\n\n"
"Selecting this option will set your board's Flexi-Port in to I2C mode."),
"ms4525-speed-sensor",
SetupWizard::MS4525);
SetupWizard::AIRSPEED_MS4525);
}

View File

@ -37,9 +37,11 @@ public:
explicit AirSpeedPage(SetupWizard *wizard, QWidget *parent = 0);
~AirSpeedPage();
public:
protected:
void initializePage(VehicleConfigurationSource *settings);
bool validatePage(SelectionItem *selectedItem);
void setupSelection(Selection *selection);
};
#endif // AIRSPEEDPAGE_H

View File

@ -35,6 +35,11 @@ FixedWingPage::FixedWingPage(SetupWizard *wizard, QWidget *parent) :
FixedWingPage::~FixedWingPage()
{}
void FixedWingPage::initializePage(VehicleConfigurationSource *settings)
{
Q_UNUSED(settings);
}
bool FixedWingPage::validatePage(SelectionItem *selectedItem)
{
getWizard()->setVehicleSubType((SetupWizard::VEHICLE_SUB_TYPE)selectedItem->id());

View File

@ -37,7 +37,8 @@ public:
explicit FixedWingPage(SetupWizard *wizard, QWidget *parent = 0);
~FixedWingPage();
public:
protected:
void initializePage(VehicleConfigurationSource *settings);
bool validatePage(SelectionItem *selectedItem);
void setupSelection(Selection *selection);
};

View File

@ -35,6 +35,11 @@ GpsPage::GpsPage(SetupWizard *wizard, QWidget *parent) :
GpsPage::~GpsPage()
{}
void GpsPage::initializePage(VehicleConfigurationSource *settings)
{
Q_UNUSED(settings);
}
bool GpsPage::validatePage(SelectionItem *selectedItem)
{
getWizard()->setGpsType((SetupWizard::GPS_TYPE)selectedItem->id());
@ -60,7 +65,7 @@ void GpsPage::setupSelection(Selection *selection)
"and Microcontroller connected to the Main Port of your controller.\n\n"
"Note: for the OpenPilot v8 GPS please select the U-Blox option."),
"OPGPS-v9",
SetupWizard::GPS_PLAT);
SetupWizard::GPS_PLATINUM);
selection->addItem(tr("U-Blox Based"),
tr("Select this option for the OpenPilot V8 GPS or generic U-Blox chipset GPSs connected"

View File

@ -38,6 +38,7 @@ public:
~GpsPage();
public:
void initializePage(VehicleConfigurationSource *settings);
bool validatePage(SelectionItem *selectedItem);
void setupSelection(Selection *selection);
};

View File

@ -35,6 +35,11 @@ MultiPage::MultiPage(SetupWizard *wizard, QWidget *parent) :
MultiPage::~MultiPage()
{}
void MultiPage::initializePage(VehicleConfigurationSource *settings)
{
Q_UNUSED(settings);
}
bool MultiPage::validatePage(SelectionItem *selectedItem)
{
getWizard()->setVehicleSubType((SetupWizard::VEHICLE_SUB_TYPE)selectedItem->id());

View File

@ -37,7 +37,8 @@ public:
explicit MultiPage(SetupWizard *wizard, QWidget *parent = 0);
virtual ~MultiPage();
public:
protected:
void initializePage(VehicleConfigurationSource *settings);
bool validatePage(SelectionItem *selectedItem);
void setupSelection(Selection *selection);
};

View File

@ -68,6 +68,7 @@ void SelectionPage::initializePage()
ui->typeCombo->setCurrentIndex(0);
}
}
initializePage(getWizard());
}
bool SelectionPage::validatePage()
@ -104,9 +105,9 @@ void SelectionPage::selectionChanged(int index)
fitImage();
}
void SelectionPage::addItem(QString name, QString description, QString shapeId, int id)
void SelectionPage::addItem(QString name, QString description, QString shapeId, int id, bool disabled)
{
m_selectionItems << new SelectionItem(name, description, shapeId, id);
m_selectionItems << new SelectionItem(name, description, shapeId, id, disabled);
}
void SelectionPage::setTitle(QString title)
@ -119,6 +120,16 @@ void SelectionPage::setText(QString text)
ui->text->setText(text);
}
SelectionItem::SelectionItem(QString name, QString description, QString shapeId, int id) :
m_name(name), m_description(description), m_shapeId(shapeId), m_id(id)
void SelectionPage::setItemDisabled(int id, bool disabled)
{
for (int i = 0; i < m_selectionItems.count(); i++) {
if (id < 0 || m_selectionItems.at(i)->id() == id) {
m_selectionItems.at(i)->setDisabled(disabled);
ui->typeCombo->setItemData(i, disabled ? 0 : 33, Qt::UserRole - 1);
}
}
}
SelectionItem::SelectionItem(QString name, QString description, QString shapeId, int id, bool disabled) :
m_name(name), m_description(description), m_shapeId(shapeId), m_id(id), m_disabled(disabled)
{}

View File

@ -40,8 +40,7 @@ class SelectionPage;
class SelectionItem {
public:
SelectionItem(QString name, QString description, QString shapeId, int id);
// ~SelectionItem();
SelectionItem(QString name, QString description, QString shapeId, int id, bool disabled = false);
QString name()
{
@ -59,20 +58,28 @@ public:
{
return m_id;
}
void setDisabled(bool disabled) {
m_disabled = disabled;
}
bool disabled() {
return m_disabled;
}
private:
QString m_name;
QString m_description;
QString m_shapeId;
int m_id;
bool m_disabled;
};
class Selection {
public:
Selection() {}
virtual void addItem(QString name, QString description, QString shapeId, int id) = 0;
virtual void addItem(QString name, QString description, QString shapeId, int id, bool disabled = false) = 0;
virtual void setTitle(QString title) = 0;
virtual void setText(QString text) = 0;
virtual void setItemDisabled(int id, bool disabled) = 0;
};
class SelectionPage : public AbstractWizardPage, public Selection {
@ -84,14 +91,15 @@ public:
void initializePage();
bool validatePage();
void addItem(QString name, QString description, QString shapeId, int id);
void addItem(QString name, QString description, QString shapeId, int id, bool disabled = false);
void setTitle(QString title);
void setText(QString text);
virtual void setupSelection(Selection *selection) = 0;
virtual bool validatePage(SelectionItem *selectedItem) = 0;
void setItemDisabled(int id, bool disabled);
protected:
virtual void setupSelection(Selection *selection) = 0;
virtual void initializePage(VehicleConfigurationSource *settings) = 0;
virtual bool validatePage(SelectionItem *selectedItem) = 0;
void resizeEvent(QResizeEvent *event);
void showEvent(QShowEvent *event);

View File

@ -20,15 +20,14 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;OpenPilot Configuration Summary&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;The first part of this wizard is now complete. All information required to create a basic OpenPilot controller configuration for a specific vehicle has been collected.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Below is a summary of the configuration and a button that links to a diagram illustrating how to connect required hardware and the OpenPilot Controller with the current configuration.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;To continue the wizard and go through some basic configuration steps, please continue to the next step of this wizard.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;The following steps require that your OpenPilot controller is set up according to the diagram, it is &lt;/span&gt;&lt;span style=&quot; font-size:10pt; font-weight:600;&quot;&gt;connected to the computer&lt;/span&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt; by USB, and that the vehicle is&lt;/span&gt;&lt;span style=&quot; font-size:10pt; font-weight:600;&quot;&gt; powered by a battery&lt;/span&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;&quot;&gt;OpenPilot Configuration Summary&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt;&quot;&gt;The first part of this wizard is now complete. All information required to create a basic OpenPilot controller configuration for a specific vehicle has been collected.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt;&quot;&gt;Below is a summary of the configuration and a button that links to a diagram illustrating how to connect required hardware and the OpenPilot Controller with the current configuration.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt;&quot;&gt;To continue the wizard and go through some basic configuration steps, please continue to the next step of this wizard.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt;&quot;&gt;The following steps require that your OpenPilot controller is set up according to the diagram, it is &lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;&quot;&gt;connected to the computer&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt;&quot;&gt; by USB, and that the vehicle is&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;&quot;&gt; powered by a battery&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@ -78,8 +77,8 @@ p, li { white-space: pre-wrap; }
</property>
<property name="iconSize">
<size>
<width>150</width>
<height>150</height>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="checkable">

View File

@ -88,6 +88,7 @@ int SetupWizard::nextId() const
case CONTROLLER_CC:
case CONTROLLER_CC3D:
case CONTROLLER_REVO:
case CONTROLLER_NANO:
return PAGE_INPUT;
case CONTROLLER_OPLINK:
@ -159,8 +160,6 @@ int SetupWizard::nextId() const
case PAGE_BIAS_CALIBRATION:
return PAGE_OUTPUT_CALIBRATION;
// case PAGE_REVO_CALIBRATION:
// return PAGE_OUTPUT_CALIBRATION;
case PAGE_OUTPUT_CALIBRATION:
return PAGE_AIRFRAME_INITIAL_TUNING;
@ -170,8 +169,11 @@ int SetupWizard::nextId() const
case PAGE_GPS:
switch (getVehicleType()) {
case VEHICLE_FIXEDWING:
return PAGE_AIRSPEED;
if (getGpsType() != GPS_DISABLED) {
return PAGE_AIRSPEED;
} else {
return PAGE_SUMMARY;
}
default:
return PAGE_SUMMARY;
}
@ -185,10 +187,10 @@ int SetupWizard::nextId() const
case CONTROLLER_CC:
case CONTROLLER_CC3D:
case CONTROLLER_REVO:
case CONTROLLER_NANO:
switch (getVehicleType()) {
case VEHICLE_FIXEDWING:
return PAGE_OUTPUT_CALIBRATION;
default:
return PAGE_BIAS_CALIBRATION;
}
@ -222,6 +224,9 @@ QString SetupWizard::getSummaryText()
case CONTROLLER_REVO:
summary.append(tr("OpenPilot Revolution"));
break;
case CONTROLLER_NANO:
summary.append(tr("OpenPilot Nano"));
break;
case CONTROLLER_OPLINK:
summary.append(tr("OpenPilot OPLink Radio Modem"));
break;
@ -368,7 +373,7 @@ QString SetupWizard::getSummaryText()
summary.append("<br>");
summary.append("<b>").append(tr("GPS type: ")).append("</b>");
switch (getGpsType()) {
case GPS_PLAT:
case GPS_PLATINUM:
summary.append(tr("OpenPilot Platinum"));
break;
case GPS_UBX:
@ -387,25 +392,19 @@ QString SetupWizard::getSummaryText()
summary.append("<br>");
summary.append("<b>").append(tr("Airspeed Sensor: ")).append("</b>");
switch (getAirspeedType()) {
case ESTIMATE:
case AIRSPEED_ESTIMATE:
summary.append(tr("Software Estimated"));
break;
case EAGLETREE:
case AIRSPEED_EAGLETREE:
summary.append(tr("EagleTree on Flexi-Port"));
break;
case MS4525:
case AIRSPEED_MS4525:
summary.append(tr("MS4525 based on Flexi-Port"));
break;
default:
summary.append(tr("Unknown"));
}
}
/*
summary.append("<br>");
summary.append("<b>").append(tr("Reboot required: ")).append("</b>");
summary.append(isRestartNeeded() ? tr("<font color='red'>Yes</font>") : tr("<font color='green'>No</font>"));
*/
return summary;
}
@ -425,7 +424,6 @@ void SetupWizard::createPages()
setPage(PAGE_ESC, new EscPage(this));
setPage(PAGE_SERVO, new ServoPage(this));
setPage(PAGE_BIAS_CALIBRATION, new BiasCalibrationPage(this));
// setPage(PAGE_REVO_CALIBRATION, new RevoCalibrationPage(this));
setPage(PAGE_OUTPUT_CALIBRATION, new OutputCalibrationPage(this));
setPage(PAGE_SUMMARY, new SummaryPage(this));
setPage(PAGE_SAVE, new SavePage(this));

View File

@ -152,6 +152,7 @@ void VehicleConfigurationHelper::applyHardwareConfiguration()
}
break;
case VehicleConfigurationSource::CONTROLLER_REVO:
case VehicleConfigurationSource::CONTROLLER_NANO:
// Reset all ports
data.RM_RcvrPort = HwSettings::RM_RCVRPORT_DISABLED;

View File

@ -64,8 +64,8 @@ public:
enum ESC_TYPE { ESC_RAPID, ESC_STANDARD, ESC_UNKNOWN };
enum SERVO_TYPE { SERVO_ANALOG, SERVO_DIGITAL, SERVO_UNKNOWN };
enum INPUT_TYPE { INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSMX10, INPUT_DSMX11, INPUT_DSM2, INPUT_UNKNOWN };
enum AIRSPEED_TYPE { ESTIMATE, EAGLETREE, MS4525 };
enum GPS_TYPE { GPS_PLAT, GPS_UBX, GPS_NMEA, GPS_DISABLED };
enum AIRSPEED_TYPE { AIRSPEED_ESTIMATE, AIRSPEED_EAGLETREE, AIRSPEED_MS4525, AIRSPEED_DISABLED };
enum GPS_TYPE { GPS_PLATINUM, GPS_UBX, GPS_NMEA, GPS_DISABLED };
enum RADIO_SETTING { RADIO_TELEMETRY, RADIO_DISABLED };
virtual VehicleConfigurationSource::CONTROLLER_TYPE getControllerType() const = 0;