feat: Timer Voice & Haptic option, show elapsed speak time value when countdown (#2711)

* fix "odd" elapsed time announcement

* announce elapsed seconds

* Add support for "Beeps and Haptic" and "Voice and Haptic" for timer countdown.
This commit is contained in:
eshifri
2023-01-23 20:00:12 +10:00
committed by GitHub
parent 0b8e4c6003
commit 8e8e78671a
45 changed files with 243 additions and 136 deletions
+17 -4
View File
@@ -341,16 +341,29 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event)
{
TimerData & timer = g_model.timers[timerIdx];
lcdDrawTextAlignedLeft(y, STR_BEEPCOUNTDOWN);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VBEEPCOUNTDOWN, timer.countdownBeep, (menuHorizontalPosition == 0 ? attr : 0));
int value = timer.countdownBeep;
if (timer.extraHaptic) value += (COUNTDOWN_VOICE + 1);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VBEEPCOUNTDOWN, value, (menuHorizontalPosition == 0 ? attr : 0));
if (timer.countdownBeep != COUNTDOWN_SILENT) {
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN + 6 * FW, y, TIMER_COUNTDOWN_START(timerIdx), (menuHorizontalPosition == 1 ? attr : 0) | LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
}
if (attr && s_editMode > 0) {
switch (menuHorizontalPosition) {
case 0:
CHECK_INCDEC_MODELVAR(event, timer.countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT - 1);
break;
case 0:
{
value = timer.countdownBeep;
if (timer.extraHaptic) value += (COUNTDOWN_NON_HAPTIC_LAST + 1);
CHECK_INCDEC_MODELVAR(event, value, COUNTDOWN_SILENT,
COUNTDOWN_COUNT - 1);
if (value > COUNTDOWN_VOICE + 1) {
timer.extraHaptic = 1;
timer.countdownBeep = value - (COUNTDOWN_NON_HAPTIC_LAST + 1);
} else {
timer.extraHaptic = 0;
timer.countdownBeep = value;
}
} break;
case 1:
timer.countdownStart = -checkIncDecModel(event, -timer.countdownStart, -1, +2);
break;
+18 -3
View File
@@ -262,7 +262,10 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event)
{
TimerData & timer = g_model.timers[timerIdx];
lcdDrawTextAlignedLeft(y, STR_BEEPCOUNTDOWN);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VBEEPCOUNTDOWN, timer.countdownBeep, (menuHorizontalPosition==0 ? attr : 0));
int value = timer.countdownBeep;
if (timer.extraHaptic) value += (COUNTDOWN_NON_HAPTIC_LAST + 1);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VBEEPCOUNTDOWN, value,
(menuHorizontalPosition == 0 ? attr : 0));
if (timer.countdownBeep != COUNTDOWN_SILENT) {
lcdDrawNumber(MODEL_SETUP_3RD_COLUMN, y, TIMER_COUNTDOWN_START(timerIdx), (menuHorizontalPosition == 1 ? attr : 0) | LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
@@ -270,8 +273,20 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event)
if (attr && s_editMode>0) {
switch (menuHorizontalPosition) {
case 0:
CHECK_INCDEC_MODELVAR(event, timer.countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT - 1);
break;
{
value = timer.countdownBeep;
if (timer.extraHaptic) value += (COUNTDOWN_NON_HAPTIC_LAST + 1);
TRACE("value=%d\ttimer.extraHaptic=%d", value, timer.extraHaptic);
CHECK_INCDEC_MODELVAR(event, value, COUNTDOWN_SILENT, COUNTDOWN_COUNT - 1);
if (value > COUNTDOWN_VOICE + 1) {
timer.extraHaptic = 1;
timer.countdownBeep = value - (COUNTDOWN_NON_HAPTIC_LAST + 1);
} else {
timer.extraHaptic = 0;
timer.countdownBeep = value;
}
}
break;
case 1:
timer.countdownStart = -checkIncDecModel(event, -timer.countdownStart, -1, +2);
break;
+22 -2
View File
@@ -117,8 +117,28 @@ TimerWindow::TimerWindow(uint8_t timer) : Page(ICON_STATS_TIMERS)
box->setFlexLayout(LV_FLEX_FLOW_ROW);
lv_obj_set_width(box->getLvObj(), LV_SIZE_CONTENT);
new Choice(box, rect_t{}, STR_VBEEPCOUNTDOWN, COUNTDOWN_SILENT,
COUNTDOWN_COUNT - 1, GET_SET_DEFAULT(p_timer->countdownBeep));
new Choice(
box, rect_t{}, STR_VBEEPCOUNTDOWN, COUNTDOWN_SILENT, COUNTDOWN_COUNT - 1,
[=]() -> int {
int value = p_timer->countdownBeep;
if (p_timer->extraHaptic) {
value += (COUNTDOWN_NON_HAPTIC_LAST + 1);
}
return (value);
},
[=](int value) {
if (value > COUNTDOWN_NON_HAPTIC_LAST + 1) {
p_timer->extraHaptic = 1;
p_timer->countdownBeep = value - (COUNTDOWN_NON_HAPTIC_LAST + 1);
} else {
p_timer->extraHaptic = 0;
p_timer->countdownBeep = value;
}
SET_DIRTY();
TRACE("value=%d\tcountdownBeep = %d\textraHaptic = %d", value,
p_timer->countdownBeep, p_timer->extraHaptic);
});
new Choice(box, rect_t{}, STR_COUNTDOWNVALUES, 0, 3,
GET_SET_WITH_OFFSET(p_timer->countdownStart, 2));