5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
23 #include "ui_setup_timer.h"
24 #include "ui_setup_module.h"
25 #include "switchitemmodel.h"
27 #include "modelprinter.h"
28 #include "multiprotocols.h"
29 #include "checklistdialog.h"
31 TimerPanel::TimerPanel(QWidget
*parent
, ModelData
& model
, TimerData
& timer
, GeneralSettings
& generalSettings
, Firmware
* firmware
, QWidget
* prevFocus
):
32 ModelPanel(parent
, model
, generalSettings
, firmware
),
36 Board::Type board
= firmware
->getBoard();
43 int length
= firmware
->getCapability(TimersName
);
48 ui
->name
->setMaxLength(length
);
49 ui
->name
->setText(timer
.name
);
53 rawSwitchItemModel
= new RawSwitchFilterItemModel(&generalSettings
, &model
, TimersContext
);
54 ui
->mode
->setModel(rawSwitchItemModel
);
55 ui
->mode
->setCurrentIndex(ui
->mode
->findData(timer
.mode
.toValue()));
57 if (!firmware
->getCapability(PermTimers
)) {
58 ui
->persistent
->hide();
59 ui
->persistentValue
->hide();
62 ui
->countdownBeep
->setField(timer
.countdownBeep
, this);
63 ui
->countdownBeep
->addItem(tr("Silent"), TimerData::COUNTDOWN_SILENT
);
64 ui
->countdownBeep
->addItem(tr("Beeps"), TimerData::COUNTDOWN_BEEPS
);
65 if (IS_ARM(board
) || IS_2560(board
)) {
66 ui
->countdownBeep
->addItem(tr("Voice"), TimerData::COUNTDOWN_VOICE
);
67 ui
->countdownBeep
->addItem(tr("Haptic"), TimerData::COUNTDOWN_HAPTIC
);
70 ui
->value
->setMaximumTime(firmware
->getMaxTimerStart());
72 ui
->persistent
->setField(timer
.persistent
, this);
73 ui
->persistent
->addItem(tr("Not persistent"), 0);
74 ui
->persistent
->addItem(tr("Persistent (flight)"), 1);
75 ui
->persistent
->addItem(tr("Persistent (manual reset)"), 2);
77 disableMouseScrolling();
78 QWidget::setTabOrder(prevFocus
, ui
->name
);
79 QWidget::setTabOrder(ui
->name
, ui
->value
);
80 QWidget::setTabOrder(ui
->value
, ui
->mode
);
81 QWidget::setTabOrder(ui
->mode
, ui
->countdownBeep
);
82 QWidget::setTabOrder(ui
->countdownBeep
, ui
->minuteBeep
);
83 QWidget::setTabOrder(ui
->minuteBeep
, ui
->persistent
);
88 TimerPanel::~TimerPanel()
93 void TimerPanel::update()
95 rawSwitchItemModel
->update();
97 int hour
= timer
.val
/ 3600;
98 int min
= (timer
.val
- (hour
* 3600)) / 60;
99 int sec
= (timer
.val
- (hour
* 3600)) % 60;
101 ui
->value
->setTime(QTime(hour
, min
, sec
));
103 if (firmware
->getCapability(PermTimers
)) {
105 int pvalue
= timer
.pvalue
;
110 int hours
= pvalue
/ 3600;
111 pvalue
-= hours
* 3600;
112 int minutes
= pvalue
/ 60;
113 int seconds
= pvalue
% 60;
114 ui
->persistentValue
->setText(QString(" %1(%2:%3:%4)").arg(sign
<0 ? "-" :" ").arg(hours
, 2, 10, QLatin1Char('0')).arg(minutes
, 2, 10, QLatin1Char('0')).arg(seconds
, 2, 10, QLatin1Char('0')));
117 ui
->minuteBeep
->setChecked(timer
.minuteBeep
);
120 QWidget
* TimerPanel::getLastFocus()
122 return ui
->persistent
;
125 void TimerPanel::on_value_editingFinished()
127 unsigned val
= ui
->value
->time().hour()*3600 + ui
->value
->time().minute()*60 + ui
->value
->time().second();
128 if (timer
.val
!= val
) {
134 void TimerPanel::on_mode_currentIndexChanged(int index
)
137 timer
.mode
= RawSwitch(ui
->mode
->itemData(index
).toInt());
142 void TimerPanel::on_minuteBeep_toggled(bool checked
)
144 timer
.minuteBeep
= checked
;
148 void TimerPanel::on_name_editingFinished()
150 if (QString(timer
.name
) != ui
->name
->text()) {
151 int length
= ui
->name
->maxLength();
152 strncpy(timer
.name
, ui
->name
->text().toLatin1(), length
);
157 /******************************************************************************/
159 #define FAILSAFE_CHANNEL_HOLD 2000
160 #define FAILSAFE_CHANNEL_NOPULSE 2001
162 #define MASK_PROTOCOL 1
163 #define MASK_CHANNELS_COUNT 2
164 #define MASK_RX_NUMBER 4
165 #define MASK_CHANNELS_RANGE 8
166 #define MASK_PPM_FIELDS 16
167 #define MASK_FAILSAFES 32
168 #define MASK_OPEN_DRAIN 64
169 #define MASK_MULTIMODULE 128
170 #define MASK_ANTENNA 256
171 #define MASK_MULTIOPTION 512
172 #define MASK_R9M 1024
173 #define MASK_SBUSPPM_FIELDS 2048
174 #define MASK_SUBTYPES 4096
176 quint8
ModulePanel::failsafesValueDisplayType
= ModulePanel::FAILSAFE_DISPLAY_PERCENT
;
178 ModulePanel::ModulePanel(QWidget
* parent
, ModelData
& model
, ModuleData
& module
, GeneralSettings
& generalSettings
, Firmware
* firmware
, int moduleIdx
):
179 ModelPanel(parent
, model
, generalSettings
, firmware
),
181 moduleIdx(moduleIdx
),
190 label
= tr("Trainer Port");
191 if (IS_HORUS(firmware
->getBoard())) {
192 ui
->trainerMode
->setItemData(TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE
, 0, Qt::UserRole
- 1);
193 ui
->trainerMode
->setItemData(TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE
, 0, Qt::UserRole
- 1);
195 if (generalSettings
.hw_uartMode
!= UART_MODE_SBUS_TRAINER
) {
196 ui
->trainerMode
->setItemData(TRAINER_MODE_MASTER_BATTERY_COMPARTMENT
, 0, Qt::UserRole
- 1);
198 ui
->trainerMode
->setCurrentIndex(model
.trainerMode
);
199 if (!IS_HORUS_OR_TARANIS(firmware
->getBoard())) {
200 ui
->label_trainerMode
->hide();
201 ui
->trainerMode
->hide();
203 ui
->formLayout_col1
->setSpacing(0);
206 ui
->label_trainerMode
->hide();
207 ui
->trainerMode
->hide();
208 if (firmware
->getCapability(NumModules
) > 1) {
209 if (IS_HORUS_OR_TARANIS(firmware
->getBoard())) {
211 label
= tr("Internal Radio System");
213 label
= tr("External Radio Module");
217 label
= tr("Radio System");
219 label
= tr("Extra Radio System");
223 label
= tr("Radio System");
226 ui
->label_module
->setText(label
);
228 // The protocols available on this board
229 for (int i
=0; i
<PULSES_PROTOCOL_LAST
; i
++) {
230 if (firmware
->isAvailable((PulsesProtocol
) i
, moduleIdx
)) {
231 if (IS_TARANIS_XLITE(firmware
->getBoard()) && i
== PULSES_PXX_R9M
) //TODO remove when mini are handled as a different module type
232 ui
->protocol
->addItem("FrSky R9M Mini", (QVariant
) i
);
234 ui
->protocol
->addItem(ModelPrinter::printModuleProtocol(i
), (QVariant
) i
);
235 if (i
== module
.protocol
)
236 ui
->protocol
->setCurrentIndex(ui
->protocol
->count()-1);
239 for (int i
=0; i
<=MM_RF_PROTO_LAST
; i
++) {
240 ui
->multiProtocol
->addItem(ModelPrinter::printMultiRfProtocol(i
, false), (QVariant
) i
);
243 ui
->btnGrpValueType
->setId(ui
->optPercent
, FAILSAFE_DISPLAY_PERCENT
);
244 ui
->btnGrpValueType
->setId(ui
->optUs
, FAILSAFE_DISPLAY_USEC
);
245 ui
->btnGrpValueType
->button(failsafesValueDisplayType
)->setChecked(true);
249 disableMouseScrolling();
253 connect(ui
->protocol
, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged
), this, &ModulePanel::onProtocolChanged
);
254 connect(ui
->multiProtocol
, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged
), this, &ModulePanel::onMultiProtocolChanged
);
255 connect(this, &ModulePanel::channelsRangeChanged
, this, &ModulePanel::setupFailsafes
);
256 connect(ui
->btnGrpValueType
, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked
), this, &ModulePanel::onFailsafesDisplayValueTypeChanged
);
262 ModulePanel::~ModulePanel()
267 bool ModulePanel::moduleHasFailsafes()
269 return (((PulsesProtocol
)module
.protocol
== PulsesProtocol::PULSES_PXX_XJT_X16
|| (PulsesProtocol
)module
.protocol
== PulsesProtocol::PULSES_PXX_R9M
)
270 && firmware
->getCapability(HasFailsafe
));;
273 void ModulePanel::setupFailsafes()
275 ChannelFailsafeWidgetsGroup grp
;
276 const int start
= module
.channelsStart
;
277 const int end
= start
+ module
.channelsCount
;
278 const bool hasFailsafe
= moduleHasFailsafes();
282 QMutableMapIterator
<int, ChannelFailsafeWidgetsGroup
> i(failsafeGroupsMap
);
283 while (i
.hasNext()) {
286 ui
->failsafesLayout
->removeWidget(grp
.label
);
287 ui
->failsafesLayout
->removeWidget(grp
.combo
);
288 ui
->failsafesLayout
->removeWidget(grp
.sbPercent
);
289 ui
->failsafesLayout
->removeWidget(grp
.sbUsec
);
290 if (i
.key() < start
|| i
.key() >= end
|| !hasFailsafe
) {
291 grp
.label
->deleteLater();
292 grp
.combo
->deleteLater();
293 grp
.sbPercent
->deleteLater();
294 grp
.sbUsec
->deleteLater();
304 int channelMax
= model
->getChannelsMax();
305 int channelMaxUs
= 512 * channelMax
/ 100 * 2;
307 for (int i
= start
; i
< end
; ++i
) {
308 if (failsafeGroupsMap
.contains(i
)) {
309 grp
= failsafeGroupsMap
.value(i
);
312 QLabel
* label
= new QLabel(this);
313 label
->setProperty("index", i
);
314 label
->setText(QString::number(i
+1));
316 QComboBox
* combo
= new QComboBox(this);
317 combo
->setProperty("index", i
);
318 combo
->addItem(tr("Value"), 0);
319 combo
->addItem(tr("Hold"), FAILSAFE_CHANNEL_HOLD
);
320 combo
->addItem(tr("No Pulse"), FAILSAFE_CHANNEL_NOPULSE
);
322 QDoubleSpinBox
* sbDbl
= new QDoubleSpinBox(this);
323 sbDbl
->setProperty("index", i
);
324 sbDbl
->setMinimumSize(QSize(20, 0));
325 sbDbl
->setRange(-channelMax
, channelMax
);
326 sbDbl
->setSingleStep(0.1);
327 sbDbl
->setDecimals(1);
329 QSpinBox
* sbInt
= new QSpinBox(this);
330 sbInt
->setProperty("index", i
);
331 sbInt
->setMinimumSize(QSize(20, 0));
332 sbInt
->setRange(-channelMaxUs
, channelMaxUs
);
333 sbInt
->setSingleStep(1);
335 grp
= ChannelFailsafeWidgetsGroup();
337 grp
.sbPercent
= sbDbl
;
340 failsafeGroupsMap
.insert(i
, grp
);
342 connect(combo
, SIGNAL(currentIndexChanged(int)), this, SLOT(onFailsafeComboIndexChanged(int)));
343 connect(sbInt
, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeUsecChanged(int)));
344 connect(sbDbl
, SIGNAL(valueChanged(double)), this, SLOT(onFailsafePercentChanged(double)));
347 ui
->failsafesLayout
->addWidget(grp
.label
, row
, col
, Qt::AlignHCenter
);
348 ui
->failsafesLayout
->addWidget(grp
.combo
, row
+ 1, col
, Qt::AlignHCenter
);
349 ui
->failsafesLayout
->addWidget(grp
.sbPercent
, row
+ 2, col
, Qt::AlignHCenter
);
350 ui
->failsafesLayout
->addWidget(grp
.sbUsec
, row
+ 3, col
, Qt::AlignHCenter
);
351 grp
.sbPercent
->setVisible(failsafesValueDisplayType
== FAILSAFE_DISPLAY_PERCENT
);
352 grp
.sbUsec
->setVisible(failsafesValueDisplayType
== FAILSAFE_DISPLAY_USEC
);
365 void ModulePanel::update()
367 unsigned int mask
= 0;
368 PulsesProtocol protocol
= (PulsesProtocol
)module
.protocol
;
369 unsigned int max_rx_num
= 63;
371 if (moduleIdx
>= 0) {
372 mask
|= MASK_PROTOCOL
;
375 mask
|= MASK_R9M
| MASK_SUBTYPES
;
376 case PULSES_PXX_XJT_X16
:
377 case PULSES_PXX_XJT_D8
:
378 case PULSES_PXX_XJT_LR12
:
380 mask
|= MASK_CHANNELS_RANGE
| MASK_CHANNELS_COUNT
;
381 if (protocol
==PULSES_PXX_XJT_X16
|| protocol
==PULSES_PXX_XJT_LR12
|| protocol
==PULSES_PXX_R9M
)
382 mask
|= MASK_RX_NUMBER
;
383 if ((IS_HORUS(firmware
->getBoard()) || IS_TARANIS_XLITE(firmware
->getBoard())) && moduleIdx
==0)
384 mask
|= MASK_ANTENNA
;
389 mask
|= MASK_CHANNELS_RANGE
| MASK_RX_NUMBER
;
390 module
.channelsCount
= 6;
393 case PULSES_CROSSFIRE
:
394 mask
|= MASK_CHANNELS_RANGE
;
395 module
.channelsCount
= 16;
398 mask
|= MASK_PPM_FIELDS
| MASK_SBUSPPM_FIELDS
| MASK_CHANNELS_RANGE
| MASK_CHANNELS_COUNT
;
399 if (IS_9XRPRO(firmware
->getBoard())) {
400 mask
|= MASK_OPEN_DRAIN
;
404 module
.channelsCount
= 16;
405 mask
|= MASK_SBUSPPM_FIELDS
| MASK_CHANNELS_RANGE
;
407 case PULSES_MULTIMODULE
:
408 mask
|= MASK_CHANNELS_RANGE
| MASK_RX_NUMBER
| MASK_MULTIMODULE
| MASK_SUBTYPES
;
410 if (module
.multi
.rfProtocol
== MM_RF_PROTO_DSM2
)
411 mask
|= MASK_CHANNELS_COUNT
;
413 module
.channelsCount
= 16;
414 if (multiProtocols
.getProtocol(module
.multi
.rfProtocol
).optionsstr
!= nullptr)
415 mask
|= MASK_MULTIOPTION
;
416 if (multiProtocols
.getProtocol(module
.multi
.rfProtocol
).hasFailsafe
)
417 mask
|= MASK_FAILSAFES
;
425 else if (IS_HORUS_OR_TARANIS(firmware
->getBoard())) {
426 if (model
->trainerMode
== TRAINER_SLAVE_JACK
) {
427 mask
|= MASK_PPM_FIELDS
| MASK_CHANNELS_RANGE
| MASK_CHANNELS_COUNT
;
430 else if (model
->trainerMode
!= TRAINER_MASTER_JACK
) {
431 mask
|= MASK_PPM_FIELDS
| MASK_CHANNELS_RANGE
| MASK_CHANNELS_COUNT
;
434 if (moduleHasFailsafes()) {
435 mask
|= MASK_FAILSAFES
;
438 ui
->label_protocol
->setVisible(mask
& MASK_PROTOCOL
);
439 ui
->protocol
->setVisible(mask
& MASK_PROTOCOL
);
440 ui
->label_rxNumber
->setVisible(mask
& MASK_RX_NUMBER
);
441 ui
->rxNumber
->setVisible(mask
& MASK_RX_NUMBER
);
442 ui
->rxNumber
->setMaximum(max_rx_num
);
443 ui
->rxNumber
->setValue(module
.modelId
);
444 ui
->label_channelsStart
->setVisible(mask
& MASK_CHANNELS_RANGE
);
445 ui
->channelsStart
->setVisible(mask
& MASK_CHANNELS_RANGE
);
446 ui
->channelsStart
->setValue(module
.channelsStart
+1);
447 ui
->label_channelsCount
->setVisible(mask
& MASK_CHANNELS_RANGE
);
448 ui
->channelsCount
->setVisible(mask
& MASK_CHANNELS_RANGE
);
449 ui
->channelsCount
->setEnabled(mask
& MASK_CHANNELS_COUNT
);
450 ui
->channelsCount
->setValue(module
.channelsCount
);
451 ui
->channelsCount
->setSingleStep(firmware
->getCapability(HasPPMStart
) ? 1 : 2);
453 // PPM settings fields
454 ui
->label_ppmPolarity
->setVisible(mask
& MASK_SBUSPPM_FIELDS
);
455 ui
->ppmPolarity
->setVisible(mask
& MASK_SBUSPPM_FIELDS
);
456 ui
->ppmPolarity
->setCurrentIndex(module
.ppm
.pulsePol
);
457 ui
->label_ppmOutputType
->setVisible(mask
& MASK_OPEN_DRAIN
);
458 ui
->ppmOutputType
->setVisible(mask
& MASK_OPEN_DRAIN
);
459 ui
->ppmOutputType
->setCurrentIndex(module
.ppm
.outputType
);
460 ui
->label_ppmDelay
->setVisible(mask
& MASK_PPM_FIELDS
);
461 ui
->ppmDelay
->setVisible(mask
& MASK_PPM_FIELDS
);
462 ui
->ppmDelay
->setValue(module
.ppm
.delay
);
463 ui
->label_ppmFrameLength
->setVisible(mask
& MASK_SBUSPPM_FIELDS
);
464 ui
->ppmFrameLength
->setVisible(mask
& MASK_SBUSPPM_FIELDS
);
465 ui
->ppmFrameLength
->setMinimum(module
.channelsCount
*(model
->extendedLimits
? 2.250 : 2)+3.5);
466 ui
->ppmFrameLength
->setMaximum(firmware
->getCapability(PPMFrameLength
));
467 ui
->ppmFrameLength
->setValue(22.5+((double)module
.ppm
.frameLength
)*0.5);
469 // Antenna selection on Horus and xlite
470 ui
->label_antenna
->setVisible(mask
& MASK_ANTENNA
);
471 ui
->antennaMode
->setVisible(mask
& MASK_ANTENNA
);
472 if IS_HORUS_X12S(firmware
->getBoard()) {
473 ui
->antennaMode
->setItemText(1,tr("Ext. + Int"));
476 ui
->antennaMode
->setItemText(1,tr("External"));
478 ui
->antennaMode
->setCurrentIndex(module
.pxx
.external_antenna
);
481 ui
->r9mPower
->setVisible(mask
& MASK_R9M
);
482 ui
->label_r9mPower
->setVisible(mask
& MASK_R9M
);
483 ui
->warning_r9mPower
->setVisible((mask
& MASK_R9M
) && module
.subType
== R9M_LBT
);
485 if (mask
& MASK_R9M
) {
486 const QSignalBlocker
blocker(ui
->r9mPower
);
487 ui
->r9mPower
->clear();
488 Board::Type board
= firmware
->getBoard();
489 if (IS_TARANIS_XLITE(board
)) {
490 if (module
.subType
== R9M_FCC
) {
491 ui
->r9mPower
->addItem(tr("100 mW - 16CH"));
494 ui
->r9mPower
->addItem(tr("25 mW - 8CH"));
495 ui
->r9mPower
->addItem(tr("25 mW - 16CH"));
496 ui
->r9mPower
->addItem(tr("100 mW - 16CH, no telemetry"));
500 if (module
.subType
== R9M_FCC
) {
501 ui
->r9mPower
->addItem(tr("10 mW - 16CH"));
502 ui
->r9mPower
->addItem(tr("100 mW - 16CH"));
503 ui
->r9mPower
->addItem(tr("500 mW - 16CH"));
504 ui
->r9mPower
->addItem(tr("1000 mW - 16CH"));
507 ui
->r9mPower
->addItem(tr("25 mW - 8CH"));
508 ui
->r9mPower
->addItem(tr("25 mW - 16CH"));
509 ui
->r9mPower
->addItem(tr("200 mW - 16CH"));
510 ui
->r9mPower
->addItem(tr("500 mW - 16CH"));
513 ui
->r9mPower
->setCurrentIndex(module
.pxx
.power
);
517 ui
->label_multiSubType
->setVisible(mask
& MASK_SUBTYPES
);
518 ui
->multiSubType
->setVisible(mask
& MASK_SUBTYPES
);
519 if (mask
& MASK_SUBTYPES
) {
520 unsigned numEntries
= 2; // R9M FCC/EU
521 if (mask
& MASK_MULTIMODULE
)
522 numEntries
= (module
.multi
.customProto
? 8 : multiProtocols
.getProtocol(module
.multi
.rfProtocol
).numSubytes());
524 const QSignalBlocker
blocker(ui
->multiSubType
);
525 ui
->multiSubType
->clear();
526 for (unsigned i
=0; i
< numEntries
; i
++)
527 ui
->multiSubType
->addItem(ModelPrinter::printModuleSubType(protocol
, i
, module
.multi
.rfProtocol
, module
.multi
.customProto
), i
);
528 ui
->multiSubType
->setCurrentIndex(module
.subType
);
531 // Multi settings fields
532 ui
->label_multiProtocol
->setVisible(mask
& MASK_MULTIMODULE
);
533 ui
->multiProtocol
->setVisible(mask
& MASK_MULTIMODULE
);
534 ui
->label_option
->setVisible(mask
& MASK_MULTIOPTION
);
535 ui
->optionValue
->setVisible(mask
& MASK_MULTIOPTION
);
536 ui
->autoBind
->setVisible(mask
& MASK_MULTIMODULE
);
537 ui
->lowPower
->setVisible(mask
& MASK_MULTIMODULE
);
539 if (mask
& MASK_MULTIMODULE
) {
540 ui
->multiProtocol
->setCurrentIndex(module
.multi
.rfProtocol
);
541 ui
->autoBind
->setChecked(module
.multi
.autoBindMode
);
542 ui
->lowPower
->setChecked(module
.multi
.lowPowerMode
);
545 if (mask
& MASK_MULTIOPTION
) {
546 auto pdef
= multiProtocols
.getProtocol(module
.multi
.rfProtocol
);
547 ui
->optionValue
->setMinimum(pdef
.getOptionMin());
548 ui
->optionValue
->setMaximum(pdef
.getOptionMax());
549 ui
->optionValue
->setValue(module
.multi
.optionValue
);
550 ui
->label_option
->setText(qApp
->translate("Multiprotocols", qPrintable(pdef
.optionsstr
)));
554 ui
->label_failsafeMode
->setVisible(mask
& MASK_FAILSAFES
);
555 ui
->failsafeMode
->setVisible(mask
& MASK_FAILSAFES
);
557 if ((mask
& MASK_FAILSAFES
) && module
.failsafeMode
== FAILSAFE_CUSTOM
) {
558 if (ui
->failsafesGroupBox
->isHidden()) {
560 ui
->failsafesGroupBox
->setVisible(true);
564 ui
->failsafesGroupBox
->setVisible(false);
567 if (mask
& MASK_FAILSAFES
) {
568 ui
->failsafeMode
->setCurrentIndex(module
.failsafeMode
);
570 if (firmware
->getCapability(ChannelsName
)) {
573 QMapIterator
<int, ChannelFailsafeWidgetsGroup
> i(failsafeGroupsMap
);
574 while (i
.hasNext()) {
577 name
= QString(model
->limitData
[chan
+ module
.channelsStart
].name
).trimmed();
579 i
.value().label
->setText(QString::number(chan
+ 1));
581 i
.value().label
->setText(name
);
586 if (mask
& MASK_CHANNELS_RANGE
) {
587 ui
->channelsStart
->setMaximum(33 - ui
->channelsCount
->value());
588 ui
->channelsCount
->setMaximum(qMin(16, 33-ui
->channelsStart
->value()));
592 void ModulePanel::on_trainerMode_currentIndexChanged(int index
)
594 if (!lock
&& model
->trainerMode
!= (unsigned)index
) {
595 model
->trainerMode
= index
;
601 void ModulePanel::onProtocolChanged(int index
)
603 if (!lock
&& module
.protocol
!= ui
->protocol
->itemData(index
).toInt()) {
604 module
.protocol
= ui
->protocol
->itemData(index
).toInt();
610 void ModulePanel::on_ppmPolarity_currentIndexChanged(int index
)
612 if (!lock
&& module
.ppm
.pulsePol
!= (bool)index
) {
613 module
.ppm
.pulsePol
= index
;
618 void ModulePanel::on_antennaMode_currentIndexChanged(int index
)
620 if (!lock
&& module
.pxx
.external_antenna
!= (bool)index
) {
621 module
.pxx
.external_antenna
= index
;
626 void ModulePanel::on_r9mPower_currentIndexChanged(int index
)
628 if (!lock
&& module
.pxx
.power
!= index
) {
629 module
.pxx
.power
= index
;
634 void ModulePanel::on_ppmOutputType_currentIndexChanged(int index
)
636 if (!lock
&& module
.ppm
.outputType
!= (bool)index
) {
637 module
.ppm
.outputType
= index
;
642 void ModulePanel::on_channelsCount_editingFinished()
644 if (!lock
&& module
.channelsCount
!= ui
->channelsCount
->value()) {
645 module
.channelsCount
= ui
->channelsCount
->value();
647 emit
channelsRangeChanged();
652 void ModulePanel::on_channelsStart_editingFinished()
654 if (!lock
&& module
.channelsStart
!= (unsigned)ui
->channelsStart
->value() - 1) {
655 module
.channelsStart
= (unsigned)ui
->channelsStart
->value() - 1;
657 emit
channelsRangeChanged();
662 void ModulePanel::on_ppmDelay_editingFinished()
664 if (!lock
&& module
.ppm
.delay
!= ui
->ppmDelay
->value()) {
665 // TODO only accept valid values
666 module
.ppm
.delay
= ui
->ppmDelay
->value();
671 void ModulePanel::on_rxNumber_editingFinished()
673 if (module
.modelId
!= (unsigned)ui
->rxNumber
->value()) {
674 module
.modelId
= (unsigned)ui
->rxNumber
->value();
679 void ModulePanel::on_ppmFrameLength_editingFinished()
681 int val
= (ui
->ppmFrameLength
->value()-22.5) / 0.5;
682 if (module
.ppm
.frameLength
!= val
) {
683 module
.ppm
.frameLength
= val
;
688 void ModulePanel::on_failsafeMode_currentIndexChanged(int value
)
690 if (!lock
&& module
.failsafeMode
!= (unsigned)value
) {
691 module
.failsafeMode
= value
;
697 void ModulePanel::onMultiProtocolChanged(int index
)
699 if (!lock
&& module
.multi
.rfProtocol
!= (unsigned)index
) {
701 module
.multi
.rfProtocol
= (unsigned int) index
;
702 unsigned int maxSubTypes
= multiProtocols
.getProtocol(index
).numSubytes();
703 if (module
.multi
.customProto
)
705 module
.subType
= std::min(module
.subType
, maxSubTypes
-1);
712 void ModulePanel::on_optionValue_editingFinished()
714 if (module
.multi
.optionValue
!= ui
->optionValue
->value()) {
715 module
.multi
.optionValue
= ui
->optionValue
->value();
720 void ModulePanel::on_multiSubType_currentIndexChanged(int index
)
722 if (!lock
&& module
.subType
!= (unsigned)index
) {
724 module
.subType
= index
;
731 void ModulePanel::on_autoBind_stateChanged(int state
)
733 module
.multi
.autoBindMode
= (state
== Qt::Checked
);
735 void ModulePanel::on_lowPower_stateChanged(int state
)
737 module
.multi
.lowPowerMode
= (state
== Qt::Checked
);
740 // updtSb (update spin box(es)): 0=none or bitmask of FailsafeValueDisplayTypes
741 void ModulePanel::setChannelFailsafeValue(const int channel
, const int value
, quint8 updtSb
)
743 if (channel
< 0 || channel
>= CPN_MAX_CHNOUT
)
746 module
.failsafeChannels
[channel
] = value
;
747 double pctVal
= divRoundClosest(value
* 1000, 1024) / 10.0;
748 // qDebug() << value << pctVal;
750 if (failsafeGroupsMap
.contains(channel
)) {
751 const ChannelFailsafeWidgetsGroup
& grp
= failsafeGroupsMap
.value(channel
);
752 if ((updtSb
& FAILSAFE_DISPLAY_PERCENT
) && grp
.sbPercent
) {
753 grp
.sbPercent
->blockSignals(true);
754 grp
.sbPercent
->setValue(pctVal
);
755 grp
.sbPercent
->blockSignals(false);
757 if ((updtSb
& FAILSAFE_DISPLAY_USEC
) && grp
.sbUsec
) {
758 grp
.sbUsec
->blockSignals(true);
759 grp
.sbUsec
->setValue(value
);
760 grp
.sbUsec
->blockSignals(false);
767 void ModulePanel::onFailsafeUsecChanged(int value
)
773 int channel
= sender()->property("index").toInt(&ok
);
775 setChannelFailsafeValue(channel
, value
, FAILSAFE_DISPLAY_PERCENT
);
778 void ModulePanel::onFailsafePercentChanged(double value
)
784 int channel
= sender()->property("index").toInt(&ok
);
786 setChannelFailsafeValue(channel
, divRoundClosest(int(value
* 1024), 100), FAILSAFE_DISPLAY_USEC
);
789 void ModulePanel::onFailsafeComboIndexChanged(int index
)
794 QComboBox
* cb
= qobject_cast
<QComboBox
*>(sender());
799 int channel
= sender()->property("index").toInt(&ok
);
801 module
.failsafeChannels
[channel
] = cb
->itemData(index
).toInt();
802 updateFailsafe(channel
);
809 void ModulePanel::onFailsafesDisplayValueTypeChanged(int type
)
811 if (failsafesValueDisplayType
!= type
) {
812 failsafesValueDisplayType
= type
;
813 foreach (ChannelFailsafeWidgetsGroup grp
, failsafeGroupsMap
) {
815 grp
.sbPercent
->setVisible(type
== FAILSAFE_DISPLAY_PERCENT
);
817 grp
.sbUsec
->setVisible(type
== FAILSAFE_DISPLAY_USEC
);
822 void ModulePanel::onExtendedLimitsToggled()
824 double channelMaxPct
= double(model
->getChannelsMax());
825 int channelMaxUs
= 512 * channelMaxPct
/ 100 * 2;
826 foreach (ChannelFailsafeWidgetsGroup grp
, failsafeGroupsMap
) {
828 grp
.sbPercent
->setRange(-channelMaxPct
, channelMaxPct
);
830 grp
.sbUsec
->setRange(-channelMaxUs
, channelMaxUs
);
834 void ModulePanel::updateFailsafe(int channel
)
836 if (channel
>= CPN_MAX_CHNOUT
|| !failsafeGroupsMap
.contains(channel
))
839 const int failsafeValue
= module
.failsafeChannels
[channel
];
840 const ChannelFailsafeWidgetsGroup
& grp
= failsafeGroupsMap
.value(channel
);
841 const bool valDisable
= (failsafeValue
== FAILSAFE_CHANNEL_HOLD
|| failsafeValue
== FAILSAFE_CHANNEL_NOPULSE
);
844 grp
.combo
->setCurrentIndex(grp
.combo
->findData(valDisable
? failsafeValue
: 0));
846 grp
.sbPercent
->setDisabled(valDisable
);
848 grp
.sbUsec
->setDisabled(valDisable
);
851 setChannelFailsafeValue(channel
, failsafeValue
, (FAILSAFE_DISPLAY_PERCENT
| FAILSAFE_DISPLAY_USEC
));
854 /******************************************************************************/
856 SetupPanel::SetupPanel(QWidget
* parent
, ModelData
& model
, GeneralSettings
& generalSettings
, Firmware
* firmware
):
857 ModelPanel(parent
, model
, generalSettings
, firmware
),
860 Board::Type board
= firmware
->getBoard();
864 memset(modules
, 0, sizeof(modules
));
868 QRegExp
rx(CHAR_FOR_NAMES_REGEX
);
869 ui
->name
->setValidator(new QRegExpValidator(rx
, this));
870 ui
->name
->setMaxLength(firmware
->getCapability(ModelName
));
872 if (firmware
->getCapability(ModelImage
)) {
875 QString path
= g
.profile
[g
.id()].sdPath();
876 path
.append("/IMAGES/");
880 if(IS_HORUS(board
)) {
881 filters
<< "*.bmp" << "*.jpg" << "*.png";
882 foreach ( QString file
, qd
.entryList(filters
, QDir::Files
) ) {
884 QString temp
= fi
.fileName();
885 if (!items
.contains(temp
) && temp
.length() <= 6+4) {
892 foreach (QString file
, qd
.entryList(filters
, QDir::Files
)) {
894 QString temp
= fi
.completeBaseName();
895 if (!items
.contains(temp
) && temp
.length() <= 10+4) {
901 if (!items
.contains(model
.bitmap
)) {
902 items
.append(model
.bitmap
);
905 foreach (QString file
, items
) {
906 ui
->image
->addItem(file
);
907 if (file
== model
.bitmap
) {
908 ui
->image
->setCurrentIndex(ui
->image
->count()-1);
909 QString fileName
= path
;
910 fileName
.append(model
.bitmap
);
911 if (!IS_HORUS(board
))
912 fileName
.append(".bmp");
913 QImage
image(fileName
);
914 if (image
.isNull() && !IS_HORUS(board
)) {
916 fileName
.append(model
.bitmap
);
917 fileName
.append(".BMP");
918 image
.load(fileName
);
920 if (!image
.isNull()) {
921 if (IS_HORUS(board
)) {
922 ui
->imagePreview
->setFixedSize(QSize(192, 114));
923 ui
->imagePreview
->setPixmap(QPixmap::fromImage(image
.scaled(192, 114)));
926 ui
->imagePreview
->setFixedSize(QSize(64, 32));
927 ui
->imagePreview
->setPixmap(QPixmap::fromImage(image
.scaled(64, 32)));
935 ui
->modelImage_label
->hide();
936 ui
->imagePreview
->hide();
939 QWidget
* prevFocus
= ui
->image
;
940 for (int i
=0; i
<CPN_MAX_TIMERS
; i
++) {
941 if (i
<firmware
->getCapability(Timers
)) {
942 timers
[i
] = new TimerPanel(this, model
, model
.timers
[i
], generalSettings
, firmware
, prevFocus
);
943 ui
->gridLayout
->addWidget(timers
[i
], 1+i
, 1);
944 connect(timers
[i
], &TimerPanel::modified
, this, &SetupPanel::modified
);
945 prevFocus
= timers
[i
]->getLastFocus();
948 foreach(QLabel
*label
, findChildren
<QLabel
*>(QRegExp(QString("label_timer%1").arg(i
+1)))) {
954 if (firmware
->getCapability(HasTopLcd
)) {
955 ui
->toplcdTimer
->setField(model
.toplcdTimer
, this);
956 for (int i
=0; i
<CPN_MAX_TIMERS
; i
++) {
957 if (i
<firmware
->getCapability(Timers
)) {
958 ui
->toplcdTimer
->addItem(tr("Timer %1").arg(i
+1), i
);
963 ui
->toplcdTimerLabel
->hide();
964 ui
->toplcdTimer
->hide();
967 if (!firmware
->getCapability(HasDisplayText
)) {
968 ui
->displayText
->hide();
969 ui
->editText
->hide();
972 if (!firmware
->getCapability(GlobalFunctions
)) {
973 ui
->gfEnabled
->hide();
976 // Beep Center checkboxes
977 prevFocus
= ui
->trimsDisplay
;
978 int analogs
= CPN_MAX_STICKS
+ getBoardCapability(board
, Board::Pots
) + getBoardCapability(board
, Board::Sliders
);
980 for (int i
=0; i
< analogs
+ firmware
->getCapability(RotaryEncoders
); i
++) {
981 RawSource
src((i
< analogs
) ? SOURCE_TYPE_STICK
: SOURCE_TYPE_ROTARY_ENCODER
, (i
< analogs
) ? i
: analogs
- i
);
982 QCheckBox
* checkbox
= new QCheckBox(this);
983 checkbox
->setProperty("index", i
);
984 checkbox
->setText(src
.toString(&model
, &generalSettings
));
985 ui
->centerBeepLayout
->addWidget(checkbox
, 0, i
+1);
986 connect(checkbox
, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
987 centerBeepCheckboxes
<< checkbox
;
988 if (IS_HORUS_OR_TARANIS(board
)) {
989 if (src
.isPot(&genAryIdx
) && !generalSettings
.isPotAvailable(genAryIdx
)) {
992 else if (src
.isSlider(&genAryIdx
) && !generalSettings
.isSliderAvailable(genAryIdx
)) {
996 QWidget::setTabOrder(prevFocus
, checkbox
);
997 prevFocus
= checkbox
;
1000 // Startup switches warnings
1001 for (int i
=0; i
<getBoardCapability(board
, Board::Switches
); i
++) {
1002 Board::SwitchInfo switchInfo
= Boards::getSwitchInfo(board
, i
);
1003 switchInfo
.config
= Board::SwitchType(generalSettings
.switchConfig
[i
]);
1004 if (switchInfo
.config
== Board::SWITCH_NOT_AVAILABLE
|| switchInfo
.config
== Board::SWITCH_TOGGLE
) {
1007 RawSource
src(RawSourceType::SOURCE_TYPE_SWITCH
, i
);
1008 QLabel
* label
= new QLabel(this);
1009 QSlider
* slider
= new QSlider(this);
1010 QCheckBox
* cb
= new QCheckBox(this);
1011 slider
->setProperty("index", i
);
1012 slider
->setOrientation(Qt::Vertical
);
1013 slider
->setMinimum(0);
1014 slider
->setInvertedAppearance(true);
1015 slider
->setInvertedControls(true);
1016 slider
->setTickPosition(QSlider::TicksBothSides
);
1017 slider
->setMinimumSize(QSize(30, 50));
1018 slider
->setMaximumSize(QSize(50, 50));
1019 slider
->setSingleStep(1);
1020 slider
->setPageStep(1);
1021 slider
->setTickInterval(1);
1022 label
->setText(src
.toString(&model
, &generalSettings
));
1023 slider
->setMaximum(switchInfo
.config
== Board::SWITCH_3POS
? 2 : 1);
1024 cb
->setProperty("index", i
);
1025 ui
->switchesStartupLayout
->addWidget(label
, 0, i
+1);
1026 ui
->switchesStartupLayout
->setAlignment(label
, Qt::AlignCenter
);
1027 ui
->switchesStartupLayout
->addWidget(slider
, 1, i
+1);
1028 ui
->switchesStartupLayout
->setAlignment(slider
, Qt::AlignCenter
);
1029 ui
->switchesStartupLayout
->addWidget(cb
, 2, i
+1);
1030 ui
->switchesStartupLayout
->setAlignment(cb
, Qt::AlignCenter
);
1031 connect(slider
, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
1032 connect(cb
, SIGNAL(toggled(bool)), this, SLOT(startupSwitchToggled(bool)));
1033 startupSwitchesSliders
<< slider
;
1034 startupSwitchesCheckboxes
<< cb
;
1035 QWidget::setTabOrder(prevFocus
, slider
);
1036 QWidget::setTabOrder(slider
, cb
);
1041 prevFocus
= ui
->potWarningMode
;
1042 if (IS_HORUS_OR_TARANIS(board
)) {
1043 for (int i
=0; i
<getBoardCapability(board
, Board::Pots
)+getBoardCapability(board
, Board::Sliders
); i
++) {
1044 RawSource
src(SOURCE_TYPE_STICK
, CPN_MAX_STICKS
+ i
);
1045 QCheckBox
* cb
= new QCheckBox(this);
1046 cb
->setProperty("index", i
);
1047 cb
->setText(src
.toString(&model
, &generalSettings
));
1048 ui
->potWarningLayout
->addWidget(cb
, 0, i
+1);
1049 connect(cb
, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool)));
1050 potWarningCheckboxes
<< cb
;
1051 if (src
.isPot(&genAryIdx
) && !generalSettings
.isPotAvailable(genAryIdx
)) {
1054 else if (src
.isSlider(&genAryIdx
) && !generalSettings
.isSliderAvailable(genAryIdx
)) {
1057 QWidget::setTabOrder(prevFocus
, cb
);
1062 ui
->label_potWarning
->hide();
1063 ui
->potWarningMode
->hide();
1066 if (IS_ARM(board
)) {
1067 ui
->trimsDisplay
->setField(model
.trimsDisplay
, this);
1070 ui
->labelTrimsDisplay
->hide();
1071 ui
->trimsDisplay
->hide();
1074 for (int i
=0; i
<firmware
->getCapability(NumModules
); i
++) {
1075 modules
[i
] = new ModulePanel(this, model
, model
.moduleData
[i
], generalSettings
, firmware
, i
);
1076 ui
->modulesLayout
->addWidget(modules
[i
]);
1077 connect(modules
[i
], &ModulePanel::modified
, this, &SetupPanel::modified
);
1078 connect(this, &SetupPanel::extendedLimitsToggled
, modules
[i
], &ModulePanel::onExtendedLimitsToggled
);
1081 if (firmware
->getCapability(ModelTrainerEnable
)) {
1082 modules
[CPN_MAX_MODULES
] = new ModulePanel(this, model
, model
.moduleData
[CPN_MAX_MODULES
], generalSettings
, firmware
, -1);
1083 ui
->modulesLayout
->addWidget(modules
[CPN_MAX_MODULES
]);
1084 connect(modules
[CPN_MAX_MODULES
], &ModulePanel::modified
, this, &SetupPanel::modified
);
1087 disableMouseScrolling();
1092 SetupPanel::~SetupPanel()
1097 void SetupPanel::on_extendedLimits_toggled(bool checked
)
1099 model
->extendedLimits
= checked
;
1100 emit
extendedLimitsToggled();
1104 void SetupPanel::on_throttleWarning_toggled(bool checked
)
1106 model
->disableThrottleWarning
= !checked
;
1110 void SetupPanel::on_throttleReverse_toggled(bool checked
)
1112 model
->throttleReversed
= checked
;
1116 void SetupPanel::on_extendedTrims_toggled(bool checked
)
1118 model
->extendedTrims
= checked
;
1122 void SetupPanel::on_trimIncrement_currentIndexChanged(int index
)
1124 model
->trimInc
= index
-2;
1128 void SetupPanel::on_throttleSource_currentIndexChanged(int index
)
1131 model
->thrTraceSrc
= index
;
1136 void SetupPanel::on_name_editingFinished()
1138 if (QString(model
->name
) != ui
->name
->text()) {
1139 int length
= ui
->name
->maxLength();
1140 strncpy(model
->name
, ui
->name
->text().toLatin1(), length
);
1145 void SetupPanel::on_image_currentIndexChanged(int index
)
1148 Board::Type board
= firmware
->getBoard();
1149 strncpy(model
->bitmap
, ui
->image
->currentText().toLatin1(), 10);
1150 QString path
= g
.profile
[g
.id()].sdPath();
1151 path
.append("/IMAGES/");
1154 QString fileName
=path
;
1155 fileName
.append(model
->bitmap
);
1156 if (!IS_HORUS(board
))
1157 fileName
.append(".bmp");
1158 QImage
image(fileName
);
1159 if (image
.isNull() && !IS_HORUS(board
)) {
1161 fileName
.append(model
->bitmap
);
1162 fileName
.append(".BMP");
1163 image
.load(fileName
);
1165 if (!image
.isNull()) {
1166 if (IS_HORUS(board
)) {
1167 ui
->imagePreview
->setFixedSize(QSize(192, 114));
1168 ui
->imagePreview
->setPixmap(QPixmap::fromImage(image
.scaled(192, 114)));
1171 ui
->imagePreview
->setFixedSize(QSize(64, 32));
1172 ui
->imagePreview
->setPixmap(QPixmap::fromImage(image
.scaled(64, 32)));
1176 ui
->imagePreview
->clear();
1180 ui
->imagePreview
->clear();
1186 void SetupPanel::populateThrottleSourceCB()
1188 Board::Type board
= firmware
->getBoard();
1190 ui
->throttleSource
->clear();
1191 ui
->throttleSource
->addItem(tr("THR"));
1192 for (int i
=0; i
<getBoardCapability(board
, Board::Pots
)+getBoardCapability(board
, Board::Sliders
); i
++) {
1193 ui
->throttleSource
->addItem(firmware
->getAnalogInputName(4+i
), i
);
1195 for (int i
=0; i
<firmware
->getCapability(Outputs
); i
++) {
1196 ui
->throttleSource
->addItem(RawSource(SOURCE_TYPE_CH
, i
).toString(model
, &generalSettings
));
1198 ui
->throttleSource
->setCurrentIndex(model
->thrTraceSrc
);
1202 void SetupPanel::update()
1204 ui
->name
->setText(model
->name
);
1205 ui
->throttleReverse
->setChecked(model
->throttleReversed
);
1206 populateThrottleSourceCB();
1207 ui
->throttleWarning
->setChecked(!model
->disableThrottleWarning
);
1208 ui
->trimIncrement
->setCurrentIndex(model
->trimInc
+2);
1209 ui
->throttleTrim
->setChecked(model
->thrTrim
);
1210 ui
->extendedLimits
->setChecked(model
->extendedLimits
);
1211 ui
->extendedTrims
->setChecked(model
->extendedTrims
);
1212 ui
->displayText
->setChecked(model
->displayChecklist
);
1213 ui
->gfEnabled
->setChecked(!model
->noGlobalFunctions
);
1216 updateStartupSwitches();
1218 if (IS_HORUS_OR_TARANIS(firmware
->getBoard())) {
1219 updatePotWarnings();
1222 for (int i
=0; i
<firmware
->getCapability(Timers
); i
++) {
1223 timers
[i
]->update();
1226 for (int i
=0; i
<CPN_MAX_MODULES
+1; i
++) {
1228 modules
[i
]->update();
1233 void SetupPanel::updateBeepCenter()
1235 for (int i
=0; i
<centerBeepCheckboxes
.size(); i
++) {
1236 centerBeepCheckboxes
[i
]->setChecked(model
->beepANACenter
& (0x01 << i
));
1240 void SetupPanel::updateStartupSwitches()
1244 uint64_t switchStates
= model
->switchWarningStates
;
1247 for (int i
=0; i
<startupSwitchesSliders
.size(); i
++) {
1248 QSlider
* slider
= startupSwitchesSliders
[i
];
1249 QCheckBox
* cb
= startupSwitchesCheckboxes
[i
];
1250 int index
= slider
->property("index").toInt();
1251 bool enabled
= !(model
->switchWarningEnable
& (1 << index
));
1252 if (IS_HORUS_OR_TARANIS(firmware
->getBoard())) {
1253 value
= (switchStates
>> (2*index
)) & 0x03;
1254 if (generalSettings
.switchConfig
[index
] != Board::SWITCH_3POS
&& value
== 2) {
1259 value
= (i
==0 ? switchStates
& 0x3 : switchStates
& 0x1);
1260 switchStates
>>= (i
==0 ? 2 : 1);
1262 slider
->setValue(value
);
1263 slider
->setEnabled(enabled
);
1264 cb
->setChecked(enabled
);
1270 void SetupPanel::startupSwitchEdited(int value
)
1275 int index
= sender()->property("index").toInt();
1277 if (IS_HORUS_OR_TARANIS(firmware
->getBoard())) {
1279 mask
= 0x03ull
<< shift
;
1287 mask
= 0x01ull
<< shift
;
1291 model
->switchWarningStates
&= ~mask
;
1293 if (IS_HORUS_OR_TARANIS(firmware
->getBoard()) && generalSettings
.switchConfig
[index
] != Board::SWITCH_3POS
) {
1300 model
->switchWarningStates
|= ((uint64_t)value
<< shift
);
1303 updateStartupSwitches();
1308 void SetupPanel::startupSwitchToggled(bool checked
)
1311 int index
= sender()->property("index").toInt();
1314 model
->switchWarningEnable
&= ~(1 << index
);
1316 model
->switchWarningEnable
|= (1 << index
);
1318 updateStartupSwitches();
1323 void SetupPanel::updatePotWarnings()
1326 ui
->potWarningMode
->setCurrentIndex(model
->potsWarningMode
);
1327 for (int i
=0; i
<potWarningCheckboxes
.size(); i
++) {
1328 QCheckBox
*checkbox
= potWarningCheckboxes
[i
];
1329 int index
= checkbox
->property("index").toInt();
1330 checkbox
->setChecked(!model
->potsWarningEnabled
[index
]);
1331 checkbox
->setDisabled(model
->potsWarningMode
== 0);
1336 void SetupPanel::potWarningToggled(bool checked
)
1339 int index
= sender()->property("index").toInt();
1340 model
->potsWarningEnabled
[index
] = !checked
;
1341 updatePotWarnings();
1346 void SetupPanel::on_potWarningMode_currentIndexChanged(int index
)
1349 model
->potsWarningMode
= index
;
1350 updatePotWarnings();
1355 void SetupPanel::on_displayText_toggled(bool checked
)
1357 model
->displayChecklist
= checked
;
1361 void SetupPanel::on_gfEnabled_toggled(bool checked
)
1363 model
->noGlobalFunctions
= !checked
;
1367 void SetupPanel::on_throttleTrim_toggled(bool checked
)
1369 model
->thrTrim
= checked
;
1373 void SetupPanel::onBeepCenterToggled(bool checked
)
1376 int index
= sender()->property("index").toInt();
1377 unsigned int mask
= (0x01 << index
);
1379 model
->beepANACenter
|= mask
;
1381 model
->beepANACenter
&= ~mask
;
1386 void SetupPanel::on_editText_clicked()
1388 ChecklistDialog
*g
= new ChecklistDialog(this, ui
->name
->text());