1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Merged in f5soh/librepilot/laurent/LP-114_Add_accessory_input_channel (pull request #54)

LP-114 Add accessory input channel
This commit is contained in:
Alessio Morale 2015-09-15 23:21:04 +02:00
commit 3e7a53beaf
10 changed files with 545 additions and 240 deletions

View File

@ -10,7 +10,8 @@
* pass it to ManualControl
*
* @file receiver.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @brief Receiver module. Handles safety R/C link and flight mode.
*
* @see The GNU Public License (GPL) Version 3
@ -206,6 +207,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
// this includes not even registering it if not used
AccessoryDesiredCreateInstance();
AccessoryDesiredCreateInstance();
AccessoryDesiredCreateInstance();
// Whenever the configuration changes, make sure it is safe to fly
@ -377,6 +379,10 @@ static void receiverTask(__attribute__((unused)) void *parameters)
valid_input_detected &= validInputRange(settings.ChannelMin.Accessory2,
settings.ChannelMax.Accessory2, cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ACCESSORY2]);
}
if (settings.ChannelGroups.Accessory3 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
valid_input_detected &= validInputRange(settings.ChannelMin.Accessory3,
settings.ChannelMax.Accessory3, cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ACCESSORY3]);
}
// Implement hysteresis loop on connection status
if (valid_input_detected && (++connected_count > 10)) {
@ -436,6 +442,13 @@ static void receiverTask(__attribute__((unused)) void *parameters)
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
}
}
// Set Accessory 3
if (settings.ChannelGroups.Accessory3 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
accessory.AccessoryVal = settings.FailsafeChannel.Accessory3;
if (AccessoryDesiredInstSet(3, &accessory) != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
}
}
} else if (valid_input_detected) {
AlarmsClear(SYSTEMALARMS_ALARM_RECEIVER);
@ -545,6 +558,17 @@ static void receiverTask(__attribute__((unused)) void *parameters)
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
}
}
// Set Accessory 3
if (settings.ChannelGroups.Accessory3 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
accessory.AccessoryVal = scaledChannel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ACCESSORY3];
#ifdef USE_INPUT_LPF
applyLPF(&accessory.AccessoryVal, MANUALCONTROLSETTINGS_RESPONSETIME_ACCESSORY3, &settings.ResponseTime, settings.Deadband, dT);
#endif
if (AccessoryDesiredInstSet(3, &accessory) != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
}
}
}
// Update cmd object

View File

