1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge branch 'rel-nano-15.05' into corvuscorax/fixedwingautotakeofftest

This commit is contained in:
Corvus Corax 2015-06-05 15:17:35 +02:00
commit 96f58605ec
8 changed files with 434 additions and 345 deletions

View File

@ -42,6 +42,7 @@
#include <gpsvelocitysensor.h>
#include <homelocation.h>
#include <auxmagsensor.h>
#include <auxmagsettings.h>
#include <gyrostate.h>
#include <accelstate.h>
@ -254,7 +255,7 @@ static const filterPipeline *ekf13Queue = &(filterPipeline) {
static void settingsUpdatedCb(UAVObjEvent *objEv);
static void sensorUpdatedCb(UAVObjEvent *objEv);
static void homeLocationUpdatedCb(UAVObjEvent *objEv);
static void criticalConfigUpdatedCb(UAVObjEvent *objEv);
static void StateEstimationCb(void);
static inline int32_t maxint32_t(int32_t a, int32_t b)
@ -289,10 +290,12 @@ int32_t StateEstimationInitialize(void)
AirspeedStateInitialize();
PositionStateInitialize();
VelocityStateInitialize();
AuxMagSettingsInitialize();
RevoSettingsConnectCallback(&settingsUpdatedCb);
HomeLocationConnectCallback(&homeLocationUpdatedCb);
HomeLocationConnectCallback(&criticalConfigUpdatedCb);
AuxMagSettingsConnectCallback(&criticalConfigUpdatedCb);
GyroSensorConnectCallback(&sensorUpdatedCb);
AccelSensorConnectCallback(&sensorUpdatedCb);
@ -538,9 +541,9 @@ static void settingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
}
/**
* Callback for eventdispatcher when HomeLocation has been updated
* Callback for eventdispatcher when HomeLocation or other critical configs (auxmagsettings, ...) has been updated
*/
static void homeLocationUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
static void criticalConfigUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
{
// Ask for a filter init (necessary for LLA filter)
// Only possible if disarmed

View File

@ -66,6 +66,7 @@ ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(paren
addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_ui->cbMainComSpeed);
addWidgetBinding("HwSettings", "TelemetrySpeed", m_ui->cbRcvrTelemSpeed);
addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_ui->cbRcvrComSpeed);
// Add Gps protocol configuration
addWidgetBinding("GPSSettings", "DataProtocol", m_ui->cbMainGPSProtocol);
@ -121,7 +122,8 @@ void ConfigRevoHWWidget::updateObjectsFromWidgets()
// If any port is configured to be GPS port, enable GPS module if it is not enabled.
// Otherwise disable GPS module.
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_GPS || m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_GPS) {
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS)
|| isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS)) {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_ENABLED;
} else {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_DISABLED;
@ -134,44 +136,40 @@ void ConfigRevoHWWidget::usbVCPPortChanged(int index)
{
Q_UNUSED(index);
bool vcpComBridgeEnabled = m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_COMBRIDGE;
bool vcpComBridgeEnabled = isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_COMBRIDGE);
m_ui->lblUSBVCPSpeed->setVisible(vcpComBridgeEnabled);
m_ui->cbUSBVCPSpeed->setVisible(vcpComBridgeEnabled);
if (!vcpComBridgeEnabled && m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_COMBRIDGE) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (!vcpComBridgeEnabled && isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
m_ui->cbFlexi->model()->setData(m_ui->cbFlexi->model()->index(HwSettings::RM_FLEXIPORT_COMBRIDGE, 0),
!vcpComBridgeEnabled ? QVariant(0) : QVariant(1 | 32), Qt::UserRole - 1);
enableComboBoxOptionItem(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_COMBRIDGE, vcpComBridgeEnabled);
if (!vcpComBridgeEnabled && m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_COMBRIDGE) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (!vcpComBridgeEnabled && isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
m_ui->cbMain->model()->setData(m_ui->cbMain->model()->index(HwSettings::RM_MAINPORT_COMBRIDGE, 0),
!vcpComBridgeEnabled ? QVariant(0) : QVariant(1 | 32), Qt::UserRole - 1);
enableComboBoxOptionItem(m_ui->cbMain, HwSettings::RM_MAINPORT_COMBRIDGE, vcpComBridgeEnabled);
if (!vcpComBridgeEnabled && m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_COMBRIDGE) {
m_ui->cbRcvr->setCurrentIndex(HwSettings::RM_RCVRPORT_DISABLED);
if (!vcpComBridgeEnabled && isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
m_ui->cbRcvr->model()->setData(m_ui->cbRcvr->model()->index(HwSettings::RM_RCVRPORT_COMBRIDGE, 0),
!vcpComBridgeEnabled ? QVariant(0) : QVariant(1 | 32), Qt::UserRole - 1);
enableComboBoxOptionItem(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_COMBRIDGE, vcpComBridgeEnabled);
// _DEBUGCONSOLE modes are mutual exclusive
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE) {
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_DEBUGCONSOLE) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DEBUGCONSOLE)) {
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_DEBUGCONSOLE) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
}
// _USBTELEMETRY modes are mutual exclusive
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_USBTELEMETRY) {
if (m_ui->cbUSBHIDFunction->currentIndex() == HwSettings::USB_HIDPORT_USBTELEMETRY) {
m_ui->cbUSBHIDFunction->setCurrentIndex(HwSettings::USB_HIDPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_USBTELEMETRY)
&& isComboboxOptionSelected(m_ui->cbUSBHIDFunction, HwSettings::USB_HIDPORT_USBTELEMETRY)) {
setComboboxSelectedOption(m_ui->cbUSBHIDFunction, HwSettings::USB_HIDPORT_DISABLED);
}
}
@ -180,10 +178,9 @@ void ConfigRevoHWWidget::usbHIDPortChanged(int index)
Q_UNUSED(index);
// _USBTELEMETRY modes are mutual exclusive
if (m_ui->cbUSBHIDFunction->currentIndex() == HwSettings::USB_HIDPORT_USBTELEMETRY) {
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_USBTELEMETRY) {
m_ui->cbUSBVCPFunction->setCurrentIndex(HwSettings::USB_VCPPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbUSBHIDFunction, HwSettings::USB_HIDPORT_USBTELEMETRY)
&& isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_USBTELEMETRY)) {
setComboboxSelectedOption(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DISABLED);
}
}
@ -200,15 +197,15 @@ void ConfigRevoHWWidget::flexiPortChanged(int index)
m_ui->cbFlexiGPSProtocol->setVisible(false);
m_ui->lbFlexiGPSProtocol->setVisible(false);
switch (m_ui->cbFlexi->currentIndex()) {
switch (getComboboxSelectedOption(m_ui->cbFlexi)) {
case HwSettings::RM_FLEXIPORT_TELEMETRY:
m_ui->cbFlexiTelemSpeed->setVisible(true);
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_TELEMETRY) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
if (m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_PPMTELEMETRY
|| m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_TELEMETRY) {
m_ui->cbRcvr->setCurrentIndex(HwSettings::RM_RCVRPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_PPMTELEMETRY)
|| isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
break;
case HwSettings::RM_FLEXIPORT_GPS:
@ -217,23 +214,26 @@ void ConfigRevoHWWidget::flexiPortChanged(int index)
m_ui->lbFlexiGPSProtocol->setVisible(true);
m_ui->cbFlexiGPSSpeed->setVisible(true);
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_GPS) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
break;
case HwSettings::RM_FLEXIPORT_COMBRIDGE:
m_ui->cbFlexiComSpeed->setVisible(true);
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_COMBRIDGE) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
break;
case HwSettings::RM_FLEXIPORT_DEBUGCONSOLE:
m_ui->cbFlexiComSpeed->setVisible(true);
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_DEBUGCONSOLE) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE) {
m_ui->cbUSBVCPFunction->setCurrentIndex(HwSettings::USB_VCPPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DISABLED);
}
break;
default:
@ -255,15 +255,15 @@ void ConfigRevoHWWidget::mainPortChanged(int index)
m_ui->cbMainGPSProtocol->setVisible(false);
m_ui->lbMainGPSProtocol->setVisible(false);
switch (m_ui->cbMain->currentIndex()) {
switch (getComboboxSelectedOption(m_ui->cbMain)) {
case HwSettings::RM_MAINPORT_TELEMETRY:
m_ui->cbMainTelemSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_PPMTELEMETRY
|| m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_TELEMETRY) {
m_ui->cbRcvr->setCurrentIndex(HwSettings::RM_RCVRPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_PPMTELEMETRY)
|| isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
break;
case HwSettings::RM_MAINPORT_GPS:
@ -272,23 +272,26 @@ void ConfigRevoHWWidget::mainPortChanged(int index)
m_ui->lbMainGPSProtocol->setVisible(true);
m_ui->cbMainGPSSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_GPS) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
break;
case HwSettings::RM_MAINPORT_COMBRIDGE:
m_ui->cbMainComSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_COMBRIDGE) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
break;
case HwSettings::RM_MAINPORT_DEBUGCONSOLE:
m_ui->cbMainComSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_DEBUGCONSOLE) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE) {
m_ui->cbUSBVCPFunction->setCurrentIndex(HwSettings::USB_VCPPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DISABLED);
}
break;
default:
@ -300,23 +303,33 @@ void ConfigRevoHWWidget::mainPortChanged(int index)
void ConfigRevoHWWidget::rcvrPortChanged(int index)
{
Q_UNUSED(index);
m_ui->lblRcvrSpeed->setVisible(true);
m_ui->cbRcvrTelemSpeed->setVisible(false);
m_ui->cbRcvrComSpeed->setVisible(false);
switch (m_ui->cbRcvr->currentIndex()) {
switch (getComboboxSelectedOption(m_ui->cbRcvr)) {
case HwSettings::RM_RCVRPORT_TELEMETRY:
case HwSettings::RM_RCVRPORT_PPMTELEMETRY:
m_ui->lblRcvrSpeed->setVisible(true);
m_ui->cbRcvrTelemSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (m_ui->cbMain->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_FLEXIPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_FLEXIPORT_DISABLED);
}
break;
case HwSettings::RM_RCVRPORT_COMBRIDGE:
m_ui->cbRcvrComSpeed->setVisible(true);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
break;
default:
m_ui->lblRcvrSpeed->setVisible(false);
m_ui->cbRcvrTelemSpeed->setVisible(false);
break;
}
}

