mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Input configuration: Make input channel into a dropdown box and make the
neutral position into a slider. During calibration the slider moves and the min and max values are updated appropriately. Also make the collective channel skippable in the configuration wizard.
This commit is contained in:
parent
1a5fd9f30e
commit
bbdb176409
@ -78,7 +78,6 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
|||||||
|
|
||||||
connect(m_config->configurationWizard,SIGNAL(clicked()),this,SLOT(goToNormalWizard()));
|
connect(m_config->configurationWizard,SIGNAL(clicked()),this,SLOT(goToNormalWizard()));
|
||||||
connect(m_config->runCalibration,SIGNAL(toggled(bool)),this, SLOT(simpleCalibration(bool)));
|
connect(m_config->runCalibration,SIGNAL(toggled(bool)),this, SLOT(simpleCalibration(bool)));
|
||||||
connect(manualSettingsObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(settingsUpdated()));
|
|
||||||
|
|
||||||
connect(m_config->wzNext,SIGNAL(clicked()),this,SLOT(wzNext()));
|
connect(m_config->wzNext,SIGNAL(clicked()),this,SLOT(wzNext()));
|
||||||
connect(m_config->wzCancel,SIGNAL(clicked()),this,SLOT(wzCancel()));
|
connect(m_config->wzCancel,SIGNAL(clicked()),this,SLOT(wzCancel()));
|
||||||
@ -565,7 +564,8 @@ void ConfigInputWidget::identifyControls()
|
|||||||
}
|
}
|
||||||
m_config->wzText->setText(QString(tr("Please move each control once at a time according to the instructions and picture below.\n\n"
|
m_config->wzText->setText(QString(tr("Please move each control once at a time according to the instructions and picture below.\n\n"
|
||||||
"Move the %1 stick")).arg(manualSettingsObj->getFields().at(0)->getElementNames().at(currentCommand)));
|
"Move the %1 stick")).arg(manualSettingsObj->getFields().at(0)->getElementNames().at(currentCommand)));
|
||||||
if(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(currentCommand).contains("Accessory"))
|
if(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(currentCommand).contains("Accessory") ||
|
||||||
|
manualSettingsObj->getField("ChannelGroups")->getElementNames().at(currentCommand).contains("Collective"))
|
||||||
{
|
{
|
||||||
m_config->wzNext->setEnabled(true);
|
m_config->wzNext->setEnabled(true);
|
||||||
}
|
}
|
||||||
@ -981,8 +981,6 @@ void ConfigInputWidget::moveFMSlider()
|
|||||||
|
|
||||||
void ConfigInputWidget::updateCalibration()
|
void ConfigInputWidget::updateCalibration()
|
||||||
{
|
{
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
manualCommandData=manualCommandObj->getData();
|
manualCommandData=manualCommandObj->getData();
|
||||||
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
||||||
{
|
{
|
||||||
@ -995,19 +993,6 @@ void ConfigInputWidget::updateCalibration()
|
|||||||
|
|
||||||
manualSettingsObj->setData(manualSettingsData);
|
manualSettingsObj->setData(manualSettingsData);
|
||||||
manualSettingsObj->updated();
|
manualSettingsObj->updated();
|
||||||
settingsUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigInputWidget::settingsUpdated()
|
|
||||||
{
|
|
||||||
manualSettingsData=manualSettingsObj->getData();
|
|
||||||
Q_ASSERT(inputList.length() <= ManualControlSettings::CHANNELGROUPS_NUMELEM);
|
|
||||||
|
|
||||||
for(int i = 0; i < inputList.length(); i++) {
|
|
||||||
inputList[i]->ui->channelNeutral->setMaximum(manualSettingsData.ChannelMax[i]);
|
|
||||||
inputList[i]->ui->channelNeutral->setMinimum(manualSettingsData.ChannelMin[i]);
|
|
||||||
inputList[i]->ui->channelNeutral->setValue(manualSettingsData.ChannelNeutral[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigInputWidget::simpleCalibration(bool enable)
|
void ConfigInputWidget::simpleCalibration(bool enable)
|
||||||
@ -1026,7 +1011,7 @@ void ConfigInputWidget::simpleCalibration(bool enable)
|
|||||||
manualSettingsData.Arming=ManualControlSettings::ARMING_ALWAYSDISARMED;
|
manualSettingsData.Arming=ManualControlSettings::ARMING_ALWAYSDISARMED;
|
||||||
manualSettingsObj->setData(manualSettingsData);
|
manualSettingsObj->setData(manualSettingsData);
|
||||||
|
|
||||||
for (int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++) {
|
for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++) {
|
||||||
manualSettingsData.ChannelMin[i] = manualCommandData.Channel[i];
|
manualSettingsData.ChannelMin[i] = manualCommandData.Channel[i];
|
||||||
manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i];
|
manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i];
|
||||||
manualSettingsData.ChannelMax[i] = manualCommandData.Channel[i];
|
manualSettingsData.ChannelMax[i] = manualCommandData.Channel[i];
|
||||||
|
@ -134,7 +134,6 @@ private slots:
|
|||||||
void invertControls();
|
void invertControls();
|
||||||
void simpleCalibration(bool state);
|
void simpleCalibration(bool state);
|
||||||
void updateCalibration();
|
void updateCalibration();
|
||||||
void settingsUpdated();
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
virtual void enableControls(bool enable);
|
virtual void enableControls(bool enable);
|
||||||
|
@ -48,7 +48,9 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
|
|||||||
UAVObject *obj=NULL;
|
UAVObject *obj=NULL;
|
||||||
UAVObjectField *_field=NULL;
|
UAVObjectField *_field=NULL;
|
||||||
obj = objManager->getObject(QString(object));
|
obj = objManager->getObject(QString(object));
|
||||||
|
Q_ASSERT(obj);
|
||||||
_field = obj->getField(QString(field));
|
_field = obj->getField(QString(field));
|
||||||
|
Q_ASSERT(_field);
|
||||||
addUAVObjectToWidgetRelation(object,field,widget,_field->getElementNames().indexOf(index));
|
addUAVObjectToWidgetRelation(object,field,widget,_field->getElementNames().indexOf(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
|
|||||||
if(!object.isEmpty())
|
if(!object.isEmpty())
|
||||||
{
|
{
|
||||||
obj = objManager->getObject(QString(object));
|
obj = objManager->getObject(QString(object));
|
||||||
|
Q_ASSERT(obj);
|
||||||
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues()));
|
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues()));
|
||||||
}
|
}
|
||||||
//smartsave->addObject(obj);
|
//smartsave->addObject(obj);
|
||||||
@ -182,6 +185,10 @@ void ConfigTaskWidget::populateWidgets()
|
|||||||
{
|
{
|
||||||
cb->setValue(ow->field->getValue(ow->index).toInt()/ow->scale);
|
cb->setValue(ow->field->getValue(ow->index).toInt()/ow->scale);
|
||||||
}
|
}
|
||||||
|
else if(QSlider * cb=qobject_cast<QSlider *>(ow->widget))
|
||||||
|
{
|
||||||
|
cb->setValue(ow->field->getValue(ow->index).toInt()/ow->scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setDirty(dirtyBack);
|
setDirty(dirtyBack);
|
||||||
}
|
}
|
||||||
@ -207,6 +214,10 @@ void ConfigTaskWidget::refreshWidgetsValues()
|
|||||||
{
|
{
|
||||||
cb->setValue(ow->field->getValue(ow->index).toInt()/ow->scale);
|
cb->setValue(ow->field->getValue(ow->index).toInt()/ow->scale);
|
||||||
}
|
}
|
||||||
|
else if(QSlider * cb=qobject_cast<QSlider *>(ow->widget))
|
||||||
|
{
|
||||||
|
cb->setValue(ow->field->getValue(ow->index).toInt()/ow->scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setDirty(dirtyBack);
|
setDirty(dirtyBack);
|
||||||
}
|
}
|
||||||
@ -231,6 +242,10 @@ void ConfigTaskWidget::updateObjectsFromWidgets()
|
|||||||
{
|
{
|
||||||
ow->field->setValue(cb->value()* ow->scale,ow->index);
|
ow->field->setValue(cb->value()* ow->scale,ow->index);
|
||||||
}
|
}
|
||||||
|
else if(QSlider * cb=qobject_cast<QSlider *>(ow->widget))
|
||||||
|
{
|
||||||
|
ow->field->setValue(cb->value()* ow->scale,ow->index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "inputchannelform.h"
|
#include "inputchannelform.h"
|
||||||
#include "ui_inputchannelform.h"
|
#include "ui_inputchannelform.h"
|
||||||
|
|
||||||
|
#include "manualcontrolsettings.h"
|
||||||
|
|
||||||
inputChannelForm::inputChannelForm(QWidget *parent,bool showlegend) :
|
inputChannelForm::inputChannelForm(QWidget *parent,bool showlegend) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::inputChannelForm)
|
ui(new Ui::inputChannelForm)
|
||||||
@ -21,9 +23,87 @@ inputChannelForm::inputChannelForm(QWidget *parent,bool showlegend) :
|
|||||||
delete ui->legend4;
|
delete ui->legend4;
|
||||||
delete ui->legend5;
|
delete ui->legend5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(ui->channelMin,SIGNAL(valueChanged(int)),this,SLOT(minUpdated(int)));
|
||||||
|
connect(ui->channelMax,SIGNAL(valueChanged(int)),this,SLOT(maxUpdated(int)));
|
||||||
|
connect(ui->channelGroup,SIGNAL(currentIndexChanged(int)),this,SLOT(groupUpdated()));
|
||||||
|
|
||||||
|
// This is awkward but since we want the UI to be a dropdown but the field is not an enum
|
||||||
|
// it breaks the UAUVObject widget relation of the task gadget. Running the data through
|
||||||
|
// a spin box fixes this
|
||||||
|
connect(ui->channelNumberDropdown,SIGNAL(currentIndexChanged(int)),this,SLOT(channelDropdownUpdated(int)));
|
||||||
|
connect(ui->channelNumber,SIGNAL(valueChanged(int)),this,SLOT(channelNumberUpdated(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inputChannelForm::~inputChannelForm()
|
inputChannelForm::~inputChannelForm()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void inputChannelForm::minUpdated(int newval)
|
||||||
|
{
|
||||||
|
ui->channelNeutral->setMinimum(newval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void inputChannelForm::maxUpdated(int newval)
|
||||||
|
{
|
||||||
|
ui->channelNeutral->setMaximum(newval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the channel options based on the selected receiver type
|
||||||
|
*
|
||||||
|
* I fully admit this is terrible practice to embed data within UI
|
||||||
|
* like this. Open to suggestions. JC 2011-09-07
|
||||||
|
*/
|
||||||
|
void inputChannelForm::groupUpdated()
|
||||||
|
{
|
||||||
|
ui->channelNumberDropdown->clear();
|
||||||
|
ui->channelNumberDropdown->addItem("Disabled");
|
||||||
|
|
||||||
|
quint8 count = 0;
|
||||||
|
|
||||||
|
switch(ui->channelGroup->currentIndex()) {
|
||||||
|
case -1: // Nothing selected
|
||||||
|
count = 0;
|
||||||
|
break;
|
||||||
|
case ManualControlSettings::CHANNELGROUPS_PWM:
|
||||||
|
count = 8; // Need to make this 6 for CC
|
||||||
|
break;
|
||||||
|
case ManualControlSettings::CHANNELGROUPS_PPM:
|
||||||
|
case ManualControlSettings::CHANNELGROUPS_SBUS:
|
||||||
|
case ManualControlSettings::CHANNELGROUPS_SPEKTRUM1:
|
||||||
|
case ManualControlSettings::CHANNELGROUPS_SPEKTRUM2:
|
||||||
|
count = 12;
|
||||||
|
break;
|
||||||
|
case ManualControlSettings::CHANNELGROUPS_GCS:
|
||||||
|
count = 5;
|
||||||
|
case ManualControlSettings::CHANNELGROUPS_NONE:
|
||||||
|
count = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
ui->channelNumberDropdown->addItem(QString(tr("Chan %1").arg(i+1)));
|
||||||
|
|
||||||
|
ui->channelNumber->setMaximum(count);
|
||||||
|
ui->channelNumber->setMinimum(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the dropdown from the hidden control
|
||||||
|
*/
|
||||||
|
void inputChannelForm::channelDropdownUpdated(int newval)
|
||||||
|
{
|
||||||
|
ui->channelNumber->setValue(newval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the hidden control from the dropdown
|
||||||
|
*/
|
||||||
|
void inputChannelForm::channelNumberUpdated(int newval)
|
||||||
|
{
|
||||||
|
ui->channelNumberDropdown->setCurrentIndex(newval);
|
||||||
|
}
|
||||||
|
@ -16,6 +16,13 @@ public:
|
|||||||
~inputChannelForm();
|
~inputChannelForm();
|
||||||
friend class ConfigInputWidget;
|
friend class ConfigInputWidget;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void minUpdated(int);
|
||||||
|
void maxUpdated(int);
|
||||||
|
void groupUpdated();
|
||||||
|
void channelDropdownUpdated(int);
|
||||||
|
void channelNumberUpdated(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::inputChannelForm *ui;
|
Ui::inputChannelForm *ui;
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>449</width>
|
<width>482</width>
|
||||||
<height>48</height>
|
<height>48</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="channelName">
|
<widget class="QLabel" name="channelName">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
@ -45,24 +45,30 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QComboBox" name="channelGroup"/>
|
<widget class="QComboBox" name="channelGroup">
|
||||||
</item>
|
<property name="sizePolicy">
|
||||||
<item row="1" column="3">
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
<widget class="QSpinBox" name="channelNumber">
|
<horstretch>5</horstretch>
|
||||||
<property name="maximum">
|
<verstretch>0</verstretch>
|
||||||
<number>255</number>
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="4">
|
<item row="2" column="4">
|
||||||
<widget class="QSpinBox" name="channelMin">
|
<widget class="QSpinBox" name="channelMin">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>9999</number>
|
<number>9999</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="6">
|
<item row="2" column="6">
|
||||||
<widget class="QSpinBox" name="channelMax">
|
<widget class="QSpinBox" name="channelMax">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>9999</number>
|
<number>9999</number>
|
||||||
@ -95,7 +101,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Receiver type</string>
|
<string>Type</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -129,13 +135,45 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="5">
|
<item row="2" column="5">
|
||||||
<widget class="QSlider" name="channelNeutral">
|
<widget class="QSlider" name="channelNeutral">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QComboBox" name="channelNumberDropdown">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>4</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maxVisibleItems">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QSpinBox" name="channelNumber">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user