feat: Allow the timer count direction to be selected (#2038)

* timer direction: ellapsed or left

* Add AUDIO announcement support

* Storage for showElapsed

* Translations

* Fix storage

* BW implementation

* Different BW implementation

* Companion support

* Color LCD implementation and rebase to lvgl

* Fix problems found by raphaelcoeffic

* chore: Regenerate the YAML files properly

* fix: Remove unused `TR_SHOW` remnant

* chore: Formatting and cleanup

* fix: Timer dir choice was shown in wrong place
Wrong newline used in ce23b50

* Fix cpn ui triggers, remove unnecessary code and some formatting

* fix(colorlcd): Hide timer dir opt if zero value

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
eshifri
2022-08-03 09:22:42 +10:00
committed by GitHub
co-authored by Peter Feerick elecpower
parent 415b566a79
commit be7a6a51ab
50 changed files with 286 additions and 85 deletions
@@ -283,6 +283,7 @@ Node convert<TimerData>::encode(const TimerData& rhs)
node["persistent"] = rhs.persistent;
node["countdownStart"] = rhs.countdownStart;
node["value"] = rhs.pvalue;
node["showElapsed"] = rhs.showElapsed;
return node;
}
@@ -297,6 +298,7 @@ bool convert<TimerData>::decode(const Node& node, TimerData& rhs)
node["persistent"] >> rhs.persistent;
node["countdownStart"] >> rhs.countdownStart;
node["value"] >> rhs.pvalue;
node["showElapsed"] >> rhs.showElapsed;
return true;
}
+23
View File
@@ -180,6 +180,16 @@ QString TimerData::modeToString(const int value)
}
}
QString TimerData::showElapsedToString(const unsigned int value)
{
return (value) ? tr("Show Elapsed") : tr("Show Remaining");
}
QString TimerData::showElapsedToString() const
{
return showElapsedToString(showElapsed);
}
// static
AbstractStaticItemModel * TimerData::countdownBeepItemModel()
{
@@ -235,3 +245,16 @@ AbstractStaticItemModel * TimerData::modeItemModel()
mdl->loadItemList();
return mdl;
}
AbstractStaticItemModel * TimerData::showElapsedItemModel()
{
AbstractStaticItemModel *mdl = new AbstractStaticItemModel();
mdl->setName(AIM_TIMER_SHOWELAPSED);
for (unsigned int i = 0; i < TIMER_SHOW_COUNT; i++) {
mdl->appendToItemList(showElapsedToString(i), i);
}
mdl->loadItemList();
return mdl;
}
+12 -1
View File
@@ -32,6 +32,7 @@ constexpr char AIM_TIMER_COUNTDOWNBEEP[] {"timerdata.countdownBeep"};
constexpr char AIM_TIMER_COUNTDOWNSTART[] {"timerdata.countdownStart"};
constexpr char AIM_TIMER_PERSISTENT[] {"timerdata.persistent"};
constexpr char AIM_TIMER_MODE[] {"timerdata.mode"};
constexpr char AIM_TIMER_SHOWELAPSED[] {"timerdata.showElapsed"};
constexpr int TIMER_NAME_LEN {8};
@@ -74,6 +75,12 @@ class TimerData {
TIMERMODE_MAX = TIMERMODE_COUNT - 1
};
enum TimerShowDirection {
TIMER_SHOW_REMAINING,
TIMER_SHOW_ELAPSED,
TIMER_SHOW_COUNT
};
TimerData() { clear(); }
RawSwitch swtch;
@@ -85,6 +92,7 @@ class TimerData {
unsigned int persistent;
int countdownStart;
int pvalue;
unsigned int showElapsed;
void convert(RadioDataConversionState & cstate);
void clear();
@@ -97,6 +105,8 @@ class TimerData {
QString pvalueToString() const;
QString valToString() const;
QString modeToString() const;
QString showElapsedToString() const;
void countdownBeepChanged();
void modeChanged();
@@ -106,9 +116,10 @@ class TimerData {
static QString pvalueToString(const int value);
static QString valToString(const int value);
static QString modeToString(const int value);
static QString showElapsedToString(const unsigned int value);
static AbstractStaticItemModel * countdownBeepItemModel();
static AbstractStaticItemModel * countdownStartItemModel();
static AbstractStaticItemModel * persistentItemModel();
static AbstractStaticItemModel * modeItemModel();
static AbstractStaticItemModel * showElapsedItemModel();
};
+17 -1
View File
@@ -59,6 +59,9 @@ TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, G
ui->value->setField(timer.val, this);
ui->value->setMaximumTime(firmware->getMaxTimerStart());
connect(ui->value, &AutoTimeEdit::currentDataChanged, [=](const int val) {
update();
});
ui->mode->setModel(panelItemModels->getItemModel(AIM_TIMER_MODE));
ui->mode->setField(timer.mode, this);
@@ -85,6 +88,10 @@ TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, G
ui->countdownStart->setModel(panelItemModels->getItemModel(AIM_TIMER_COUNTDOWNSTART));
ui->countdownStart->setField(timer.countdownStart, this);
ui->showElapsed->setModel(panelItemModels->getItemModel(AIM_TIMER_SHOWELAPSED));
ui->showElapsed->setField(timer.showElapsed, this);
disableMouseScrolling();
QWidget::setTabOrder(prevFocus, ui->name);
QWidget::setTabOrder(ui->name, ui->value);
@@ -93,6 +100,7 @@ TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, G
QWidget::setTabOrder(ui->countdownBeep, ui->countdownStart);
QWidget::setTabOrder(ui->countdownStart, ui->minuteBeep);
QWidget::setTabOrder(ui->minuteBeep, ui->persistent);
QWidget::setTabOrder(ui->persistent, ui->showElapsed);
update();
lock = false;
@@ -114,6 +122,7 @@ void TimerPanel::update()
ui->countdownBeep->updateValue();
ui->minuteBeep->updateValue();
ui->countdownStart->updateValue();
ui->showElapsed->updateValue();
if (timer.mode != TimerData::TIMERMODE_OFF)
ui->swtch->setEnabled(true);
@@ -134,6 +143,13 @@ void TimerPanel::update()
ui->persistentValue->setText(timer.pvalueToString());
}
if (timer.val) {
ui->showElapsed->setEnabled(true);
}
else {
ui->showElapsed->setEnabled(false);
}
lock = false;
}
@@ -1276,7 +1292,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
panelItemModels->registerItemModel(TimerData::persistentItemModel());
panelItemModels->registerItemModel(TimerData::modeItemModel());
panelFilteredModels->registerItemModel(new FilteredItemModel(ModelData::trainerModeItemModel(generalSettings, firmware)), FIM_TRAINERMODE);
panelItemModels->registerItemModel(TimerData::showElapsedItemModel());
Board::Type board = firmware->getBoard();
memset(modules, 0, sizeof(modules));
+1 -1
View File
@@ -223,7 +223,7 @@ class SetupPanel : public ModelPanel
ModulePanel * modules[CPN_MAX_MODULES + 1];
TimerPanel * timers[CPN_MAX_TIMERS];
FunctionSwitchesPanel * funcswitches;
void updateStartupSwitches();
void updatePotWarnings();
void updateBeepCenter();
+3
View File
@@ -91,6 +91,9 @@
<item>
<widget class="AutoComboBox" name="persistent"/>
</item>
<item>
<widget class="AutoComboBox" name="showElapsed"/>
</item>
<item>
<widget class="QLabel" name="persistentValue">
<property name="text">
+1
View File
@@ -352,6 +352,7 @@ QString MultiModelPrinter::printTimers()
COMPARECELLWIDTH(model->timers[i].countdownStartToString(), 10);
COMPARECELLWIDTH(DataHelpers::boolToString(model->timers[i].minuteBeep, DataHelpers::BOOL_FMT_YESNO), 10);
COMPARECELLWIDTH(model->timers[i].persistentToString(false), 10);
COMPARECELLWIDTH(model->timers[i].showElapsedToString(), 12);
columns.appendRowEnd();
}
columns.appendTableEnd();