View File

@ -121,9 +121,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-87</y>
<width>789</width>
<height>847</height>
<y>-148</y>
<width>796</width>
<height>804</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
@ -232,130 +232,8 @@
</spacer>
</item>
<item row="2" column="2">
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">
<item row="22" column="1">
<widget class="QLabel" name="lbFlexiGPSProtocol">
<property name="text">
<string>Protocol</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="24" column="3">
<widget class="QComboBox" name="cbMainGPSProtocol"/>
</item>
<item row="24" column="1">
<widget class="QComboBox" name="cbFlexiGPSProtocol"/>
</item>
<item row="25" column="2">
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="20" column="3">
<widget class="QLabel" name="lblMainSpeed">
<property name="text">
<string>Speed</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="14" column="5">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="17" column="5">
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="15" column="5">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="25" column="3">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>120</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="13" column="5">
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="21" column="3">
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">
<item row="15" column="3">
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
@ -375,10 +253,10 @@
</item>
</layout>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QComboBox" name="cbRcvr"/>
</item>
<item row="1" column="0">
<item row="0" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -394,7 +272,65 @@
</property>
</spacer>
</item>
<item row="18" column="0">
<item row="14" column="3" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lblMainSpeed">
<property name="text">
<string>Speed</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="8" column="5">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="11" column="5">
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="17" column="1">
<widget class="QComboBox" name="cbFlexiGPSProtocol"/>
</item>
<item row="18" column="2">
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -410,7 +346,7 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<item row="1" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -426,7 +362,10 @@
</property>
</widget>
</item>
<item row="11" column="5">
<item row="13" column="3">
<widget class="QComboBox" name="cbMain"/>
</item>
<item row="5" column="5" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -442,7 +381,7 @@
</property>
</widget>
</item>
<item row="20" column="1">
<item row="14" column="1" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lblFlexiSpeed">
<property name="text">
<string>Speed</string>
@ -452,7 +391,7 @@
</property>
</widget>
</item>
<item row="18" column="5">
<item row="12" column="5">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -468,17 +407,81 @@
</property>
</spacer>
</item>
<item row="19" column="3">
<widget class="QComboBox" name="cbMain"/>
<item row="13" column="1">
<widget class="QComboBox" name="cbFlexi"/>
</item>
<item row="12" column="5">
<item row="6" column="5">
<widget class="QComboBox" name="cbSonar">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="25" column="4">
<item row="16" column="1" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lbFlexiGPSProtocol">
<property name="text">
<string>Protocol</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="17" column="3">
<widget class="QComboBox" name="cbMainGPSProtocol"/>
</item>
<item row="9" column="5">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="18" column="3">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>120</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="5">
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="18" column="4">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -494,7 +497,7 @@
</property>
</spacer>
</item>
<item row="16" column="5">
<item row="10" column="5">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -510,7 +513,7 @@
</property>
</spacer>
</item>
<item row="18" column="3">
<item row="12" column="3" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Main Port</string>
@ -520,10 +523,7 @@
</property>
</widget>
</item>
<item row="19" column="1">
<widget class="QComboBox" name="cbFlexi"/>
</item>
<item row="18" column="1">
<item row="12" column="1" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Flexi Port</string>
@ -533,7 +533,7 @@
</property>
</widget>
</item>
<item row="1" column="1" rowspan="17" colspan="4" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<item row="0" column="1" rowspan="12" colspan="4" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -564,7 +564,7 @@
</property>
</widget>
</item>
<item row="21" column="1">
<item row="15" column="1">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>0</number>
@ -584,7 +584,7 @@
</item>
</layout>
</item>
<item row="25" column="1">
<item row="18" column="1">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -600,7 +600,7 @@
</property>
</spacer>
</item>
<item row="22" column="3">
<item row="16" column="3" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lbMainGPSProtocol">
<property name="text">
<string>Protocol</string>
@ -610,7 +610,7 @@
</property>
</widget>
</item>
<item row="18" column="4">
<item row="12" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -626,11 +626,14 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<property name="spacing">
<number>0</number>
</property>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lblRcvrSpeed">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -649,31 +652,24 @@
<item>
<widget class="QComboBox" name="cbRcvrTelemSpeed"/>
</item>
<item>
<widget class="QComboBox" name="cbRcvrComSpeed"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_11">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="15" column="0">
<item row="9" column="0">
<widget class="QComboBox" name="cbUSBVCPSpeed">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="14" column="0">
<item row="7" column="0">
<widget class="QComboBox" name="cbUSBVCPFunction"/>
</item>
<item row="8" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lblUSBVCPSpeed">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -689,10 +685,10 @@
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QComboBox" name="cbUSBVCPFunction"/>
<item row="5" column="0">
<widget class="QComboBox" name="cbUSBHIDFunction"/>
</item>
<item row="12" column="0">
<item row="6" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -708,10 +704,7 @@
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QComboBox" name="cbUSBHIDFunction"/>
</item>
<item row="10" column="0">
<item row="4" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">

