2 ******************************************************************************
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
8 * @addtogroup InputPage
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "inputpage.h"
29 #include "ui_inputpage.h"
30 #include "setupwizard.h"
31 #include "extensionsystem/pluginmanager.h"
32 #include "uavobjectmanager.h"
33 #include "hwsettings.h"
35 InputPage::InputPage(SetupWizard
*wizard
, QWidget
*parent
) :
36 AbstractWizardPage(wizard
, parent
),
43 InputPage::~InputPage()
48 bool InputPage::validatePage()
50 if (ui
->pwmButton
->isChecked()) {
51 getWizard()->setInputType(SetupWizard::INPUT_PWM
);
52 } else if (ui
->ppmButton
->isChecked()) {
53 getWizard()->setInputType(SetupWizard::INPUT_PPM
);
54 } else if (ui
->sbusButton
->isChecked()) {
55 getWizard()->setInputType(SetupWizard::INPUT_SBUS
);
56 } else if (ui
->spectrumButton
->isChecked()) {
57 getWizard()->setInputType(SetupWizard::INPUT_DSM
);
58 } else if (ui
->multiplexButton
->isChecked()) {
59 getWizard()->setInputType(SetupWizard::INPUT_SRXL
);
61 getWizard()->setInputType(SetupWizard::INPUT_PWM
);
63 getWizard()->setRestartNeeded(getWizard()->isRestartNeeded() || restartNeeded(getWizard()->getInputType()));
68 bool InputPage::restartNeeded(VehicleConfigurationSource::INPUT_TYPE selectedType
)
70 ExtensionSystem::PluginManager
*pm
= ExtensionSystem::PluginManager::instance();
71 UAVObjectManager
*uavoManager
= pm
->getObject
<UAVObjectManager
>();
73 Q_ASSERT(uavoManager
);
74 HwSettings
*hwSettings
= HwSettings::GetInstance(uavoManager
);
75 HwSettings::DataFields data
= hwSettings
->getData();
76 switch (getWizard()->getControllerType()) {
77 case SetupWizard::CONTROLLER_CC
:
78 case SetupWizard::CONTROLLER_CC3D
:
80 switch (selectedType
) {
81 case VehicleConfigurationSource::INPUT_PWM
:
82 return data
.CC_RcvrPort
!= HwSettings::CC_RCVRPORT_PWMNOONESHOT
;
84 case VehicleConfigurationSource::INPUT_PPM
:
85 return data
.CC_RcvrPort
!= HwSettings::CC_RCVRPORT_PPMNOONESHOT
;
87 case VehicleConfigurationSource::INPUT_SBUS
:
88 return data
.CC_MainPort
!= HwSettings::CC_MAINPORT_SBUS
;
90 case VehicleConfigurationSource::INPUT_DSM
:
91 // TODO: Handle all of the DSM types ?? Which is most common?
92 return data
.CC_MainPort
!= HwSettings::CC_MAINPORT_DSM
;
98 case SetupWizard::CONTROLLER_REVO
:
99 case SetupWizard::CONTROLLER_DISCOVERYF4
:
100 case SetupWizard::CONTROLLER_NANO
:
102 switch (selectedType
) {
103 case VehicleConfigurationSource::INPUT_PWM
:
104 return data
.RM_RcvrPort
!= HwSettings::RM_RCVRPORT_PWM
;
106 case VehicleConfigurationSource::INPUT_PPM
:
107 return data
.RM_RcvrPort
!= HwSettings::RM_RCVRPORT_PPM
;
109 case VehicleConfigurationSource::INPUT_SBUS
:
110 return data
.RM_MainPort
!= HwSettings::RM_MAINPORT_SBUS
;
112 case VehicleConfigurationSource::INPUT_SRXL
:
113 return data
.RM_FlexiPort
!= HwSettings::RM_FLEXIPORT_SRXL
;
115 case VehicleConfigurationSource::INPUT_DSM
:
116 // TODO: Handle all of the DSM types ?? Which is most common?
117 return data
.RM_MainPort
!= HwSettings::RM_MAINPORT_DSM
;
119 default: return true;
123 default: return true;