From b93ff6bd89a14e2f0f9749283b1e79e20f5bf12c Mon Sep 17 00:00:00 2001 From: Fredrik Larson Date: Wed, 3 Sep 2014 07:16:36 +1000 Subject: [PATCH] Make a start on GPS page --- .../setupwizard/pages/airspeedpage.cpp | 4 +- .../src/plugins/setupwizard/pages/gpspage.cpp | 76 +++++++++++++++++++ .../src/plugins/setupwizard/pages/gpspage.h | 45 +++++++++++ .../src/plugins/setupwizard/setupwizard.cpp | 35 +++++++-- .../src/plugins/setupwizard/setupwizard.h | 12 +-- .../src/plugins/setupwizard/setupwizard.pro | 2 + .../setupwizard/vehicleconfigurationsource.h | 4 +- 7 files changed, 162 insertions(+), 16 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/gpspage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/gpspage.h diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.cpp index 3166cd735..f47b98ad4 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.cpp @@ -60,14 +60,14 @@ void AirSpeedPage::setupSelection(Selection *selection) 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 put your Flexi-Port in to I2C mode."), + "Selecting this option will set your board's Flexi-Port in to I2C mode."), "eagletree", SetupWizard::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 put your Flexi-Port in to I2C mode."), + "Selecting this option will set your board's Flexi-Port in to I2C mode."), "ms4525", SetupWizard::MS4525); } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/gpspage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/gpspage.cpp new file mode 100644 index 000000000..18531e84e --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/gpspage.cpp @@ -0,0 +1,76 @@ +/** + ****************************************************************************** + * + * @file fixedwingpage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup FixedWingPage + * @{ + * @brief + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "gpspage.h" +#include "setupwizard.h" + +GpsPage::GpsPage(SetupWizard *wizard, QWidget *parent) : + SelectionPage(wizard, QString(":/setupwizard/resources/airspeed-shapes.svg"), parent) +{} + +GpsPage::~GpsPage() +{} + +bool GpsPage::validatePage(SelectionItem *seletedItem) +{ + getWizard()->setGpsType((SetupWizard::GPS_TYPE)seletedItem->id()); + return true; +} + +void GpsPage::setupSelection(Selection *selection) +{ + selection->setTitle(tr("OpenPilot GPS Selection")); + selection->setText(tr("Please select the type of GPS you have below. As well as OpenPilot hardware " + "OpenPilot works hard to support 3rd party GPSs as well, although performance could + "be less than with using OpenPilot produced hardware; not all GPSs are created equal.\n\n" + "Please select your GPS type data below:")); + + selection->addItem(tr("Disabled"), + tr("GPS Features are not to be enabled"), + "disabled", + SetupWizard::GPS_DISABLED); + + selection->addItem(tr("OpenPilot Platinum"), + tr("Select this option to use the OpenPilot Platinum GPS with integrated Magnetometer " + "and Microcontroller connected to the Main Port of your controller.\n\n" + "Note: for the OpenPilot v8 GPS please select the U-Blox option."), + "platinum", + SetupWizard::GPS_PLAT); + + selection->addItem(tr("U-Blox Based"), + tr("Select this option for the OpenPilot V8 GPS or generic U-Blox chipset GPSs connected" + "to the Main Port of your controller."), + "ublox", + SetupWizard::GPS_UBX); + + selection->addItem(tr("NMEA Based"), + tr("Select this option for a generic NMEA based GPS connected to the Main Port of your" + "controller."), + "nmea", + SetupWizard::GPS_NMEA); + +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/gpspage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/gpspage.h new file mode 100644 index 000000000..6ef3512fa --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/gpspage.h @@ -0,0 +1,45 @@ +/** + ****************************************************************************** + * + * @file fixedwingpage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup FixedWingPage + * @{ + * @brief + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GPSPAGE_H +#define GPSPAGE_H + +#include "selectionpage.h" + +class GpsPage : public SelectionPage { + Q_OBJECT + +public: + explicit GpsPage(SetupWizard *wizard, QWidget *parent = 0); + ~GpsPage(); + +public: + bool validatePage(SelectionItem *seletedItem); + void setupSelection(Selection *selection); +}; + +#endif // GPSPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index cfe121966..3716147c4 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -33,6 +33,7 @@ #include "pages/multipage.h" #include "pages/fixedwingpage.h" #include "pages/airspeedpage.h" +#include "pages/gpspage.h" #include "pages/helipage.h" #include "pages/surfacepage.h" #include "pages/inputpage.h" @@ -133,11 +134,23 @@ int SetupWizard::nextId() const if (getVehicleSubType() == MULTI_ROTOR_TRI_Y) { return PAGE_SERVO; } else { - return PAGE_SUMMARY; - } + switch (getControllerType()) { + case CONTROLLER_REVO: + return PAGE_GPS; + default: + return PAGE_SUMMARY; + } + } case PAGE_SERVO: - return PAGE_SUMMARY; + { + switch (getControllerType()) { + case CONTROLLER_REVO: + return PAGE_GPS; + default: + return PAGE_SUMMARY; + } + } case PAGE_BIAS_CALIBRATION: return PAGE_OUTPUT_CALIBRATION; @@ -148,9 +161,9 @@ int SetupWizard::nextId() const { switch (getVehicleType()) { case VEHICLE_FIXEDWING: - return PAGE_AIRSPEED; + return PAGE_AIRFRAMESTAB_FIXEDWING; - // TODO: Pages for Multi and heli + // TODO: PID selection pages for multi and heli case VEHICLE_MULTI: case VEHICLE_HELI: case VEHICLE_SURFACE: @@ -159,8 +172,17 @@ int SetupWizard::nextId() const } } + + case PAGE_GPS: + switch (getVehicleType()) { + case VEHICLE_FIXEDWING: + return PAGE_AIRSPEED; + default: + return PAGE_SUMMARY; + } + case PAGE_AIRSPEED: - return PAGE_AIRFRAMESTAB_FIXEDWING; + return PAGE_SUMMARY; case PAGE_AIRFRAMESTAB_FIXEDWING: return PAGE_SAVE; @@ -364,6 +386,7 @@ void SetupWizard::createPages() setPage(PAGE_MULTI, new MultiPage(this)); setPage(PAGE_FIXEDWING, new FixedWingPage(this)); setPage(PAGE_AIRSPEED, new AirSpeedPage(this)); + setPage(PAGE_GPS, new GpsPage(this)); setPage(PAGE_HELI, new HeliPage(this)); setPage(PAGE_SURFACE, new SurfacePage(this)); setPage(PAGE_INPUT, new InputPage(this)); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h index ef4561567..8fb9fd325 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h @@ -106,13 +106,13 @@ public: } - void setGPSSetting(SetupWizard::GPS_SETTING setting) + void setGpsType(SetupWizard::GPS_TYPE setting) { - m_gpsSetting = setting; + m_gpsType = setting; } - SetupWizard::GPS_SETTING getGPSSetting() const + SetupWizard::GPS_TYPE getGpsType() const { - return m_gpsSetting; + return m_gpsType; } void setRadioSetting(SetupWizard::RADIO_SETTING setting) @@ -175,7 +175,7 @@ private slots: void pageChanged(int currId); private: enum { PAGE_START, PAGE_CONTROLLER, PAGE_VEHICLES, PAGE_MULTI, PAGE_FIXEDWING, - PAGE_AIRSPEED, PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_ESC, PAGE_SERVO, + PAGE_AIRSPEED, PAGE_GPS, PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_ESC, PAGE_SERVO, PAGE_BIAS_CALIBRATION, PAGE_REVO_CALIBRATION, PAGE_OUTPUT_CALIBRATION, PAGE_SAVE, PAGE_SUMMARY, PAGE_NOTYETIMPLEMENTED, PAGE_AIRFRAMESTAB_FIXEDWING, PAGE_REBOOT, PAGE_END, PAGE_UPDATE }; @@ -190,7 +190,7 @@ private: ESC_TYPE m_escType; SERVO_TYPE m_servoType; AIRSPEED_TYPE m_airspeedType; - GPS_SETTING m_gpsSetting; + GPS_TYPE m_gpsType; RADIO_SETTING m_radioSetting; bool m_calibrationPerformed; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index ae895118a..eec6f4e69 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -20,6 +20,7 @@ HEADERS += setupwizardplugin.h \ pages/multipage.h \ pages/fixedwingpage.h \ pages/airspeedpage.h \ + pages/gpspage.h \ pages/helipage.h \ pages/surfacepage.h \ pages/abstractwizardpage.h \ @@ -51,6 +52,7 @@ SOURCES += setupwizardplugin.cpp \ pages/multipage.cpp \ pages/fixedwingpage.cpp \ pages/airspeedpage.cpp \ + pages/gpspage.cpp \ pages/helipage.cpp \ pages/surfacepage.cpp \ pages/abstractwizardpage.cpp \ diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h index 90f70114f..7b7f66b0a 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h @@ -65,7 +65,7 @@ public: 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_SETTING { GPS_PLAT, GPS_UBX, GPS_NMEA, GPS_DISABLED }; + enum GPS_TYPE { GPS_PLAT, GPS_UBX, GPS_NMEA, GPS_DISABLED }; enum RADIO_SETTING { RADIO_TELEMETRY, RADIO_DISABLED }; virtual VehicleConfigurationSource::CONTROLLER_TYPE getControllerType() const = 0; @@ -75,7 +75,7 @@ public: virtual VehicleConfigurationSource::ESC_TYPE getEscType() const = 0; virtual VehicleConfigurationSource::SERVO_TYPE getServoType() const = 0; virtual VehicleConfigurationSource::AIRSPEED_TYPE getAirspeedType() const = 0; - virtual VehicleConfigurationSource::GPS_SETTING getGPSSetting() const = 0; + virtual VehicleConfigurationSource::GPS_TYPE getGpsType() const = 0; virtual VehicleConfigurationSource::RADIO_SETTING getRadioSetting() const = 0; virtual bool isCalibrationPerformed() const = 0;