1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

OP-1683 - Show bank number and color beside output number

This commit is contained in:
Alessio Morale 2015-01-27 19:39:45 +01:00
parent 97bf9f74b6
commit 26fcec09e3
6 changed files with 198 additions and 74 deletions

View File

@ -249,6 +249,15 @@ void ConfigOutputWidget::sendChannelTest(int index, int value)
actuatorCommand->setData(actuatorCommandFields);
}
void ConfigOutputWidget::setColor(QWidget *widget, const QColor color)
{
QPalette p(palette());
QColor color2 = QColor(color);
p.setColor(QPalette::Background, color2);
widget->setAutoFillBackground(true);
widget->setPalette(p);
}
/********************************
* Output settings
@ -272,6 +281,9 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject *obj)
// Get channel descriptions
QStringList ChannelDesc = ConfigVehicleTypeWidget::getChannelDescriptions();
QList<int> ChannelBanks;
QList<QColor> bankColors;
bankColors << Qt::magenta << Qt::yellow << Qt::green << Qt::cyan << Qt::red << Qt::darkCyan;
// Initialize output forms
QList<OutputChannelForm *> outputChannelForms = findChildren<OutputChannelForm *>();
foreach(OutputChannelForm * outputChannelForm, outputChannelForms) {
@ -315,84 +327,72 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject *obj)
ui->cb_outputRate5->setCurrentIndex(ui->cb_outputRate5->findText(QString::number(actuatorSettingsData.BankUpdateFreq[4])));
ui->cb_outputRate6->setCurrentIndex(ui->cb_outputRate6->findText(QString::number(actuatorSettingsData.BankUpdateFreq[5])));
QList<QLabel *> bank;
bank << ui->chBank1 << ui->chBank2 << ui->chBank3 << ui->chBank4 << ui->chBank5 << ui->chBank6;
QList<QComboBox *> outputRateCombos;
outputRateCombos << ui->cb_outputRate1 << ui->cb_outputRate2 << ui->cb_outputRate3 <<
ui->cb_outputRate4 << ui->cb_outputRate5 << ui->cb_outputRate6;
QList<QComboBox *> outputModeCombos;
outputModeCombos << ui->cb_outputMode1 << ui->cb_outputMode2 << ui->cb_outputMode3 <<
ui->cb_outputMode4 << ui->cb_outputMode5 << ui->cb_outputMode6;
// Reset to all disabled
ui->chBank1->setText("-");
ui->chBank2->setText("-");
ui->chBank3->setText("-");
ui->chBank4->setText("-");
ui->chBank5->setText("-");
ui->chBank6->setText("-");
ui->cb_outputRate1->setEnabled(false);
ui->cb_outputRate2->setEnabled(false);
ui->cb_outputRate3->setEnabled(false);
ui->cb_outputRate4->setEnabled(false);
ui->cb_outputRate5->setEnabled(false);
ui->cb_outputRate6->setEnabled(false);
foreach(QLabel * label, bank) {
label->setText("-");
}
int i = 0;
foreach(QComboBox * cbo, outputRateCombos) {
cbo->setEnabled(false);
setColor(cbo, palette().color(QPalette::Background));
}
ui->cb_outputMode1->setEnabled(false);
ui->cb_outputMode2->setEnabled(false);
ui->cb_outputMode3->setEnabled(false);
ui->cb_outputMode4->setEnabled(false);
ui->cb_outputMode5->setEnabled(false);
ui->cb_outputMode6->setEnabled(false);
i = 0;
foreach(QComboBox * cbo, outputModeCombos) {
cbo->setEnabled(false);
setColor(cbo, palette().color(QPalette::Background));
}
// Get connected board model
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
Q_ASSERT(pm);
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
Q_ASSERT(utilMngr);
QStringList bankLabels;
if (utilMngr) {
int board = utilMngr->getBoardModel();
// Setup labels and combos for banks according to board type
if ((board & 0xff00) == 0x0400) {
// Coptercontrol family of boards 4 timer banks
ui->chBank1->setText("1-3");
ui->chBank2->setText("4");
ui->chBank3->setText("5,7-8");
ui->chBank4->setText("6,9-10");
ui->cb_outputRate1->setEnabled(true);
ui->cb_outputRate2->setEnabled(true);
ui->cb_outputRate3->setEnabled(true);
ui->cb_outputRate4->setEnabled(true);
ui->cb_outputMode1->setEnabled(true);
ui->cb_outputMode2->setEnabled(true);
ui->cb_outputMode3->setEnabled(true);
ui->cb_outputMode4->setEnabled(true);
bankLabels << "1 (1-3)" << "2 (4)" << "3 (5,7-8)" << "4 (6,9-10)";
ChannelBanks << 1 << 1 << 1 << 2 << 3 << 4 << 3 << 3 << 4 << 4;
} else if ((board & 0xff00) == 0x0900) {
// Revolution family of boards 6 timer banks
ui->chBank1->setText("1-2");
ui->chBank2->setText("3");
ui->chBank3->setText("4");
ui->chBank4->setText("5-6");
ui->chBank5->setText("7-8");
ui->chBank6->setText("9-10");
ui->cb_outputRate1->setEnabled(true);
ui->cb_outputRate2->setEnabled(true);
ui->cb_outputRate3->setEnabled(true);
ui->cb_outputRate4->setEnabled(true);
ui->cb_outputRate5->setEnabled(true);
ui->cb_outputRate6->setEnabled(true);
ui->cb_outputMode1->setEnabled(true);
ui->cb_outputMode2->setEnabled(true);
ui->cb_outputMode3->setEnabled(true);
ui->cb_outputMode4->setEnabled(true);
ui->cb_outputMode5->setEnabled(true);
ui->cb_outputMode6->setEnabled(true);
bankLabels << "1 (1-2)" << "2 (3)" << "3 (4)" << "4 (5-6)" << "5 (7-8)" << "6 (9-10)";
ChannelBanks << 1 << 1 << 2 << 3 << 4 << 4 << 5 << 5 << 6 << 6;
}
}
i = 0;
foreach(QString banklabel, bankLabels) {
bank[i]->setText(banklabel);
outputRateCombos[i]->setEnabled(true);
setColor(outputRateCombos[i], bankColors[i]);
outputModeCombos[i]->setEnabled(true);
setColor(outputModeCombos[i], bankColors[i]);
i++;
}
// Get Channel ranges:
i = 0;
foreach(OutputChannelForm * outputChannelForm, outputChannelForms) {
int minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()];
int maxValue = actuatorSettingsData.ChannelMax[outputChannelForm->index()];
outputChannelForm->setRange(minValue, maxValue);
if (ChannelBanks.count() > i) {
outputChannelForm->setBank(QString("%1:").arg(ChannelBanks.at(i)));
outputChannelForm->setColor(bankColors[ChannelBanks.at(i++) - 1]);
}
int neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()];
outputChannelForm->setNeutral(neutral);
}

View File

@ -59,6 +59,8 @@ private:
void assignOutputChannel(UAVDataObject *obj, QString &str);
void setColor(QWidget *widget, const QColor color);
OutputChannelForm *getOutputChannelForm(const int index) const;
void sendAllChannelTests();

View File

@ -183,7 +183,7 @@
<item row="0" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Channels:</string>
<string>Bank(Channels):</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>

View File

@ -34,7 +34,7 @@ OutputChannelForm::OutputChannelForm(const int index, QWidget *parent) :
// The convention for OP is Channel 1 to Channel 10.
ui.actuatorNumber->setText(QString("%1:").arg(index + 1));
setBank("-");
// Register for ActuatorSettings changes:
connect(ui.actuatorMin, SIGNAL(editingFinished()), this, SLOT(setChannelRange()));
connect(ui.actuatorMax, SIGNAL(editingFinished()), this, SLOT(setChannelRange()));
@ -58,6 +58,11 @@ QString OutputChannelForm::name()
return ui.actuatorName->text();
}
QString OutputChannelForm::bank()
{
return ui.actuatorBankNumber->text();
}
/**
* Set the channel assignment label.
*/
@ -66,6 +71,27 @@ void OutputChannelForm::setName(const QString &name)
ui.actuatorName->setText(name);
}
void OutputChannelForm::setColor(const QColor &color)
{
QPalette p(palette());
p.setColor(QPalette::Background, color);
p.setColor(QPalette::Base, color);
p.setBrush(QPalette::Base, Qt::transparent);
ui.actuatorBankNumber->setAutoFillBackground(true);
ui.actuatorNumber->setAutoFillBackground(true);
ui.actuatorBankNumber->setPalette(p);
ui.actuatorNumber->setPalette(p);
}
/**
* Set the channel bank label.
*/
void OutputChannelForm::setBank(const QString &bank)
{
ui.actuatorBankNumber->setText(bank);
}
/**
* Restrict UI to protect users from accidental misuse.
*/