@ -532,6 +532,13 @@ Typical value is 50% for + or X configuration on quads.</string>
<property name="leftMargin">
<number>0</number>
</property>
<item row="2" column="2">
<widget class="QComboBox" name="rcOutputCurveBox2">
<property name="toolTip">
<string>Select output curve for Accessory1 RcInput</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="rcOutputChannelBox1">
<property name="sizePolicy">
@ -752,13 +759,6 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="rcOutputCurveBox2">
<property name="toolTip">
<string>Select output curve for Accessory1 RcInput</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="rcOutputCurveBox3">
<property name="toolTip">
@ -766,6 +766,55 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_11">
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>Accessory3</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="rcOutputChannelBox4">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Select output channel for Accessory3 RcInput</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QComboBox" name="rcOutputCurveBox4">
<property name="toolTip">
<string>Select output curve for Accessory3 RcInput</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="4">
@ -805,6 +854,9 @@ margin:1px;</string>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
@ -857,6 +909,12 @@ margin:1px;</string>
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
@ -881,6 +939,12 @@ margin:1px;</string>
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
@ -905,6 +969,12 @@ margin:1px;</string>
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
@ -952,6 +1022,9 @@ margin:1px;</string>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
@ -971,6 +1044,12 @@ margin:1px;</string>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="multiMotorChannelBox1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
@ -992,6 +1071,12 @@ margin:1px;</string>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="multiMotorChannelBox2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
@ -1013,6 +1098,12 @@ margin:1px;</string>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="multiMotorChannelBox3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
@ -1034,6 +1125,12 @@ margin:1px;</string>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="multiMotorChannelBox4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file configcustomwidget.cpp
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ConfigPlugin Config Plugin
@ -123,6 +124,24 @@ QStringList ConfigCustomWidget::getChannelDescriptions()
if (custom.Servo8 > 0 && custom.Servo8 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo8 - 1] = QString("Servo8");
}
if (custom.Accessory0 > 0 && custom.Accessory0 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Accessory0 - 1] = QString("Accessory0");
}
if (custom.Accessory1 > 0 && custom.Accessory1 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Accessory1 - 1] = QString("Accessory1");
}
if (custom.Accessory2 > 0 && custom.Accessory2 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Accessory2 - 1] = QString("Accessory2");
}
if (custom.Accessory3 > 0 && custom.Accessory3 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Accessory3 - 1] = QString("Accessory3");
}
if (custom.Accessory4 > 0 && custom.Accessory4 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Accessory4 - 1] = QString("Accessory4");
}
if (custom.Accessory5 > 0 && custom.Accessory5 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Accessory5 - 1] = QString("Accessory5");
}
return channelDesc;
}
@ -198,6 +217,12 @@ void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData)
configData->custom.Servo6 = 0;
configData->custom.Servo7 = 0;
configData->custom.Servo8 = 0;
configData->custom.Accessory0 = 0;
configData->custom.Accessory1 = 0;
configData->custom.Accessory2 = 0;
configData->custom.Accessory3 = 0;
configData->custom.Accessory4 = 0;
configData->custom.Accessory5 = 0;
}
/**
@ -377,16 +402,22 @@ QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW);
} else if (q->currentText() == "Accessory0") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0);
configData.custom.Accessory0 = channel + 1;
} else if (q->currentText() == "Accessory1") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1);
configData.custom.Accessory1 = channel + 1;
} else if (q->currentText() == "Accessory2") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2);
configData.custom.Accessory2 = channel + 1;
} else if (q->currentText() == "Accessory3") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3);
configData.custom.Accessory3 = channel + 1;
} else if (q->currentText() == "Accessory4") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4);
configData.custom.Accessory4 = channel + 1;
} else if (q->currentText() == "Accessory5") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5);
configData.custom.Accessory5 = channel + 1;
}
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
m_aircraft->customMixerTable->item(1, channel)->text().toDouble());

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file configmultirotorwidget.cpp
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ConfigPlugin Config Plugin
@ -120,6 +121,9 @@ QStringList ConfigMultiRotorWidget::getChannelDescriptions()
if (multi.Accessory2 > 0 && multi.Accessory2 <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
channelDesc[multi.Accessory2 - 1] = QString("Accessory2");
}
if (multi.Accessory3 > 0 && multi.Accessory3 <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
channelDesc[multi.Accessory3 - 1] = QString("Accessory3");
}
return channelDesc;
}
@ -136,6 +140,7 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
m_aircraft->rcOutputCurveBox1->addItems(mixerCurveList);
m_aircraft->rcOutputCurveBox2->addItems(mixerCurveList);
m_aircraft->rcOutputCurveBox3->addItems(mixerCurveList);
m_aircraft->rcOutputCurveBox4->addItems(mixerCurveList);
// Setup the Multirotor picture in the Quad settings interface
m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -332,9 +337,11 @@ void ConfigMultiRotorWidget::registerWidgets(ConfigTaskWidget &parent)
parent.addWidget(m_aircraft->rcOutputChannelBox1);
parent.addWidget(m_aircraft->rcOutputChannelBox2);
parent.addWidget(m_aircraft->rcOutputChannelBox3);
parent.addWidget(m_aircraft->rcOutputChannelBox4);
parent.addWidget(m_aircraft->rcOutputCurveBox1);
parent.addWidget(m_aircraft->rcOutputCurveBox2);
parent.addWidget(m_aircraft->rcOutputCurveBox3);
parent.addWidget(m_aircraft->rcOutputCurveBox4);
}
void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData)
@ -363,6 +370,7 @@ void ConfigMultiRotorWidget::resetRcOutputs(GUIConfigDataUnion *configData)
configData->multi.Accessory0 = 0;
configData->multi.Accessory1 = 0;
configData->multi.Accessory2 = 0;
configData->multi.Accessory3 = 0;
}
void ConfigMultiRotorWidget::resetMixers()
@ -386,6 +394,7 @@ void ConfigMultiRotorWidget::updateRcCurvesUsed()
setComboCurrentIndex(m_aircraft->rcOutputCurveBox1, VehicleConfig::MIXER_THROTTLECURVE1);
setComboCurrentIndex(m_aircraft->rcOutputCurveBox2, VehicleConfig::MIXER_THROTTLECURVE1);
setComboCurrentIndex(m_aircraft->rcOutputCurveBox3, VehicleConfig::MIXER_THROTTLECURVE1);
setComboCurrentIndex(m_aircraft->rcOutputCurveBox4, VehicleConfig::MIXER_THROTTLECURVE1);
for (int channel = 0; channel < (int)ConfigMultiRotorWidget::CHANNEL_NUMELEM; channel++) {
QString mixerType = getMixerType(mixer, channel);
@ -395,6 +404,8 @@ void ConfigMultiRotorWidget::updateRcCurvesUsed()
setComboCurrentIndex(m_aircraft->rcOutputCurveBox2, VehicleConfig::MIXER_THROTTLECURVE2);
} else if (mixerType == "Accessory2" && getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2)) {
setComboCurrentIndex(m_aircraft->rcOutputCurveBox3, VehicleConfig::MIXER_THROTTLECURVE2);
} else if (mixerType == "Accessory3" && getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2)) {
setComboCurrentIndex(m_aircraft->rcOutputCurveBox4, VehicleConfig::MIXER_THROTTLECURVE2);
}
}
}
@ -511,6 +522,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
setComboCurrentIndex(m_aircraft->rcOutputChannelBox1, multi.Accessory0);
setComboCurrentIndex(m_aircraft->rcOutputChannelBox2, multi.Accessory1);
setComboCurrentIndex(m_aircraft->rcOutputChannelBox3, multi.Accessory2);
setComboCurrentIndex(m_aircraft->rcOutputChannelBox4, multi.Accessory3);
updateRcCurvesUsed();
@ -537,7 +549,7 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
resetMixers();
QList<QString> rcOutputList;
rcOutputList << "Accessory0" << "Accessory1" << "Accessory2";
rcOutputList << "Accessory0" << "Accessory1" << "Accessory2" << "Accessory3";
setupRcOutputs(rcOutputList);
// Curve is also common to all quads:
@ -880,7 +892,8 @@ void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double ro
void ConfigMultiRotorWidget::setupRcOutputs(QList<QString> rcOutputList)
{
QList<QComboBox *> rcList;
rcList << m_aircraft->rcOutputChannelBox1 << m_aircraft->rcOutputChannelBox2 << m_aircraft->rcOutputChannelBox3;
rcList << m_aircraft->rcOutputChannelBox1 << m_aircraft->rcOutputChannelBox2
<< m_aircraft->rcOutputChannelBox3 << m_aircraft->rcOutputChannelBox4;
GUIConfigDataUnion configData = getConfigData();
resetRcOutputs(&configData);
@ -891,6 +904,7 @@ void ConfigMultiRotorWidget::setupRcOutputs(QList<QString> rcOutputList)
int curveAccessory0 = m_aircraft->rcOutputCurveBox1->currentIndex();
int curveAccessory1 = m_aircraft->rcOutputCurveBox2->currentIndex();
int curveAccessory2 = m_aircraft->rcOutputCurveBox3->currentIndex();
int curveAccessory3 = m_aircraft->rcOutputCurveBox4->currentIndex();
foreach(QString rc_output, rcOutputList) {
int index = rcList.takeFirst()->currentIndex();
@ -925,6 +939,16 @@ void ConfigMultiRotorWidget::setupRcOutputs(QList<QString> rcOutputList)
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
}
}
} else if (rc_output == QString("Accessory3")) {
configData.multi.Accessory3 = index;
if (index) {
setMixerType(mixer, index - 1, VehicleConfig::MIXERTYPE_ACCESSORY3);
if (curveAccessory3) {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
} else {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
}
}
}
}
setConfigData(configData);
@ -1196,7 +1220,7 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
}
// Iterate through all instances of rcOutputChannelBox
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 5; i++) {
// Find widgets with his name "rcOutputChannelBox.x", where x is an integer
QComboBox *combobox = this->findChild<QComboBox *>("rcOutputChannelBox" + QString::number(i + 1));
if (combobox) {

View File

@ -56,7 +56,8 @@ typedef struct {
uint Accessory0 : 4;
uint Accessory1 : 4;
uint Accessory2 : 4;
quint32 padding : 16; // 96 bits
uint Accessory3 : 4;
quint32 padding : 12; // 96 bits
quint32 padding1; // 128 bits
} __attribute__((packed)) multiGUISettingsStruct;
@ -130,7 +131,13 @@ typedef struct {
uint RevMotor6 : 4;
uint RevMotor7 : 4;
uint RevMotor8 : 4; // 96 bits
quint32 padding; // 128 bits
uint Accessory0 : 4;
uint Accessory1 : 4;
uint Accessory2 : 4;
uint Accessory3 : 4;
uint Accessory4 : 4;
uint Accessory5 : 4;
uint padding : 8; // 128 bits
} __attribute__((packed)) customGUISettingsStruct;

View File

@ -65,7 +65,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
nextDelayedLatestActivityTick(0),
accessoryDesiredObj0(NULL),
accessoryDesiredObj1(NULL),
accessoryDesiredObj2(NULL)
accessoryDesiredObj2(NULL),
accessoryDesiredObj3(NULL)
{
manualCommandObj = ManualControlCommand::GetInstance(getObjectManager());
manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager());
@ -75,6 +76,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
accessoryDesiredObj0 = AccessoryDesired::GetInstance(getObjectManager(), 0);
accessoryDesiredObj1 = AccessoryDesired::GetInstance(getObjectManager(), 1);
accessoryDesiredObj2 = AccessoryDesired::GetInstance(getObjectManager(), 2);
accessoryDesiredObj3 = AccessoryDesired::GetInstance(getObjectManager(), 3);
actuatorSettingsObj = ActuatorSettings::GetInstance(getObjectManager());
systemSettingsObj = SystemSettings::GetInstance(getObjectManager());
@ -140,6 +142,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
case ManualControlSettings::CHANNELGROUPS_ACCESSORY0:
case ManualControlSettings::CHANNELGROUPS_ACCESSORY1:
case ManualControlSettings::CHANNELGROUPS_ACCESSORY2:
case ManualControlSettings::CHANNELGROUPS_ACCESSORY3:
addWidgetBinding("ManualControlSettings", "ResponseTime", form->ui->channelResponseTime, indexRT);
++indexRT;
break;
@ -262,6 +265,11 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
m_txAccess2->setSharedRenderer(m_renderer);
m_txAccess2->setElementId("access2");
m_txAccess3 = new QGraphicsSvgItem();
m_txAccess3->setParentItem(m_txBackground);
m_txAccess3->setSharedRenderer(m_renderer);
m_txAccess3->setElementId("access3");
m_txFlightMode = new QGraphicsSvgItem();
m_txFlightMode->setParentItem(m_txBackground);
m_txFlightMode->setSharedRenderer(m_renderer);
@ -330,6 +338,12 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
orig = Matrix.mapRect(orig);
m_txAccess2Orig.translate(orig.x(), orig.y());
m_txAccess2->setTransform(m_txAccess2Orig, true);
orig = m_renderer->boundsOnElement("access3");
Matrix = m_renderer->matrixForElement("access3");
orig = Matrix.mapRect(orig);
m_txAccess3Orig.translate(orig.x(), orig.y());
m_txAccess3->setTransform(m_txAccess3Orig, true);
}
wizardUi->graphicsView->fitInView(m_txMainBody, Qt::KeepAspectRatio);
animate = new QTimer(this);
@ -343,7 +357,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
ManualControlSettings::CHANNELGROUPS_FLIGHTMODE <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY0 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY1 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY2;
ManualControlSettings::CHANNELGROUPS_ACCESSORY2 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY3;
acroChannelOrder << ManualControlSettings::CHANNELGROUPS_THROTTLE <<
ManualControlSettings::CHANNELGROUPS_ROLL <<
@ -352,7 +367,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
ManualControlSettings::CHANNELGROUPS_FLIGHTMODE <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY0 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY1 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY2;
ManualControlSettings::CHANNELGROUPS_ACCESSORY2 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY3;
groundChannelOrder << ManualControlSettings::CHANNELGROUPS_THROTTLE <<
ManualControlSettings::CHANNELGROUPS_YAW <<
@ -368,6 +384,7 @@ void ConfigInputWidget::resetTxControls()
m_txAccess0->setTransform(m_txAccess0Orig, false);
m_txAccess1->setTransform(m_txAccess1Orig, false);
m_txAccess2->setTransform(m_txAccess2Orig, false);
m_txAccess3->setTransform(m_txAccess3Orig, false);
m_txFlightMode->setElementId("flightModeCenter");
m_txFlightMode->setTransform(m_txFlightModeCOrig, false);
m_txArrows->setVisible(false);
@ -1133,6 +1150,9 @@ void ConfigInputWidget::setMoveFromCommand(int command)
case ManualControlSettings::CHANNELNUMBER_ACCESSORY2:
movement = moveAccess2;
break;
case ManualControlSettings::CHANNELNUMBER_ACCESSORY3:
movement = moveAccess3;
break;
default:
Q_ASSERT(0);
break;
@ -1186,6 +1206,12 @@ void ConfigInputWidget::setTxMovement(txMovements movement)
currentMovement = moveAccess2;
animate->start(100);
break;
case moveAccess3:
movePos = 0;
growing = true;
currentMovement = moveAccess3;
animate->start(100);
break;
case moveFlightMode:
movePos = 0;
growing = true;
@ -1272,6 +1298,13 @@ void ConfigInputWidget::moveTxControls()
limitMin = ACCESS_MIN_MOVE;
move = horizontal;
break;
case moveAccess3:
item = m_txAccess3;
trans = m_txAccess3Orig;
limitMax = ACCESS_MAX_MOVE;
limitMin = ACCESS_MIN_MOVE;
move = horizontal;
break;
case moveFlightMode:
item = m_txFlightMode;
move = jump;
@ -1325,6 +1358,8 @@ void ConfigInputWidget::moveTxControls()
m_txAccess1->setTransform(trans.translate(movePos * 10 * ACCESS_MAX_MOVE / STICK_MAX_MOVE, 0), false);
trans = m_txAccess2Orig;
m_txAccess2->setTransform(trans.translate(movePos * 10 * ACCESS_MAX_MOVE / STICK_MAX_MOVE, 0), false);
trans = m_txAccess3Orig;
m_txAccess3->setTransform(trans.translate(movePos * 10 * ACCESS_MAX_MOVE / STICK_MAX_MOVE, 0), false);
if (auxFlag) {
trans = m_txLeftStickOrig;
@ -1390,6 +1425,12 @@ AccessoryDesired *ConfigInputWidget::getAccessoryDesiredInstance(int instance)
}
return accessoryDesiredObj2;
case 3:
if (accessoryDesiredObj3 == NULL) {
accessoryDesiredObj3 = AccessoryDesired::GetInstance(getObjectManager(), 3);
}
return accessoryDesiredObj3;
default:
Q_ASSERT(false);
}
@ -1461,6 +1502,7 @@ void ConfigInputWidget::moveSticks()
m_txAccess0->setTransform(QTransform(m_txAccess0Orig).translate(getAccessoryDesiredValue(0) * ACCESS_MAX_MOVE * 10, 0), false);
m_txAccess1->setTransform(QTransform(m_txAccess1Orig).translate(getAccessoryDesiredValue(1) * ACCESS_MAX_MOVE * 10, 0), false);
m_txAccess2->setTransform(QTransform(m_txAccess2Orig).translate(getAccessoryDesiredValue(2) * ACCESS_MAX_MOVE * 10, 0), false);
m_txAccess3->setTransform(QTransform(m_txAccess3Orig).translate(getAccessoryDesiredValue(3) * ACCESS_MAX_MOVE * 10, 0), false);
}
void ConfigInputWidget::dimOtherControls(bool value)
@ -1475,6 +1517,7 @@ void ConfigInputWidget::dimOtherControls(bool value)
m_txAccess0->setOpacity(opac);
m_txAccess1->setOpacity(opac);
m_txAccess2->setOpacity(opac);
m_txAccess3->setOpacity(opac);
m_txFlightMode->setOpacity(opac);
}

View File

@ -2,7 +2,8 @@
******************************************************************************
*
* @file configservowidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ConfigPlugin Config Plugin
@ -61,7 +62,7 @@ public:
~ConfigInputWidget();
enum wizardSteps { wizardWelcome, wizardChooseMode, wizardChooseType, wizardIdentifySticks, wizardIdentifyCenter, wizardIdentifyLimits, wizardIdentifyInverted, wizardFinish, wizardNone };
enum txMode { mode1, mode2, mode3, mode4 };
enum txMovements { moveLeftVerticalStick, moveRightVerticalStick, moveLeftHorizontalStick, moveRightHorizontalStick, moveAccess0, moveAccess1, moveAccess2, moveFlightMode, centerAll, moveAll, nothing };
enum txMovements { moveLeftVerticalStick, moveRightVerticalStick, moveLeftHorizontalStick, moveRightHorizontalStick, moveAccess0, moveAccess1, moveAccess2, moveAccess3,moveFlightMode, centerAll, moveAll, nothing };
enum txMovementType { vertical, horizontal, jump, mix };
enum txType { acro, heli, ground };
void startInputWizard()
@ -125,6 +126,7 @@ private:
AccessoryDesired *accessoryDesiredObj0;
AccessoryDesired *accessoryDesiredObj1;
AccessoryDesired *accessoryDesiredObj2;
AccessoryDesired *accessoryDesiredObj3;
ManualControlSettings *manualSettingsObj;
ManualControlSettings::DataFields manualSettingsData;
@ -157,6 +159,7 @@ private:
QGraphicsSvgItem *m_txAccess0;
QGraphicsSvgItem *m_txAccess1;
QGraphicsSvgItem *m_txAccess2;
QGraphicsSvgItem *m_txAccess3;
QGraphicsSvgItem *m_txFlightMode;
QGraphicsSvgItem *m_txBackground;
QGraphicsSvgItem *m_txArrows;
@ -165,6 +168,7 @@ private:
QTransform m_txAccess0Orig;
QTransform m_txAccess1Orig;
QTransform m_txAccess2Orig;
QTransform m_txAccess3Orig;
QTransform m_txFlightModeCOrig;
QTransform m_txFlightModeLOrig;
QTransform m_txFlightModeROrig;

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 424 KiB

After

Width:  |  Height:  |  Size: 424 KiB

View File

@ -8,7 +8,7 @@
<field name="Yaw" units="%" type="float" elements="1"/>
<field name="Collective" units="%" type="float" elements="1"/>
<field name="Thrust" units="%" type="float" elements="1"/>
<field name="Channel" units="us" type="uint16" elements="9"/>
<field name="Channel" units="us" type="uint16" elements="10"/>
<field name="FlightModeSwitchPosition" units="" type="uint8" elements="1" defaultvalue="0"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>

View File

@ -2,18 +2,18 @@
<object name="ManualControlSettings" singleinstance="true" settings="true" category="Control">
<description>Settings to indicate how to decode receiver input by @ref ManualControlModule.</description>
<field name="ChannelGroups" units="Channel Group" type="enum"
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2,Accessory3"
options="PWM,PPM,DSM (MainPort),DSM (FlexiPort),S.Bus,SRXL,GCS,OPLink,None" defaultvalue="None"/>
<field name="ChannelNumber" units="channel" type="uint8" defaultvalue="0"
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"/>
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2,Accessory3"/>
<field name="ChannelMin" units="us" type="int16" defaultvalue="1000"
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"/>
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2,Accessory3"/>
<field name="ChannelNeutral" units="us" type="int16" defaultvalue="1500"
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"/>
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2,Accessory3"/>
<field name="ChannelMax" units="us" type="int16" defaultvalue="2000"
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"/>
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2,Accessory3"/>
<field name="ResponseTime" units="ms" type="uint16" defaultvalue="0"
elementnames="Roll,Pitch,Yaw,Collective,Accessory0,Accessory1,Accessory2"/>
elementnames="Roll,Pitch,Yaw,Collective,Accessory0,Accessory1,Accessory2,Accessory3"/>
<field name="Deadband" units="%" type="uint8" elements="1" defaultvalue="2"/>
<!-- Note the following deadband is used in AssistedControl. Use of deadband with AssistedControl is not optional and will have a hardcoded minimum. -->
@ -24,7 +24,7 @@
<field name="FlightModeNumber" units="" type="uint8" elements="1" defaultvalue="3"/>
<field name="FailsafeFlightModeSwitchPosition" units="" type="int8" elements="1" defaultvalue="-1"/>
<field name="FailsafeChannel" units="%" type="float" elementnames="Throttle,Roll,Pitch,Yaw,Collective,Accessory0,Accessory1,Accessory2" defaultvalue="-1,0,0,0,0,0,0,0" />
<field name="FailsafeChannel" units="%" type="float" elementnames="Throttle,Roll,Pitch,Yaw,Collective,Accessory0,Accessory1,Accessory2,Accessory3" defaultvalue="-1,0,0,0,0,0,0,0,0" />
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>