Skip to content

Commit c5ad31d

Browse files
orodericojgriffiths
authored andcommitted
Fix TTGO PIN entry navigation
1 parent b48520f commit c5ad31d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

main/ui/pin.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ static const char PIN_CHARS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '
1111
static const uint32_t NUM_PIN_CHARS = sizeof(PIN_CHARS) / sizeof(PIN_CHARS[0]);
1212
static const uint32_t NUM_PIN_VALUES = NUM_PIN_CHARS - 1; // ie. not including backspace
1313

14+
static inline bool pin_entry_invert_navigation(void)
15+
{
16+
#if defined(CONFIG_BOARD_TYPE_TTGO_TDISPLAY) || defined(CONFIG_BOARD_TYPE_TTGO_TDISPLAYS3)
17+
// TTGO boards need to locally invert navigation so PIN entry matches the rest of the UI.
18+
return true;
19+
#else
20+
return false;
21+
#endif
22+
}
23+
1424
static inline char get_pin_value(size_t index)
1525
{
1626
JADE_ASSERT(index < NUM_PIN_CHARS);
@@ -194,6 +204,14 @@ bool run_pin_entry_loop(pin_insert_t* pin_insert)
194204
while (true) {
195205
// wait for a GUI event
196206
gui_activity_wait_event(pin_insert->activity, GUI_EVENT, ESP_EVENT_ANY_ID, NULL, &ev_id, NULL, 0);
207+
if (pin_entry_invert_navigation()) {
208+
// Swap left/right wheel events
209+
if (ev_id == GUI_WHEEL_LEFT_EVENT) {
210+
ev_id = GUI_WHEEL_RIGHT_EVENT;
211+
} else if (ev_id == GUI_WHEEL_RIGHT_EVENT) {
212+
ev_id = GUI_WHEEL_LEFT_EVENT;
213+
}
214+
}
197215

198216
switch (ev_id) {
199217
case GUI_WHEEL_LEFT_EVENT:

0 commit comments

Comments
 (0)