View File

@ -43,8 +43,12 @@ public:
friend class ConfigOutputWidget;
virtual QString name();
virtual void setName(const QString &name);
virtual QString bank();
virtual void setName(const QString &name);
virtual void setBank(const QString &bank);
virtual void setColor(const QColor &color);
public slots:
int min() const;
void setMin(int minimum);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>768</width>
<height>51</height>
<height>54</height>
</rect>
</property>
<property name="windowTitle">
@ -29,7 +29,7 @@
<property name="horizontalSpacing">
<number>12</number>
</property>
<item row="0" column="1">
<item row="0" column="2">
<widget class="QLabel" name="legend0">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -72,7 +72,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="3">
<widget class="QLabel" name="legend1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -115,7 +115,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="0" column="4">
<item row="0" column="5">
<widget class="QLabel" name="legend2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -152,7 +152,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="0" column="5">
<item row="0" column="6">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -217,7 +217,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -233,7 +233,7 @@ margin:1px;</string>
</property>
</spacer>
</item>
<item row="1" column="5">
<item row="1" column="6">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -249,7 +249,7 @@ margin:1px;</string>
</property>
</spacer>
</item>
<item row="1" column="3">
<item row="1" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -265,7 +265,7 @@ margin:1px;</string>
</property>
</spacer>
</item>
<item row="1" column="2">
<item row="1" column="3">
<widget class="QSpinBox" name="actuatorMin">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -322,9 +322,18 @@ margin:1px;</string>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Channel Number</string>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 5;\nfont: bold 12px;\nmargin:1px;</string>
</property>
<property name="text">
<string>0:</string>
</property>
@ -333,7 +342,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="0" column="6">
<item row="0" column="7">
<widget class="QLabel" name="legend3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -376,7 +385,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="0" column="7">
<item row="0" column="8">
<widget class="QLabel" name="legend4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -419,7 +428,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="0" column="8">
<item row="0" column="9">
<widget class="QLabel" name="legend5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -462,7 +471,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="2">
<widget class="QLabel" name="actuatorName">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@ -490,7 +499,7 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="1" column="6">
<item row="1" column="7">
<widget class="QSpinBox" name="actuatorMax">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -524,8 +533,8 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QFrame" name="frame">
<item row="1" column="5">
<widget class="QFrame" name="barFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -607,7 +616,7 @@ margin:1px;</string>
</layout>
</widget>
</item>
<item row="1" column="7">
<item row="1" column="8">
<widget class="QFrame" name="frame_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@ -665,7 +674,7 @@ margin:1px;</string>
</layout>
</widget>
</item>
<item row="1" column="8">
<item row="1" column="9">
<widget class="QFrame" name="frame_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@ -726,6 +735,89 @@ margin:1px;</string>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</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>Bank</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="actuatorBankNumber">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Bank number</string>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 5;\nfont: 12px;\nmargin:1px;</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>