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

Button long press strange behaviour(SDK12.3)

main.cHi,

I have implemented button long press with APP_BUTTON library with APP timer (a 5 seconds timer). Normally the detection works fine.

But I found that if the system has been left running for a period of time, it will immediate trigger the long press handler when i press the button (instead of after 5 seconds).

The pin in question is P0 (update. tested on another button have similar effect)

Any idea on this??

Thanks.

Parents
  • Sorry don't know how to properly paste the code here with correct format...

    Timer init as below: err_code = app_timer_create(&button_power_5sec_timer_id, APP_TIMER_MODE_SINGLE_SHOT, button_power_5sec_handler);

    I start timer when detect a button press in button_handler():

    err_code = app_timer_start(button_power_5sec_timer_id, APP_TIMER_TICKS(5000,APP_TIMER_PRESCALER), NULL); //start timer, 5 second timeout

Reply
  • Sorry don't know how to properly paste the code here with correct format...

    Timer init as below: err_code = app_timer_create(&button_power_5sec_timer_id, APP_TIMER_MODE_SINGLE_SHOT, button_power_5sec_handler);

    I start timer when detect a button press in button_handler():

    err_code = app_timer_start(button_power_5sec_timer_id, APP_TIMER_TICKS(5000,APP_TIMER_PRESCALER), NULL); //start timer, 5 second timeout

Children
No Data
Related