2 #include "ui_inputchannelform.h"
4 #include "manualcontrolsettings.h"
5 #include "uavtalkreceiver.h"
14 , ui(new Ui::InputChannelForm)
15 , m_chanType(chanType)
21 layout()->removeWidget(ui->legend0);
22 layout()->removeWidget(ui->legend1);
23 layout()->removeWidget(ui->legend2);
24 layout()->removeWidget(ui->legend3);
25 layout()->removeWidget(ui->legend4);
26 layout()->removeWidget(ui->legend5);
27 layout()->removeWidget(ui->legend6);
28 layout()->removeWidget(ui->lblReverse);
36 delete ui->lblReverse;
40 ui->channelNeutral->setHidden(
true);
44 sbChannelCurrent =
new QSpinBox(
this);
45 sbChannelCurrent->setVisible(
false);
46 sbChannelCurrent->setMaximum(65535);
49 connect(ui->channelMin, QOverload<int>::of(&QSpinBox::valueChanged),
this,
50 &inputChannelForm::minMaxUpdated);
51 connect(ui->channelMax, QOverload<int>::of(&QSpinBox::valueChanged),
this,
52 &inputChannelForm::minMaxUpdated);
53 connect(ui->channelGroup, QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
54 &inputChannelForm::groupUpdated);
55 connect(sbChannelCurrent, QOverload<int>::of(&QSpinBox::valueChanged), ui->channelNeutral,
57 connect(ui->btnReverse, &QAbstractButton::released,
this, &inputChannelForm::reverseChannel);
62 connect(ui->channelNumberDropdown, QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
63 &inputChannelForm::channelDropdownUpdated);
64 connect(ui->channelNumber, QOverload<int>::of(&QSpinBox::valueChanged),
this,
65 &inputChannelForm::channelNumberUpdated);
77 ui->channelName->setText(name);
78 QFontMetrics metrics(ui->channelName->font());
79 int width = metrics.width(name) + 5;
80 foreach (
inputChannelForm *form, parent()->findChildren<inputChannelForm *>()) {
83 if (form->ui->channelName->minimumSize().width() < width)
84 form->ui->channelName->setMinimumSize(width, 0);
86 width = form->ui->channelName->minimumSize().width();
88 ui->channelName->setMinimumSize(width, 0);
94 void inputChannelForm::minMaxUpdated()
96 if (ui->channelMin->value() != ui->channelMax->value()) {
97 bool reverse = (ui->channelMin->value() > ui->channelMax->value());
99 ui->channelNeutral->setMinimum(ui->channelMax->value());
100 ui->channelNeutral->setMaximum(ui->channelMin->value());
103 ui->channelNeutral->setProperty(
"state",
"inverted");
105 ui->channelNeutral->setMinimum(ui->channelMin->value());
106 ui->channelNeutral->setMaximum(ui->channelMax->value());
109 ui->channelNeutral->setProperty(
"state",
"normal");
111 ui->channelNeutral->setInvertedAppearance(reverse);
114 ui->channelNeutral->setEnabled(
true);
118 ui->channelNeutral->setMinimum(ui->channelMin->value() - 1);
119 ui->channelNeutral->setMaximum(ui->channelMax->value() + 1);
120 ui->channelNeutral->setEnabled(
false);
124 ui->channelNeutral->setStyle(QApplication::style());
133 void inputChannelForm::groupUpdated()
135 int selected = ui->channelNumberDropdown->currentIndex();
136 ui->channelNumberDropdown->clear();
137 ui->channelNumberDropdown->addItem(
"Disabled");
141 switch (m_chanType) {
144 switch (ui->channelGroup->currentIndex()) {
148 case ManualControlSettings::CHANNELGROUPS_PWM:
151 case ManualControlSettings::CHANNELGROUPS_PPM:
152 case ManualControlSettings::CHANNELGROUPS_DSM:
155 case ManualControlSettings::CHANNELGROUPS_SBUS:
158 case ManualControlSettings::CHANNELGROUPS_OPENLRS:
161 case ManualControlSettings::CHANNELGROUPS_UAVTALK:
162 count = UAVTalkReceiver::CHANNEL_NUMELEM;
164 case ManualControlSettings::CHANNELGROUPS_HOTTSUM:
167 case ManualControlSettings::CHANNELGROUPS_SRXL:
170 case ManualControlSettings::CHANNELGROUPS_IBUS:
173 case ManualControlSettings::CHANNELGROUPS_TBSCROSSFIRE:
176 case ManualControlSettings::CHANNELGROUPS_NONE:
185 switch (ui->channelGroup->currentIndex()) {
189 case ManualControlSettings::RSSITYPE_PWM:
192 case ManualControlSettings::RSSITYPE_PPM:
195 case ManualControlSettings::RSSITYPE_SBUS:
198 case ManualControlSettings::RSSITYPE_HOTTSUM:
201 case ManualControlSettings::RSSITYPE_ADC:
204 case ManualControlSettings::RSSITYPE_OPENLRS:
207 case ManualControlSettings::RSSITYPE_FRSKYPWM:
210 case ManualControlSettings::RSSITYPE_TBSCROSSFIRE:
213 case ManualControlSettings::RSSITYPE_IBUS:
216 case ManualControlSettings::RSSITYPE_NONE:
225 ui->channelNumber->setMaximum(count);
226 ui->channelNumber->setMinimum(0);
229 && ui->channelGroup->currentIndex() == ManualControlSettings::RSSITYPE_ADC) {
235 for (
int i = 0;
i < count;
i++) {
237 if (
i < names.length())
238 name = names[
i] + QString(
" (ADC%1)").arg(
i);
239 else if (names.isEmpty())
240 name = QString(
"ADC%1").arg(
i);
242 name = QString(
"N/A (ADC%1)").arg(
i);
244 ui->channelNumberDropdown->addItem(name);
247 for (
int i = 0;
i < count;
i++)
248 ui->channelNumberDropdown->addItem(QString(tr(
"Chan %1").arg(
i + 1)));
249 if (selected > 0 && selected <= count)
250 ui->channelNumberDropdown->setCurrentIndex(selected);
259 void inputChannelForm::channelDropdownUpdated(
int newval)
261 ui->channelNumber->setValue(newval);
267 void inputChannelForm::channelNumberUpdated(
int newval)
269 ui->channelNumberDropdown->setCurrentIndex(newval);
276 void inputChannelForm::reverseChannel()
278 int min = ui->channelMin->value();
279 int neutral = ui->channelNeutral->value();
280 int max = ui->channelMax->value();
281 ui->channelMax->setValue(min);
282 ui->channelMin->setValue(max);
283 if (ui->channelName->text() ==
"Throttle")
284 neutral = max - (neutral - min);
285 ui->channelNeutral->setValue(neutral);
293 return ui->channelGroup->currentIndex() != ManualControlSettings::CHANNELGROUPS_NONE
294 && ui->channelNumber->value() > 0;
virtual QStringList getAdcNames()
void setIndicatorValue(int us)
Core::IBoardType * getBoardType()
Get the IBoardType corresponding to the connected board.