View File

@ -68,6 +68,7 @@ ConfigRevoNanoHWWidget::ConfigRevoNanoHWWidget(QWidget *parent) : ConfigTaskWidg
addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_ui->cbMainComSpeed);
addWidgetBinding("HwSettings", "TelemetrySpeed", m_ui->cbRcvrTelemSpeed);
addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_ui->cbRcvrComSpeed);
// Add Gps protocol configuration
addWidgetBinding("GPSSettings", "DataProtocol", m_ui->cbMainGPSProtocol);
@ -118,7 +119,8 @@ void ConfigRevoNanoHWWidget::updateObjectsFromWidgets()
// If any port is configured to be GPS port, enable GPS module if it is not enabled.
// Otherwise disable GPS module.
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_GPS || m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_GPS) {
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS)
|| isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS)) {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_ENABLED;
} else {
data.OptionalModules[HwSettings::OPTIONALMODULES_GPS] = HwSettings::OPTIONALMODULES_DISABLED;
@ -131,38 +133,40 @@ void ConfigRevoNanoHWWidget::usbVCPPortChanged(int index)
{
Q_UNUSED(index);
bool vcpComBridgeEnabled = m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_COMBRIDGE;
bool vcpComBridgeEnabled = isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_COMBRIDGE);
m_ui->lblUSBVCPSpeed->setVisible(vcpComBridgeEnabled);
m_ui->cbUSBVCPSpeed->setVisible(vcpComBridgeEnabled);
if (!vcpComBridgeEnabled && m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_COMBRIDGE) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (!vcpComBridgeEnabled && isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
m_ui->cbFlexi->model()->setData(m_ui->cbFlexi->model()->index(HwSettings::RM_FLEXIPORT_COMBRIDGE, 0),
!vcpComBridgeEnabled ? QVariant(0) : QVariant(1 | 32), Qt::UserRole - 1);
enableComboBoxOptionItem(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_COMBRIDGE, vcpComBridgeEnabled);
if (!vcpComBridgeEnabled && m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_COMBRIDGE) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (!vcpComBridgeEnabled && isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
m_ui->cbMain->model()->setData(m_ui->cbMain->model()->index(HwSettings::RM_MAINPORT_COMBRIDGE, 0),
!vcpComBridgeEnabled ? QVariant(0) : QVariant(1 | 32), Qt::UserRole - 1);
enableComboBoxOptionItem(m_ui->cbMain, HwSettings::RM_MAINPORT_COMBRIDGE, vcpComBridgeEnabled);
if (!vcpComBridgeEnabled && isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
enableComboBoxOptionItem(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_COMBRIDGE, vcpComBridgeEnabled);
// _DEBUGCONSOLE modes are mutual exclusive
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE) {
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_DEBUGCONSOLE) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DEBUGCONSOLE)) {
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_DEBUGCONSOLE) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
}
// _USBTELEMETRY modes are mutual exclusive
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_USBTELEMETRY) {
if (m_ui->cbUSBHIDFunction->currentIndex() == HwSettings::USB_HIDPORT_USBTELEMETRY) {
m_ui->cbUSBHIDFunction->setCurrentIndex(HwSettings::USB_HIDPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_USBTELEMETRY)
&& isComboboxOptionSelected(m_ui->cbUSBHIDFunction, HwSettings::USB_HIDPORT_USBTELEMETRY)) {
setComboboxSelectedOption(m_ui->cbUSBHIDFunction, HwSettings::USB_HIDPORT_DISABLED);
}
}
@ -171,10 +175,9 @@ void ConfigRevoNanoHWWidget::usbHIDPortChanged(int index)
Q_UNUSED(index);
// _USBTELEMETRY modes are mutual exclusive
if (m_ui->cbUSBHIDFunction->currentIndex() == HwSettings::USB_HIDPORT_USBTELEMETRY) {
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_USBTELEMETRY) {
m_ui->cbUSBVCPFunction->setCurrentIndex(HwSettings::USB_VCPPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbUSBHIDFunction, HwSettings::USB_HIDPORT_USBTELEMETRY)
&& isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_USBTELEMETRY)) {
setComboboxSelectedOption(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DISABLED);
}
}
@ -191,15 +194,15 @@ void ConfigRevoNanoHWWidget::flexiPortChanged(int index)
m_ui->cbFlexiGPSProtocol->setVisible(false);
m_ui->lbFlexiGPSProtocol->setVisible(false);
switch (m_ui->cbFlexi->currentIndex()) {
switch (getComboboxSelectedOption(m_ui->cbFlexi)) {
case HwSettings::RM_FLEXIPORT_TELEMETRY:
m_ui->cbFlexiTelemSpeed->setVisible(true);
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_TELEMETRY) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
if (m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_PPMTELEMETRY
|| m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_TELEMETRY) {
m_ui->cbRcvr->setCurrentIndex(HwSettings::RM_RCVRPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_PPMTELEMETRY)
|| isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
break;
case HwSettings::RM_FLEXIPORT_GPS:
@ -208,23 +211,26 @@ void ConfigRevoNanoHWWidget::flexiPortChanged(int index)
m_ui->lbFlexiGPSProtocol->setVisible(true);
m_ui->cbFlexiGPSSpeed->setVisible(true);
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_GPS) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_GPS)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
break;
case HwSettings::RM_FLEXIPORT_COMBRIDGE:
m_ui->cbFlexiComSpeed->setVisible(true);
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_COMBRIDGE) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
break;
case HwSettings::RM_FLEXIPORT_DEBUGCONSOLE:
m_ui->cbFlexiComSpeed->setVisible(true);
if (m_ui->cbMain->currentIndex() == HwSettings::RM_MAINPORT_DEBUGCONSOLE) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_MAINPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE) {
m_ui->cbUSBVCPFunction->setCurrentIndex(HwSettings::USB_VCPPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DISABLED);
}
break;
default:
@ -246,15 +252,15 @@ void ConfigRevoNanoHWWidget::mainPortChanged(int index)
m_ui->cbMainGPSProtocol->setVisible(false);
m_ui->lbMainGPSProtocol->setVisible(false);
switch (m_ui->cbMain->currentIndex()) {
switch (getComboboxSelectedOption(m_ui->cbMain)) {
case HwSettings::RM_MAINPORT_TELEMETRY:
m_ui->cbMainTelemSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_PPMTELEMETRY
|| m_ui->cbRcvr->currentIndex() == HwSettings::RM_RCVRPORT_TELEMETRY) {
m_ui->cbRcvr->setCurrentIndex(HwSettings::RM_RCVRPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_PPMTELEMETRY)
|| isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
break;
case HwSettings::RM_MAINPORT_GPS:
@ -263,23 +269,26 @@ void ConfigRevoNanoHWWidget::mainPortChanged(int index)
m_ui->lbMainGPSProtocol->setVisible(true);
m_ui->cbMainGPSSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_GPS) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_GPS)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
break;
case HwSettings::RM_MAINPORT_COMBRIDGE:
m_ui->cbMainComSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_COMBRIDGE) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbRcvr, HwSettings::RM_RCVRPORT_DISABLED);
}
break;
case HwSettings::RM_MAINPORT_DEBUGCONSOLE:
m_ui->cbMainComSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_DEBUGCONSOLE) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (m_ui->cbUSBVCPFunction->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE) {
m_ui->cbUSBVCPFunction->setCurrentIndex(HwSettings::USB_VCPPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DEBUGCONSOLE)) {
setComboboxSelectedOption(m_ui->cbUSBVCPFunction, HwSettings::USB_VCPPORT_DISABLED);
}
break;
default:
@ -292,22 +301,33 @@ void ConfigRevoNanoHWWidget::rcvrPortChanged(int index)
{
Q_UNUSED(index);
switch (m_ui->cbRcvr->currentIndex()) {
m_ui->lblRcvrSpeed->setVisible(true);
m_ui->cbRcvrTelemSpeed->setVisible(false);
m_ui->cbRcvrComSpeed->setVisible(false);
switch (getComboboxSelectedOption(m_ui->cbRcvr)) {
case HwSettings::RM_RCVRPORT_TELEMETRY:
case HwSettings::RM_RCVRPORT_PPMTELEMETRY:
m_ui->lblRcvrSpeed->setVisible(true);
m_ui->cbRcvrTelemSpeed->setVisible(true);
if (m_ui->cbFlexi->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) {
m_ui->cbFlexi->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (m_ui->cbMain->currentIndex() == HwSettings::RM_FLEXIPORT_TELEMETRY) {
m_ui->cbMain->setCurrentIndex(HwSettings::RM_FLEXIPORT_DISABLED);
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_FLEXIPORT_TELEMETRY)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_FLEXIPORT_DISABLED);
}
break;
case HwSettings::RM_RCVRPORT_COMBRIDGE:
m_ui->cbRcvrComSpeed->setVisible(true);
if (isComboboxOptionSelected(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbFlexi, HwSettings::RM_FLEXIPORT_DISABLED);
}
if (isComboboxOptionSelected(m_ui->cbMain, HwSettings::RM_MAINPORT_COMBRIDGE)) {
setComboboxSelectedOption(m_ui->cbMain, HwSettings::RM_MAINPORT_DISABLED);
}
break;
default:
m_ui->lblRcvrSpeed->setVisible(false);
m_ui->cbRcvrTelemSpeed->setVisible(false);
break;
}
}

