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:
co-authored by
Peter Feerick
elecpower
parent
415b566a79
commit
be7a6a51ab
@@ -43,6 +43,21 @@ static std::function<void(uint32_t)> timerValueUpdater(uint8_t timer)
|
||||
};
|
||||
}
|
||||
|
||||
static void timer_start_changed(lv_event_t* e)
|
||||
{
|
||||
lv_obj_t* target = lv_event_get_target(e);
|
||||
auto obj = (lv_obj_t*)lv_event_get_user_data(e);
|
||||
auto val = (TimeEdit*)lv_obj_get_user_data(target);
|
||||
|
||||
if (!obj || !val) return;
|
||||
|
||||
if (val->getValue() > 0) {
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
TimerWindow::TimerWindow(uint8_t timer) : Page(ICON_STATS_TIMERS)
|
||||
{
|
||||
std::string title = std::string(STR_TIMER) + std::to_string(timer + 1);
|
||||
@@ -74,8 +89,21 @@ TimerWindow::TimerWindow(uint8_t timer) : Page(ICON_STATS_TIMERS)
|
||||
// Timer start value
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_START, 0, COLOR_THEME_PRIMARY1);
|
||||
new TimeEdit(line, rect_t{}, 0, TIMER_MAX, GET_DEFAULT(p_timer->start),
|
||||
timerValueUpdater(timer));
|
||||
auto timerValue =
|
||||
new TimeEdit(line, rect_t{}, 0, TIMER_MAX, GET_DEFAULT(p_timer->start),
|
||||
timerValueUpdater(timer));
|
||||
|
||||
// Timer direction
|
||||
auto timerDirLine = form->newLine(&grid);
|
||||
new StaticText(timerDirLine, rect_t{}, STR_LIMITS_HEADERS_DIRECTION, 0,
|
||||
COLOR_THEME_PRIMARY1);
|
||||
new Choice(timerDirLine, rect_t{}, STR_TIMER_DIR, 0, 1,
|
||||
GET_SET_DEFAULT(p_timer->showElapsed));
|
||||
|
||||
if (timerValue->getValue() == 0) {
|
||||
auto obj = timerDirLine->getLvObj();
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
// Timer minute beep
|
||||
line = form->newLine(&grid);
|
||||
@@ -88,7 +116,7 @@ TimerWindow::TimerWindow(uint8_t timer) : Page(ICON_STATS_TIMERS)
|
||||
|
||||
auto box = new FormGroup(line, rect_t{});
|
||||
box->setFlexLayout(LV_FLEX_FLOW_ROW);
|
||||
|
||||
|
||||
new Choice(box, rect_t{}, STR_VBEEPCOUNTDOWN, COUNTDOWN_SILENT,
|
||||
COUNTDOWN_COUNT - 1, GET_SET_DEFAULT(p_timer->countdownBeep));
|
||||
new Choice(box, rect_t{}, STR_COUNTDOWNVALUES, 0, 3,
|
||||
@@ -100,4 +128,7 @@ TimerWindow::TimerWindow(uint8_t timer) : Page(ICON_STATS_TIMERS)
|
||||
|
||||
new Choice(line, rect_t{}, STR_VPERSISTENT, 0, 2,
|
||||
GET_SET_DEFAULT(p_timer->persistent));
|
||||
|
||||
lv_obj_add_event_cb(timerValue->getLvObj(), timer_start_changed,
|
||||
LV_EVENT_VALUE_CHANGED, timerDirLine->getLvObj());
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ STATIC_LZ4_BITMAP(LBM_TIMER_BACKGROUND);
|
||||
class TimerWidget : public Widget
|
||||
{
|
||||
public:
|
||||
TimerWidget(const WidgetFactory* factory, Window* parent,
|
||||
const rect_t& rect, Widget::PersistentData* persistentData) :
|
||||
TimerWidget(const WidgetFactory* factory, Window* parent, const rect_t& rect,
|
||||
Widget::PersistentData* persistentData) :
|
||||
Widget(factory, parent, rect, persistentData)
|
||||
{
|
||||
}
|
||||
@@ -81,8 +81,11 @@ class TimerWidget : public Widget
|
||||
dc->drawBitmapPattern(3, 4, LBM_TIMER, colorFore);
|
||||
}
|
||||
// value
|
||||
splitTimer(sDigitGroup0, sDigitGroup1, sUnit0, sUnit1,
|
||||
abs(timerState.val), false);
|
||||
int val = timerState.val;
|
||||
if (timerData.start && timerData.showElapsed &&
|
||||
timerData.start != timerState.val)
|
||||
val = (int)timerData.start - (int)timerState.val;
|
||||
splitTimer(sDigitGroup0, sDigitGroup1, sUnit0, sUnit1, abs(val), false);
|
||||
|
||||
dc->drawSizedText(76, 31, sDigitGroup0, ZLEN(sDigitGroup0),
|
||||
FONT(XL) | colorFore);
|
||||
@@ -115,12 +118,16 @@ class TimerWidget : public Widget
|
||||
FONT(XS) | COLOR_THEME_PRIMARY2);
|
||||
}
|
||||
// value
|
||||
int val = timerState.val;
|
||||
if (timerData.start && timerData.showElapsed &&
|
||||
timerData.start != timerState.val)
|
||||
val = (int)timerData.start - (int)timerState.val;
|
||||
if (width() > 100 && height() > 40) {
|
||||
if (abs(timerState.val) >= 3600) {
|
||||
drawTimer(dc, 3, 20, abs(timerState.val),
|
||||
if (abs(val) >= 3600) {
|
||||
drawTimer(dc, 3, 20, abs(val),
|
||||
COLOR_THEME_PRIMARY2 | LEFT | TIMEHOUR);
|
||||
} else {
|
||||
drawTimer(dc, 3, 18, abs(timerState.val),
|
||||
drawTimer(dc, 3, 18, abs(val),
|
||||
COLOR_THEME_PRIMARY2 | LEFT | FONT(STD));
|
||||
}
|
||||
}
|
||||
@@ -130,8 +137,12 @@ class TimerWidget : public Widget
|
||||
drawTimer(dc, 3, 20, abs(timerState.val),
|
||||
COLOR_THEME_PRIMARY2 | LEFT | FONT(XS) | TIMEHOUR);
|
||||
} else {
|
||||
drawTimer(dc, 3, 18, abs(timerState.val),
|
||||
COLOR_THEME_PRIMARY2 | LEFT);
|
||||
// value
|
||||
int val = timerState.val;
|
||||
if (timerData.start && timerData.showElapsed &&
|
||||
timerData.start != timerState.val)
|
||||
val = (int)timerData.start - (int)timerState.val;
|
||||
drawTimer(dc, 3, 18, abs(val), COLOR_THEME_PRIMARY2 | LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user