1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Changed the RC input sliders for vertical bars. Simplified some code areas.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2879 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-02-25 20:43:58 +00:00 committed by pip
parent 611cb06ec6
commit 09786b763f
6 changed files with 3450 additions and 3558 deletions

View File

@ -1,11 +1,14 @@
TEMPLATE = lib
TARGET = Config
QT += svg
include(../../openpilotgcsplugin.pri)
include(../../plugins/uavtalk/uavtalk.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
OTHER_FILES += Config.pluginspec
HEADERS += configplugin.h \
configgadgetconfiguration.h \
configgadgetwidget.h \
@ -22,7 +25,9 @@ HEADERS += configplugin.h \
mixercurvepoint.h \
mixercurveline.h \
configccpmwidget.h \
configstabilizationwidget.h
configstabilizationwidget.h \
widgetbar.h
SOURCES += configplugin.cpp \
configgadgetconfiguration.cpp \
configgadgetwidget.cpp \
@ -39,11 +44,14 @@ SOURCES += configplugin.cpp \
mixercurvepoint.cpp \
mixercurveline.cpp \
configccpmwidget.cpp \
configstabilizationwidget.cpp
configstabilizationwidget.cpp \
widgetbar.cpp
FORMS += settingswidget.ui \
airframe.ui \
telemetry.ui \
ahrs.ui \
ccpm.ui \
stabilization.ui
RESOURCES += configgadget.qrc

View File

@ -43,8 +43,7 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
// First of all, put all the channel widgets into lists, so that we can
// manipulate those:
// NOTE: for historical reasons, we have objects below called ch0 to ch7, but the
// convention for OP is Channel 1 to Channel 8.
// NOTE: for historical reasons, we have objects below called ch0 to ch7, but the convention for OP is Channel 1 to Channel 8.
outLabels << m_config->ch0OutValue
<< m_config->ch1OutValue
<< m_config->ch2OutValue
@ -53,6 +52,7 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
<< m_config->ch5OutValue
<< m_config->ch6OutValue
<< m_config->ch7OutValue;
outSliders << m_config->ch0OutSlider
<< m_config->ch1OutSlider
<< m_config->ch2OutSlider
@ -61,6 +61,7 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
<< m_config->ch5OutSlider
<< m_config->ch6OutSlider
<< m_config->ch7OutSlider;
outMin << m_config->ch0OutMin
<< m_config->ch1OutMin
<< m_config->ch2OutMin
@ -69,6 +70,7 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
<< m_config->ch5OutMin
<< m_config->ch6OutMin
<< m_config->ch7OutMin;
outMax << m_config->ch0OutMax
<< m_config->ch1OutMax
<< m_config->ch2OutMax
@ -77,6 +79,7 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
<< m_config->ch5OutMax
<< m_config->ch6OutMax
<< m_config->ch7OutMax;
reversals << m_config->ch0Rev
<< m_config->ch1Rev
<< m_config->ch2Rev
@ -85,15 +88,33 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
<< m_config->ch5Rev
<< m_config->ch6Rev
<< m_config->ch7Rev;
inSliders << m_config->ch0Slider
<< m_config->ch1Slider
<< m_config->ch2Slider
<< m_config->ch3Slider
<< m_config->ch4Slider
<< m_config->ch5Slider
<< m_config->ch6Slider
<< m_config->ch7Slider;
inMaxLabels << m_config->ch0Max
<< m_config->ch1Max
<< m_config->ch2Max
<< m_config->ch3Max
<< m_config->ch4Max
<< m_config->ch5Max
<< m_config->ch6Max
<< m_config->ch7Max;
inMinLabels << m_config->ch0Min
<< m_config->ch1Min
<< m_config->ch2Min
<< m_config->ch3Min
<< m_config->ch4Min
<< m_config->ch5Min
<< m_config->ch6Min
<< m_config->ch7Min;
inWidgetBars << m_config->widgetBarCH0
<< m_config->widgetBarCH1
<< m_config->widgetBarCH2
<< m_config->widgetBarCH3
<< m_config->widgetBarCH4
<< m_config->widgetBarCH5
<< m_config->widgetBarCH6
<< m_config->widgetBarCH7;
// Now connect the widget to the ManualControlCommand / Channel UAVObject
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
@ -540,59 +561,30 @@ void ConfigServoWidget::requestRCInputUpdate()
Q_ASSERT(obj);
obj->requestUpdate();
UAVObjectField *field;
// Now update all the slider values:
QString fieldName = QString("ChannelMax");
UAVObjectField *field = obj->getField(fieldName);
m_config->ch0Max->setText(field->getValue(0).toString());
m_config->ch0Slider->setMaximum(field->getValue(0).toInt());
m_config->ch1Max->setText(field->getValue(1).toString());
m_config->ch1Slider->setMaximum(field->getValue(1).toInt());
m_config->ch2Max->setText(field->getValue(2).toString());
m_config->ch2Slider->setMaximum(field->getValue(2).toInt());
m_config->ch3Max->setText(field->getValue(3).toString());
m_config->ch3Slider->setMaximum(field->getValue(3).toInt());
m_config->ch4Max->setText(field->getValue(4).toString());
m_config->ch4Slider->setMaximum(field->getValue(4).toInt());
m_config->ch5Max->setText(field->getValue(5).toString());
m_config->ch5Slider->setMaximum(field->getValue(5).toInt());
m_config->ch6Max->setText(field->getValue(6).toString());
m_config->ch6Slider->setMaximum(field->getValue(6).toInt());
m_config->ch7Max->setText(field->getValue(7).toString());
m_config->ch7Slider->setMaximum(field->getValue(7).toInt());
fieldName = QString("ChannelMin");
field = obj->getField(fieldName);
m_config->ch0Min->setText(field->getValue(0).toString());
m_config->ch0Slider->setMinimum(field->getValue(0).toInt());
m_config->ch1Min->setText(field->getValue(1).toString());
m_config->ch1Slider->setMinimum(field->getValue(1).toInt());
m_config->ch2Min->setText(field->getValue(2).toString());
m_config->ch2Slider->setMinimum(field->getValue(2).toInt());
m_config->ch3Min->setText(field->getValue(3).toString());
m_config->ch3Slider->setMinimum(field->getValue(3).toInt());
m_config->ch4Min->setText(field->getValue(4).toString());
m_config->ch4Slider->setMinimum(field->getValue(4).toInt());
m_config->ch5Min->setText(field->getValue(5).toString());
m_config->ch5Slider->setMinimum(field->getValue(5).toInt());
m_config->ch6Min->setText(field->getValue(6).toString());
m_config->ch6Slider->setMinimum(field->getValue(6).toInt());
m_config->ch7Min->setText(field->getValue(7).toString());
m_config->ch7Slider->setMinimum(field->getValue(7).toInt());
fieldName = QString("ChannelNeutral");
field = obj->getField(fieldName);
m_config->ch0Slider->setValue(field->getValue(0).toInt());
m_config->ch1Slider->setValue(field->getValue(1).toInt());
m_config->ch2Slider->setValue(field->getValue(2).toInt());
m_config->ch3Slider->setValue(field->getValue(3).toInt());
m_config->ch4Slider->setValue(field->getValue(4).toInt());
m_config->ch5Slider->setValue(field->getValue(5).toInt());
m_config->ch6Slider->setValue(field->getValue(6).toInt());
m_config->ch7Slider->setValue(field->getValue(7).toInt());
UAVObjectField *field_max = obj->getField(QString("ChannelMax"));
UAVObjectField *field_min = obj->getField(QString("ChannelMin"));
UAVObjectField *field_neu = obj->getField(QString("ChannelNeutral"));
Q_ASSERT(field_max);
Q_ASSERT(field_min);
Q_ASSERT(field_neu);
for (int i = 0; i < 8; i++)
{
QVariant max = field_max->getValue(i);
QVariant min = field_min->getValue(i);
QVariant neutral = field_neu->getValue(i);
inMaxLabels[i]->setText(max.toString());
inMinLabels[i]->setText(min.toString());
inWidgetBars[i]->setMaximum(max.toInt());
inWidgetBars[i]->setMinimum(min.toInt());
inWidgetBars[i]->setValue(neutral.toInt());
}
// Update receiver type
fieldName = QString("InputMode");
field = obj->getField(fieldName);
field = obj->getField(QString("InputMode"));
m_config->receiverType->setCurrentIndex(m_config->receiverType->findText(field->getValue().toString()));
// Reset all channel assignement dropdowns:
@ -606,12 +598,12 @@ void ConfigServoWidget::requestRCInputUpdate()
m_config->ch7Assign->setCurrentIndex(0);
// Update all channels assignements
QList<UAVObjectField*> fieldList = obj->getFields();
foreach (UAVObjectField* field, fieldList) {
if (field->getUnits().contains("channel")) {
QList<UAVObjectField *> fieldList = obj->getFields();
foreach (UAVObjectField *field, fieldList)
{
if (field->getUnits().contains("channel"))
assignChannel(obj, field->getName());
}
}
// Update all the flight mode settingsin the relevant tab
field = obj->getField(QString("Pos1FlightMode"));
@ -621,33 +613,23 @@ void ConfigServoWidget::requestRCInputUpdate()
field = obj->getField(QString("Pos3FlightMode"));
m_config->fmsModePos3->setCurrentIndex((m_config->fmsModePos3->findText(field->getValue().toString())));
field = obj->getField(QString("Pos1StabilizationSettings"));
m_config->fmsSsPos1Roll->setCurrentIndex(m_config->fmsSsPos1Roll->findText(
field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos1Pitch->setCurrentIndex(m_config->fmsSsPos1Pitch->findText(
field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos1Yaw->setCurrentIndex(m_config->fmsSsPos1Yaw->findText(
field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
m_config->fmsSsPos1Roll->setCurrentIndex(m_config->fmsSsPos1Roll->findText(field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos1Pitch->setCurrentIndex(m_config->fmsSsPos1Pitch->findText(field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos1Yaw->setCurrentIndex(m_config->fmsSsPos1Yaw->findText(field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
field = obj->getField(QString("Pos2StabilizationSettings"));
m_config->fmsSsPos2Roll->setCurrentIndex(m_config->fmsSsPos2Roll->findText(
field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos2Pitch->setCurrentIndex(m_config->fmsSsPos2Pitch->findText(
field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos2Yaw->setCurrentIndex(m_config->fmsSsPos2Yaw->findText(
field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
m_config->fmsSsPos2Roll->setCurrentIndex(m_config->fmsSsPos2Roll->findText(field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos2Pitch->setCurrentIndex(m_config->fmsSsPos2Pitch->findText(field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos2Yaw->setCurrentIndex(m_config->fmsSsPos2Yaw->findText(field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
field = obj->getField(QString("Pos3StabilizationSettings"));
m_config->fmsSsPos3Roll->setCurrentIndex(m_config->fmsSsPos3Roll->findText(
field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos3Pitch->setCurrentIndex(m_config->fmsSsPos3Pitch->findText(
field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos3Yaw->setCurrentIndex(m_config->fmsSsPos3Yaw->findText(
field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
m_config->fmsSsPos3Roll->setCurrentIndex(m_config->fmsSsPos3Roll->findText(field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos3Pitch->setCurrentIndex(m_config->fmsSsPos3Pitch->findText(field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos3Yaw->setCurrentIndex(m_config->fmsSsPos3Yaw->findText(field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
// Load the arming settings
field = obj->getField(QString("Arming"));
m_config->armControl->setCurrentIndex(m_config->armControl->findText(field->getValue().toString()));
field = obj->getField(QString("ArmedTimeout"));
m_config->armTimeout->setValue(field->getValue().toInt()/1000);
}
@ -663,36 +645,18 @@ void ConfigServoWidget::sendRCInputUpdate()
// Now update all fields from the sliders:
QString fieldName = QString("ChannelMax");
UAVObjectField * field = obj->getField(fieldName);
field->setValue(m_config->ch0Max->text().toInt(),0);
field->setValue(m_config->ch1Max->text().toInt(),1);
field->setValue(m_config->ch2Max->text().toInt(),2);
field->setValue(m_config->ch3Max->text().toInt(),3);
field->setValue(m_config->ch4Max->text().toInt(),4);
field->setValue(m_config->ch5Max->text().toInt(),5);
field->setValue(m_config->ch6Max->text().toInt(),6);
field->setValue(m_config->ch7Max->text().toInt(),7);
for (int i = 0; i < 8; i++)
field->setValue(inMaxLabels[i]->text().toInt(), i);
fieldName = QString("ChannelMin");
field = obj->getField(fieldName);
field->setValue(m_config->ch0Min->text().toInt(),0);
field->setValue(m_config->ch1Min->text().toInt(),1);
field->setValue(m_config->ch2Min->text().toInt(),2);
field->setValue(m_config->ch3Min->text().toInt(),3);
field->setValue(m_config->ch4Min->text().toInt(),4);
field->setValue(m_config->ch5Min->text().toInt(),5);
field->setValue(m_config->ch6Min->text().toInt(),6);
field->setValue(m_config->ch7Min->text().toInt(),7);
for (int i = 0; i < 8; i++)
field->setValue(inMinLabels[i]->text().toInt(), i);
fieldName = QString("ChannelNeutral");
field = obj->getField(fieldName);
field->setValue(m_config->ch0Slider->value(),0);
field->setValue(m_config->ch1Slider->value(),1);
field->setValue(m_config->ch2Slider->value(),2);
field->setValue(m_config->ch3Slider->value(),3);
field->setValue(m_config->ch4Slider->value(),4);
field->setValue(m_config->ch5Slider->value(),5);
field->setValue(m_config->ch6Slider->value(),6);
field->setValue(m_config->ch7Slider->value(),7);
for (int i = 0; i < 8; i++)
field->setValue(inWidgetBars[i]->value(), i);
// Set RC Receiver type:
fieldName = QString("InputMode");
@ -874,13 +838,15 @@ void ConfigServoWidget::updateChannels(UAVObject* controlCommand)
QString fieldName = QString("Connected");
UAVObjectField *field = controlCommand->getField(fieldName);
if (field->getValue().toBool()) {
if (field->getValue().toBool())
m_config->RCInputConnected->setText("RC Receiver Connected");
} else {
else
m_config->RCInputConnected->setText("RC Receiver Not Connected");
}
if (m_config->doRCInputCalibration->isChecked()) {
if (firstUpdate) {
if (m_config->doRCInputCalibration->isChecked())
{
if (firstUpdate)
{
// Increase the data rate from the board so that the sliders
// move faster
UAVObject::Metadata mdata = controlCommand->getMetadata();
@ -902,44 +868,17 @@ void ConfigServoWidget::updateChannels(UAVObject* controlCommand)
obj->updated();
}
fieldName = QString("Channel");
field = controlCommand->getField(fieldName);
// Hey: if you find a nicer way of doing this, be my guest!
this->updateChannelSlider(&*m_config->ch0Slider,
&*m_config->ch0Min,
&*m_config->ch0Max,
&*m_config->ch0Rev,field->getValue(0).toInt());
this->updateChannelSlider(&*m_config->ch1Slider,
&*m_config->ch1Min,
&*m_config->ch1Max,
&*m_config->ch1Rev,field->getValue(1).toInt());
this->updateChannelSlider(&*m_config->ch2Slider,
&*m_config->ch2Min,
&*m_config->ch2Max,
&*m_config->ch2Rev,field->getValue(2).toInt());
this->updateChannelSlider(&*m_config->ch3Slider,
&*m_config->ch3Min,
&*m_config->ch3Max,
&*m_config->ch3Rev,field->getValue(3).toInt());
this->updateChannelSlider(&*m_config->ch4Slider,
&*m_config->ch4Min,
&*m_config->ch4Max,
&*m_config->ch4Rev,field->getValue(4).toInt());
this->updateChannelSlider(&*m_config->ch5Slider,
&*m_config->ch5Min,
&*m_config->ch5Max,
&*m_config->ch5Rev,field->getValue(5).toInt());
this->updateChannelSlider(&*m_config->ch6Slider,
&*m_config->ch6Min,
&*m_config->ch6Max,
&*m_config->ch6Rev,field->getValue(6).toInt());
this->updateChannelSlider(&*m_config->ch7Slider,
&*m_config->ch7Min,
&*m_config->ch7Max,
&*m_config->ch7Rev,field->getValue(7).toInt());
field = controlCommand->getField(QString("Channel"));
for (int i = 0; i < 8; i++)
updateChannelWidgetBar(inWidgetBars[i], inMinLabels[i], inMaxLabels[i], reversals[i], field->getValue(i).toInt());
firstUpdate = false;
} else {
if (!firstUpdate) {
}
else
{
if (!firstUpdate)
{
// Restore original data rate from the board:
UAVObject::Metadata mdata = controlCommand->getMetadata();
mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
@ -959,62 +898,71 @@ void ConfigServoWidget::updateChannels(UAVObject* controlCommand)
// Find the channel currently assigned to flightmode
field = obj->getField("FlightMode");
int chIndex = field->getOptions().indexOf(field->getValue().toString());
if ( chIndex < field->getOptions().length()-1) {
if (chIndex < field->getOptions().length() - 1)
{
float valueScaled;
int chMin = inSliders.at(chIndex)->minimum();
int chMax = inSliders.at(chIndex)->maximum();
int chNeutral = inSliders.at(chIndex)->value();
int chMin = inWidgetBars[chIndex]->minimum();
int chMax = inWidgetBars[chIndex]->maximum();
int chNeutral = inWidgetBars[chIndex]->value();
int value = controlCommand->getField("Channel")->getValue(chIndex).toInt();
if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral)) {
if (chMax != chNeutral) {
if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral))
{
if (chMax != chNeutral)
valueScaled = (float)(value - chNeutral) / (float)(chMax - chNeutral);
} else {
else
valueScaled = 0;
}
} else {
if (chMin != chNeutral) {
else
{
if (chMin != chNeutral)
valueScaled = (float)(value - chNeutral) / (float)(chNeutral - chMin);
} else {
else
valueScaled = 0;
}
}
// Bound
if (valueScaled > 1.0) {
valueScaled = 1.0;
} else if (valueScaled < -1.0) {
valueScaled = -1.0;
}
m_config->fmsSlider->setValue(valueScaled*100);
if (valueScaled > 1.0) valueScaled = 1.0;
else
if (valueScaled < -1.0) valueScaled = -1.0;
m_config->fmsSlider->setValue(valueScaled * 100);
}
}
void ConfigServoWidget::updateChannelSlider(QSlider* slider, QLabel* min, QLabel* max, QCheckBox* rev, int value)
void ConfigServoWidget::updateChannelWidgetBar(WidgetBar *widget_bar, QLabel *min, QLabel *max, QCheckBox *rev, int value)
{
Q_UNUSED(rev);
if (firstUpdate) {
// Reset all the min/max values of the sliders since we are
// starting the calibration.
slider->setMaximum(value);
slider->setMinimum(value);
slider->setValue(value);
// if (!widget_bar || !min || !max || !rev)
if (!widget_bar || !min || !max)
return;
if (firstUpdate)
{ // Reset all the min/max values of the progress bar since we are starting the calibration.
widget_bar->setMaximum(value);
widget_bar->setMinimum(value);
widget_bar->setValue(value);
max->setText(QString::number(value));
min->setText(QString::number(value));
return;
}
if (value != 0) { // Avoids glitches...
if (value > slider->maximum()) {
slider->setMaximum(value);
if (value > 0)
{ // avoids glitches...
if (value > widget_bar->maximum())
{
widget_bar->setMaximum(value);
max->setText(QString::number(value));
}
if (value < slider->minimum()) {
slider->setMinimum(value);
if (value < widget_bar->minimum())
{
widget_bar->setMinimum(value);
min->setText(QString::number(value));
}
slider->setValue(value);
widget_bar->setValue(value);
}
}

View File

@ -34,6 +34,7 @@
#include "uavobject.h"
#include <QtGui/QWidget>
#include <QList>
#include "widgetbar.h"
class Ui_SettingsWidget;
@ -45,26 +46,33 @@ public:
ConfigServoWidget(QWidget *parent = 0);
~ConfigServoWidget();
private:
Ui_SettingsWidget *m_config;
QList<QSlider> sliders;
void updateChannelSlider(QSlider* slider, QLabel* min, QLabel* Max, QCheckBox* rev, int value);
void updateChannelWidgetBar(WidgetBar *widget_bar, QLabel *min, QLabel *max, QCheckBox *rev, int value);
void assignChannel(UAVDataObject *obj, QString str);
void assignOutputChannel(UAVDataObject *obj, QString str);
int mccDataRate;
UAVObject::Metadata accInitialData;
QList<QSlider*> outSliders;
QList<QSlider*> inSliders;
QList<QSpinBox*> outMin;
QList<QSpinBox*> outMax;
QList<QCheckBox*> reversals;
QList<QLabel*> outLabels;
QList<WidgetBar*> inWidgetBars;
QList<QLabel*> inMaxLabels;
QList<QLabel*> inMinLabels;
bool firstUpdate;
private slots:
private slots:
void updateChannels(UAVObject* obj);
void requestRCInputUpdate();
void sendRCInputUpdate();
@ -76,7 +84,6 @@ private:
void sendChannelTest(int value);
void setChOutRange();
void reverseChannel(bool state);
};
#endif // CONFIGSERVOWIDGET_H
#endif

View File

@ -50,28 +50,6 @@ p, li { white-space: pre-wrap; }
<string>2000</string>
</property>
</widget>
<widget class="QSlider" name="ch4Slider">
<property name="geometry">
<rect>
<x>300</x>
<y>30</y>
<width>18</width>
<height>101</height>
</rect>
</property>
<property name="toolTip">
<string>Channel neutral value.</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QLabel" name="ch0Cur">
<property name="geometry">
<rect>
@ -248,28 +226,6 @@ p, li { white-space: pre-wrap; }
<string>Get Current</string>
</property>
</widget>
<widget class="QSlider" name="ch3Slider">
<property name="geometry">
<rect>
<x>230</x>
<y>30</y>
<width>18</width>
<height>101</height>
</rect>
</property>
<property name="toolTip">
<string>Channel neutral value.</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QLabel" name="ch2Min">
<property name="geometry">
<rect>
@ -448,28 +404,6 @@ p, li { white-space: pre-wrap; }
<string>1000</string>
</property>
</widget>
<widget class="QSlider" name="ch7Slider">
<property name="geometry">
<rect>
<x>510</x>
<y>30</y>
<width>18</width>
<height>101</height>
</rect>
</property>
<property name="toolTip">
<string>Channel neutral value.</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QPushButton" name="saveRCInputToRAM">
<property name="geometry">
<rect>
@ -512,28 +446,6 @@ Be sure to set the Neutral position on all sliders before sending!</string>
<bool>true</bool>
</property>
</widget>
<widget class="QSlider" name="ch1Slider">
<property name="geometry">
<rect>
<x>90</x>
<y>30</y>
<width>18</width>
<height>101</height>
</rect>
</property>
<property name="toolTip">
<string>Channel neutral value.</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QLabel" name="ch3Min">
<property name="geometry">
<rect>
@ -640,28 +552,6 @@ p, li { white-space: pre-wrap; }
<string>1000</string>
</property>
</widget>
<widget class="QSlider" name="ch2Slider">
<property name="geometry">
<rect>
<x>160</x>
<y>30</y>
<width>18</width>
<height>101</height>
</rect>
</property>
<property name="toolTip">
<string>Channel neutral value.</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QLabel" name="ch5Min">
<property name="geometry">
<rect>
@ -794,28 +684,6 @@ p, li { white-space: pre-wrap; }
<string>2000</string>
</property>
</widget>
<widget class="QSlider" name="ch0Slider">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>18</width>
<height>101</height>
</rect>
</property>
<property name="toolTip">
<string>Channel neutral value.</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QLabel" name="ch1Max">
<property name="geometry">
<rect>
@ -870,50 +738,6 @@ p, li { white-space: pre-wrap; }
<string>1000</string>
</property>
</widget>
<widget class="QSlider" name="ch5Slider">
<property name="geometry">
<rect>
<x>370</x>
<y>30</y>
<width>18</width>
<height>101</height>
</rect>
</property>
<property name="toolTip">
<string>Channel neutral value.</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QSlider" name="ch6Slider">
<property name="geometry">
<rect>
<x>440</x>
<y>30</y>
<width>18</width>
<height>101</height>
</rect>
</property>
<property name="toolTip">
<string>Channel neutral value.</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QComboBox" name="ch1Assign">
<property name="geometry">
<rect>
@ -1109,6 +933,254 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; color:#ff0000;&quot;&gt;when running calibration!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="WidgetBar" name="widgetBarCH0" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>44</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(165, 165, 165);</string>
</property>
</widget>
<widget class="WidgetBar" name="widgetBarCH1" native="true">
<property name="geometry">
<rect>
<x>80</x>
<y>30</y>
<width>44</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(165, 165, 165);</string>
</property>
</widget>
<widget class="WidgetBar" name="widgetBarCH2" native="true">
<property name="geometry">
<rect>
<x>150</x>
<y>30</y>
<width>44</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(165, 165, 165);</string>
</property>
</widget>
<widget class="WidgetBar" name="widgetBarCH3" native="true">
<property name="geometry">
<rect>
<x>220</x>
<y>30</y>
<width>44</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(165, 165, 165);</string>
</property>
</widget>
<widget class="WidgetBar" name="widgetBarCH4" native="true">
<property name="geometry">
<rect>
<x>290</x>
<y>30</y>
<width>44</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(165, 165, 165);</string>
</property>
</widget>
<widget class="WidgetBar" name="widgetBarCH5" native="true">
<property name="geometry">
<rect>
<x>360</x>
<y>30</y>
<width>44</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(165, 165, 165);</string>
</property>
</widget>
<widget class="WidgetBar" name="widgetBarCH6" native="true">
<property name="geometry">
<rect>
<x>430</x>
<y>30</y>
<width>44</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(165, 165, 165);</string>
</property>
</widget>
<widget class="WidgetBar" name="widgetBarCH7" native="true">
<property name="geometry">
<rect>
<x>500</x>
<y>30</y>
<width>44</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(165, 165, 165);</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
@ -2928,15 +3000,14 @@ Applies and Saves all settings to SD</string>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>WidgetBar</class>
<extends>QWidget</extends>
<header location="global">widgetbar.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>ch0Slider</tabstop>
<tabstop>ch1Slider</tabstop>
<tabstop>ch2Slider</tabstop>
<tabstop>ch3Slider</tabstop>
<tabstop>ch4Slider</tabstop>
<tabstop>ch5Slider</tabstop>
<tabstop>ch6Slider</tabstop>
<tabstop>ch7Slider</tabstop>
<tabstop>ch0Assign</tabstop>
<tabstop>ch1Assign</tabstop>
<tabstop>ch2Assign</tabstop>
@ -3014,262 +3085,5 @@ Applies and Saves all settings to SD</string>
<tabstop>saveFmsToSD</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>ch2Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>ch2Cur</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>172</x>
<y>141</y>
</hint>
<hint type="destinationlabel">
<x>181</x>
<y>217</y>
</hint>
</hints>
</connection>
<connection>
<sender>ch0Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>ch0Cur</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>40</x>
<y>151</y>
</hint>
<hint type="destinationlabel">
<x>61</x>
<y>217</y>
</hint>
</hints>
</connection>
<connection>
<sender>ch1Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>ch1Cur</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>103</x>
<y>161</y>
</hint>
<hint type="destinationlabel">
<x>116</x>
<y>216</y>
</hint>
</hints>
</connection>
<connection>
<sender>ch3Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>ch3Cur</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>242</x>
<y>160</y>
</hint>
<hint type="destinationlabel">
<x>242</x>
<y>217</y>
</hint>
</hints>
</connection>
<connection>
<sender>ch4Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>ch4Cur</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>312</x>
<y>152</y>
</hint>
<hint type="destinationlabel">
<x>312</x>
<y>217</y>
</hint>
</hints>
</connection>
<connection>
<sender>ch5Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>ch5Cur</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>382</x>
<y>164</y>
</hint>
<hint type="destinationlabel">
<x>382</x>
<y>217</y>
</hint>
</hints>
</connection>
<connection>
<sender>ch6Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>ch6Cur</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>469</x>
<y>171</y>
</hint>
<hint type="destinationlabel">
<x>462</x>
<y>217</y>
</hint>
</hints>
</connection>
<connection>
<sender>ch7Slider</sender>
<signal>valueChanged(int)</signal>
<receiver>ch7Cur</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>539</x>
<y>168</y>
</hint>
<hint type="destinationlabel">
<x>532</x>
<y>217</y>
</hint>
</hints>
</connection>
<connection>
<sender>doRCInputCalibration</sender>
<signal>toggled(bool)</signal>
<receiver>ch0Slider</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>33</x>
<y>293</y>
</hint>
<hint type="destinationlabel">
<x>38</x>
<y>170</y>
</hint>
</hints>
</connection>
<connection>
<sender>doRCInputCalibration</sender>
<signal>toggled(bool)</signal>
<receiver>ch1Slider</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>91</x>
<y>291</y>
</hint>
<hint type="destinationlabel">
<x>103</x>
<y>112</y>
</hint>
</hints>
</connection>
<connection>
<sender>doRCInputCalibration</sender>
<signal>toggled(bool)</signal>
<receiver>ch2Slider</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>106</x>
<y>296</y>
</hint>
<hint type="destinationlabel">
<x>172</x>
<y>127</y>
</hint>
</hints>
</connection>
<connection>
<sender>doRCInputCalibration</sender>
<signal>toggled(bool)</signal>
<receiver>ch3Slider</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>104</x>
<y>291</y>
</hint>
<hint type="destinationlabel">
<x>242</x>
<y>131</y>
</hint>
</hints>
</connection>
<connection>
<sender>doRCInputCalibration</sender>
<signal>toggled(bool)</signal>
<receiver>ch4Slider</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>76</x>
<y>291</y>
</hint>
<hint type="destinationlabel">
<x>312</x>
<y>110</y>
</hint>
</hints>
</connection>
<connection>
<sender>doRCInputCalibration</sender>
<signal>toggled(bool)</signal>
<receiver>ch5Slider</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>50</x>
<y>291</y>
</hint>
<hint type="destinationlabel">
<x>382</x>
<y>124</y>
</hint>
</hints>
</connection>
<connection>
<sender>doRCInputCalibration</sender>
<signal>toggled(bool)</signal>
<receiver>ch6Slider</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>74</x>
<y>291</y>
</hint>
<hint type="destinationlabel">
<x>469</x>
<y>142</y>
</hint>
</hints>
</connection>
<connection>
<sender>doRCInputCalibration</sender>
<signal>toggled(bool)</signal>
<receiver>ch7Slider</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>62</x>
<y>296</y>
</hint>
<hint type="destinationlabel">
<x>539</x>
<y>171</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -0,0 +1,78 @@
#include <QtGui>
#include "widgetbar.h"
WidgetBar::WidgetBar(QWidget *parent)
: QWidget(parent)
{
m_maximum = 2000;
m_minimum = 1000;
m_value = 1500;
setBackgroundRole(QPalette::Base);
setAutoFillBackground(true);
}
QSize WidgetBar::minimumSizeHint() const
{
return QSize(8, 8);
}
QSize WidgetBar::sizeHint() const
{
return QSize(200, 400);
}
void WidgetBar::setMaximum(int value)
{
m_maximum = value;
update();
}
void WidgetBar::setMinimum(int value)
{
m_minimum = value;
update();
}
void WidgetBar::setValue(int value)
{
if (value < m_minimum) value = m_minimum;
else
if (value > m_maximum) value = m_maximum;
m_value = value;
update();
}
void WidgetBar::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, false);
int range = abs(m_maximum - m_minimum);
if (range < 1) range = 1;
float level = (float)(m_value - m_minimum) / range; // 0 to +1
int h = (int)((height() - 5) * level + 0.5f);
QRect rect;
rect.setLeft(2);
rect.setTop(height() - 3 - h);
rect.setWidth(width() - 5);
rect.setHeight(h);
// background
painter.setPen(QColor(160, 160, 160));
painter.setBrush(QColor(255, 255, 255));
painter.drawRect(QRect(0, 0, width() - 1, height() - 1));
if ((m_maximum - m_minimum) > 0)
{
painter.setPen(QColor(128, 128, 255));
painter.setBrush(QColor(128, 128, 255));
painter.drawRoundRect(rect, 3, 3);
}
}

View File

@ -0,0 +1,37 @@
#ifndef WIDGETBAR_H
#define WIDGETBAR_H
#include <QBrush>
#include <QPen>
#include <QPixmap>
#include <QWidget>
class WidgetBar : public QWidget
{
Q_OBJECT
public:
WidgetBar(QWidget *parent = 0);
QSize minimumSizeHint() const;
QSize sizeHint() const;
void setMaximum(int value);
void setMinimum(int value);
void setValue(int value);
int maximum() { return m_maximum; }
int minimum() { return m_minimum; }
int value() { return m_value; }
protected:
void paintEvent(QPaintEvent *event);
private:
int m_maximum;
int m_minimum;
int m_value;
};
#endif