View File

@ -232,7 +232,7 @@
</spacer>
</item>
<item row="2" column="2">
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0">
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">
<item row="4" column="0">
<widget class="QLabel" name="lblUSBVCPSpeed">
<property name="sizePolicy">
@ -302,6 +302,13 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QComboBox" name="cbUSBVCPSpeed">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
@ -334,19 +341,12 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QComboBox" name="cbUSBVCPSpeed">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0" alignment="Qt::AlignTop">
<widget class="QComboBox" name="cbRcvrTelemSpeed"/>
</item>
<item row="9" column="0">
<widget class="QComboBox" name="cbRcvr"/>
</item>
<item row="9" column="2" colspan="2">
<widget class="QComboBox" name="cbMain"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
@ -373,8 +373,8 @@
</property>
</widget>
</item>
<item row="9" column="2" colspan="2">
<widget class="QComboBox" name="cbMain"/>
<item row="14" column="2" colspan="2">
<widget class="QComboBox" name="cbMainGPSProtocol"/>
</item>
<item row="10" column="2" colspan="2">
<widget class="QLabel" name="lblMainSpeed">
@ -406,7 +406,10 @@
</item>
</layout>
</item>
<item row="12" column="2" colspan="2">
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="cbFlexiGPSProtocol"/>
</item>
<item row="13" column="2" colspan="2">
<widget class="QLabel" name="lbMainGPSProtocol">
<property name="text">
<string>Protocol</string>
@ -416,12 +419,6 @@
</property>
</widget>
</item>
<item row="13" column="2" colspan="2">
<widget class="QComboBox" name="cbMainGPSProtocol"/>
</item>
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="cbFlexiGPSProtocol"/>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="lbFlexiGPSProtocol">
<property name="text">
@ -435,6 +432,9 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="cbFlexi"/>
</item>
<item row="3" column="1" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
@ -455,6 +455,16 @@
</item>
</layout>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Flexi Port</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLabel" name="lblFlexiSpeed">
<property name="text">
@ -465,18 +475,34 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="cbFlexi"/>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Flexi Port</string>
<item row="11" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
<property name="topMargin">
<number>0</number>
</property>
</widget>
<item>
<widget class="QComboBox" name="cbRcvrTelemSpeed"/>
</item>
<item alignment="Qt::AlignTop">
<widget class="QComboBox" name="cbRcvrComSpeed"/>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
@ -683,8 +709,8 @@ Beware of not locking yourself out!</string>
</layout>
</widget>
<resources>
<include location="configgadget.qrc"/>
<include location="../coreplugin/core.qrc"/>
<include location="configgadget.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -209,6 +209,39 @@ ConfigTaskWidget::~ConfigTaskWidget()
}
}
bool ConfigTaskWidget::isComboboxOptionSelected(QComboBox *combo, int optionValue)
{
bool ok;
int value = combo->currentData().toInt(&ok);
return ok ? value == optionValue : false;
}
int ConfigTaskWidget::getComboboxSelectedOption(QComboBox *combo)
{
bool ok;
int index = combo->currentData().toInt(&ok);
return ok ? index : -1;
}
void ConfigTaskWidget::setComboboxSelectedOption(QComboBox *combo, int optionValue)
{
int index = combo->findData(QVariant(optionValue));
if (index != -1) {
combo->setCurrentIndex(index);
}
}
int ConfigTaskWidget::getComboboxIndexForOption(QComboBox *combo, int optionValue)
{
return combo->findData(QVariant(optionValue));
}
void ConfigTaskWidget::enableComboBoxOptionItem(QComboBox *combo, int optionValue, bool enable)
{
combo->model()->setData(combo->model()->index(getComboboxIndexForOption(combo, optionValue), 0),
!enable ? QVariant(0) : QVariant(1 | 32), Qt::UserRole - 1);
}
void ConfigTaskWidget::saveObjectToSD(UAVObject *obj)
{
// saveObjectToSD is now handled by the UAVUtils plugin in one
@ -858,7 +891,7 @@ QVariant ConfigTaskWidget::getVariantFromWidget(QWidget *widget, WidgetBinding *
if (QComboBox * cb = qobject_cast<QComboBox *>(widget)) {
if (binding->isInteger()) {
return cb->currentIndex();
return QVariant(getComboboxSelectedOption(cb));
}
return (QString)cb->currentText();
} else if (QDoubleSpinBox * cb = qobject_cast<QDoubleSpinBox *>(widget)) {
@ -889,7 +922,7 @@ bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, Wid
if (QComboBox * cb = qobject_cast<QComboBox *>(widget)) {
bool ok = true;
if (binding->isInteger()) {
cb->setCurrentIndex(value.toInt(&ok));
setComboboxSelectedOption(cb, value.toInt(&ok));
} else {
cb->setCurrentIndex(cb->findText(value.toString()));
}
@ -1004,22 +1037,16 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget *widget, UAVObjectField *field,
}
if (QComboBox * cb = qobject_cast<QComboBox *>(widget)) {
cb->clear();
QStringList option = field->getOptions();
if (hasLimits) {
// Only add options to combo box if we have a board id to check limits for.
// We could enter this method while there is no board connected and without
// this check, we would add all the board dependent options whether they were
// valid or not. Ultimately this method will be called again when the connected
// signal is handled.
if (m_currentBoardId > -1) {
foreach(QString str, option) {
if (field->isWithinLimits(str, index, m_currentBoardId)) {
cb->addItem(str);
}
QStringList options = field->getOptions();
for(int optionIndex = 0; optionIndex < options.count(); optionIndex++) {
if (hasLimits) {
if (m_currentBoardId > -1 && field->isWithinLimits(options.at(optionIndex), index, m_currentBoardId)) {
cb->addItem(options.at(optionIndex), QVariant(optionIndex));
}
} else {
cb->addItem(options.at(optionIndex), QVariant(optionIndex));
}
} else {
cb->addItems(option);
}
}
if (!hasLimits) {

View File

@ -104,6 +104,13 @@ public:
ConfigTaskWidget(QWidget *parent = 0);
virtual ~ConfigTaskWidget();
// Combobox helper functions
static bool isComboboxOptionSelected(QComboBox *combo, int optionValue);
static int getComboboxSelectedOption(QComboBox *combo);
static void setComboboxSelectedOption(QComboBox *combo, int optionValue);
static int getComboboxIndexForOption(QComboBox *combo, int optionValue);
static void enableComboBoxOptionItem(QComboBox *combo, int optionValue, bool enable);
void disableMouseWheelEvents();
bool eventFilter(QObject *obj, QEvent *evt);

View File

@ -10,7 +10,7 @@
<field name="RM_RcvrPort" units="function" type="enum" elements="1" options="Disabled,PWM,PPM,PPM+PWM,PPM+Telemetry,PPM+Outputs,Outputs,Telemetry,ComBridge"
defaultvalue="PWM"
limits="%0905NE:PPM+PWM:PPM+Telemetry:Telemetry;"/>
limits="%0905NE:PPM+PWM:PPM+Telemetry:Telemetry:ComBridge;"/>
<field name="RM_MainPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,GPS,S.Bus,DSM,DebugConsole,ComBridge,OsdHk" defaultvalue="Disabled"/>
<field name="RM_FlexiPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,GPS,I2C,DSM,SRXL,DebugConsole,ComBridge,OsdHk" defaultvalue="Disabled"/>