Skip to content

Commit

Permalink
Companion countdown start
Browse files Browse the repository at this point in the history
  • Loading branch information
kilrah committed Jan 26, 2021
1 parent 8b68192 commit f10eaa4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
2 changes: 2 additions & 0 deletions companion/src/firmwares/modeldata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void *>(this), 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); }
void convert(RadioDataConversionState & cstate);
Expand Down
3 changes: 2 additions & 1 deletion companion/src/firmwares/opentx/opentxeeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion companion/src/modeledit/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -121,6 +128,7 @@ void TimerPanel::update()
ui->countdownBeep->updateValue();
ui->minuteBeep->setChecked(timer.minuteBeep);
ui->persistent->updateValue();
ui->countdownStart->updateValue();
lock = false;
}

Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions companion/src/modeledit/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 13 additions & 1 deletion companion/src/modeledit/setup_timer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down Expand Up @@ -59,6 +68,9 @@
<item>
<widget class="AutoComboBox" name="countdownBeep"/>
</item>
<item>
<widget class="AutoComboBox" name="countdownStart"/>
</item>
<item>
<widget class="QCheckBox" name="minuteBeep">
<property name="text">
Expand Down

0 comments on commit f10eaa4

Please sign in to comment.