Skip to content

Commit 896b127

Browse files
Hold-to-approve: Rework and add fine tune timings
- Remove `HAVE_FAST_HOLD_TO_APPROVE` flag - Customize timing for hold-to-approve on Apex
1 parent bc17d80 commit 896b127

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

Makefile.defines

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ DEFINES += HAVE_SE_EINK_DISPLAY
159159
DEFINES += NBGL_PAGE
160160
DEFINES += NBGL_USE_CASE
161161
DEFINES += SCREEN_SIZE_WALLET
162-
DEFINES += HAVE_FAST_HOLD_TO_APPROVE
163162
endif # TARGET_FLEX
164163

165164
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_APEX_P TARGET_APEX_M))

lib_nbgl/src/nbgl_layout.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,25 +192,28 @@ static uint8_t nbTouchableControls = 0;
192192
**********************/
193193
// extern const char *get_ux_loc_string(UX_LOC_STRINGS_INDEX index);
194194

195-
#ifdef HAVE_FAST_HOLD_TO_APPROVE
196-
// Unit step in % of touchable progress bar
195+
// Hold-to-approve parameters
196+
#if defined(TARGET_FLEX)
197+
// Percent of a single "hold-to-approve" bar
197198
#define HOLD_TO_APPROVE_STEP_PERCENT (7)
198-
// Duration in ms the user must hold the progress bar
199-
// to make it progress HOLD_TO_APPROVE_STEP_PERCENT %.
200-
// This duration must be higher than the screen refresh duration.
199+
// Duration between two bars
201200
#define HOLD_TO_APPROVE_STEP_DURATION_MS (100)
202-
#else
201+
// Number of bars displayed when the user start the "hold-to-approve" mechanism
202+
#define HOLD_TO_APPROVE_FIRST_STEP (0)
203+
#elif defined(TARGET_STAX)
203204
#define HOLD_TO_APPROVE_STEP_PERCENT (25)
204205
#define HOLD_TO_APPROVE_STEP_DURATION_MS (400)
205-
#endif // HAVE_FAST_HOLD_TO_APPROVE
206+
#define HOLD_TO_APPROVE_FIRST_STEP (1)
207+
#elif defined(TARGET_APEX)
208+
#define HOLD_TO_APPROVE_STEP_PERCENT (20)
209+
#define HOLD_TO_APPROVE_STEP_DURATION_MS (300)
210+
#define HOLD_TO_APPROVE_FIRST_STEP (1)
211+
#endif // TARGETS
206212

207213
static inline uint8_t get_hold_to_approve_percent(uint32_t touch_duration)
208214
{
209-
#ifdef HAVE_FAST_HOLD_TO_APPROVE
210-
uint8_t current_step_nb = (touch_duration / HOLD_TO_APPROVE_STEP_DURATION_MS);
211-
#else
212-
uint8_t current_step_nb = (touch_duration / HOLD_TO_APPROVE_STEP_DURATION_MS) + 1;
213-
#endif
215+
uint8_t current_step_nb
216+
= (touch_duration / HOLD_TO_APPROVE_STEP_DURATION_MS) + HOLD_TO_APPROVE_FIRST_STEP;
214217
return (current_step_nb * HOLD_TO_APPROVE_STEP_PERCENT);
215218
}
216219

tests/screenshots/src/main/json_scenario.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,15 @@ static int add_targets(ScenarioPage_t *page, struct json_object *value)
162162

163163
target->wait = 0;
164164
target->wait_initial = 0;
165-
#ifdef HAVE_FAST_HOLD_TO_APPROVE
165+
166+
#if defined(TARGET_FLEX)
166167
target->long_press_wait = 1500;
167-
#else
168+
#elif defined(TARGET_STAX)
168169
target->long_press_wait = 1200;
169-
#endif
170+
#elif defined(TARGET_APEX)
171+
target->long_press_wait = 1500;
172+
#endif // TARGETS
173+
170174
#ifdef HAVE_SE_TOUCH
171175
target->x = 0;
172176
target->y = 0;

0 commit comments

Comments
 (0)