Enter two-digit number (show first digit, wait for second one before accepting)

Description

What MCU/Processor/Board and compiler are you using?

Odroid N2 SBC, Ubuntu 18.04, gcc 8.4.0

What do you want to achieve?

I need the user to enter a 2-digit number (say 00-99). So when the user enter the first digit, the widget should show it and wait for the second digit (within a reasonable time) before accepting the number.

What have you tried so far?

I have built a button matrix and started writing an handler with digit entry timeouts etc., but was wondering if there is a property (or code snippet) of some kind I may exploit, instead of writing all the low-level logic by myself.
Maybe there’s a clever way to do this, I think it’s a relatively common task…?

Thanks!

I don’t think there’s any built-in functionality in LittlevGL for handing this type of thing, but I’d suggest that you:

  • Make a LittlevGL task with the period set to whatever timeout you want. Use lv_task_once to make sure it doesn’t get called over and over.
  • Every time the user enters a character, call lv_task_reset to reset the timeout.
  • Once the task function gets called, you know that the timeout has expired.

Thank you, looks like a good excuse to study lv tasks. :slight_smile: