From f10eaa48ee16434d2f9c34fdaaa0556512d069c5 Mon Sep 17 00:00:00 2001 From: Kilrah Date: Tue, 26 Jan 2021 12:17:06 +0100 Subject: [PATCH] Companion countdown start --- companion/src/firmwares/modeldata.h | 2 ++ .../src/firmwares/opentx/opentxeeprom.cpp | 3 ++- companion/src/modeledit/setup.cpp | 18 +++++++++++++++++- companion/src/modeledit/setup.h | 1 + companion/src/modeledit/setup_timer.ui | 14 +++++++++++++- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index 2b277568ffc..847997d9416 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -70,6 +70,8 @@ class TimerData { unsigned int countdownBeep; unsigned int val; unsigned int persistent; + int countdownStart; + unsigned int direction; int pvalue; void clear() { memset(reinterpret_cast(this), 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); } void convert(RadioDataConversionState & cstate); diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 111e3c39166..f9fc8c8f523 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2311,7 +2311,8 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsig internalField.Append(new UnsignedField<2>(this, modelData.timers[i].countdownBeep)); internalField.Append(new BoolField<1>(this, modelData.timers[i].minuteBeep)); internalField.Append(new UnsignedField<2>(this, modelData.timers[i].persistent)); - internalField.Append(new SpareBitsField<3>(this)); + internalField.Append(new SignedField<2>(this, modelData.timers[i].countdownStart)); + internalField.Append(new UnsignedField<1>(this, modelData.timers[i].direction)); if (HAS_LARGE_LCD(board)) internalField.Append(new ZCharField<8>(this, modelData.timers[i].name, "Timer name")); else diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 25cd576ec03..093c8acf757 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -73,13 +73,20 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge ui->persistent->addItem(tr("Not persistent"), 0); ui->persistent->addItem(tr("Persistent (flight)"), 1); ui->persistent->addItem(tr("Persistent (manual reset)"), 2); + + ui->countdownStart->setField(timer.countdownStart, this); + ui->countdownStart->addItem("5s", 1); + ui->countdownStart->addItem("10s", 0); + ui->countdownStart->addItem("20s", -1); + ui->countdownStart->addItem("30s", 2); disableMouseScrolling(); QWidget::setTabOrder(prevFocus, ui->name); QWidget::setTabOrder(ui->name, ui->value); QWidget::setTabOrder(ui->value, ui->mode); QWidget::setTabOrder(ui->mode, ui->countdownBeep); - QWidget::setTabOrder(ui->countdownBeep, ui->minuteBeep); + QWidget::setTabOrder(ui->countdownBeep, ui->countdownStart); + QWidget::setTabOrder(ui->countdownStart, ui->minuteBeep); QWidget::setTabOrder(ui->minuteBeep, ui->persistent); update(); @@ -121,6 +128,7 @@ void TimerPanel::update() ui->countdownBeep->updateValue(); ui->minuteBeep->setChecked(timer.minuteBeep); ui->persistent->updateValue(); + ui->countdownStart->updateValue(); lock = false; } @@ -129,6 +137,14 @@ QWidget * TimerPanel::getLastFocus() return ui->persistent; } +void TimerPanel::on_countdownBeep_currentIndexChanged(int index) +{ + if(index == TimerData::COUNTDOWN_SILENT) + ui->countdownStart->hide(); + else + ui->countdownStart->show(); +} + void TimerPanel::on_value_editingFinished() { if (!lock) { diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index c931f9dd7c2..7a5cddba96a 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -51,6 +51,7 @@ class TimerPanel : public ModelPanel void onModeChanged(int index); void on_value_editingFinished(); void on_minuteBeep_toggled(bool checked); + void on_countdownBeep_currentIndexChanged(int index); void on_name_editingFinished(); void onItemModelAboutToBeUpdated(); void onItemModelUpdateComplete(); diff --git a/companion/src/modeledit/setup_timer.ui b/companion/src/modeledit/setup_timer.ui index b6b920a102c..11f566b45d3 100644 --- a/companion/src/modeledit/setup_timer.ui +++ b/companion/src/modeledit/setup_timer.ui @@ -20,7 +20,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -59,6 +68,9 @@ + + +