This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

about button long press and short press detect

Hi, I want to detect long and short press in same button. Define "BUTTON_DETECTION_DELAY" can detect one delay. Let me know to detect more than two delays.

The same question closed as "the question is answered, right answer was accepted" by Petter Myhre at Sep 25 '14.But I can't find it, could you give me the web address? thank you!

my sdk use 7.3

Parents
  • As Roger said the BUTTON_DETECTION_DELAY is intended for debouncing delay which is used to ensure that the input level is stable before reading the value (do a search on google on "button debouncing" for more info about debouncing).

    If you intend to distinguish between short press and long press you should use app_timer. For example start a timer with a certain timeout when the button is pushed and stop it when the button is released. If the timer has timed out it is a short push, if it has timed out it is a long push.

  • Regarding this question:

    The only example that shows long press and short press is the bsp module in the latest SDK. For example see bsp_button_event_handler(..) in bsp.c in SDK12. This uses more or less the same technique as I described in my answer (app_timer_start/app_timer_stop).

Reply Children
No Data
Related