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
  • Hello,

    err_code = app_timer_create(&button_power_5sec_timer_id, APP_TIMER_MODE_SINGLE_SHOT, button_5sec_timer_handler);

    • Is your button_power_5sec_timer_id variable a global / static variable? It has to be.

    • Did you configured the timer as a APP_TIMER_MODE_SINGLE_SHOT / APP_TIMER_MODE_REPEATED timer?

    • Can you show me the code related to the APP_BUTTON_RELEASE part and the timer handler part?

    I think your code when pressing the button doesn't seem to be a problem.

    I cannot tell big issues without those parts.

Reply
  • Hello,

    err_code = app_timer_create(&button_power_5sec_timer_id, APP_TIMER_MODE_SINGLE_SHOT, button_5sec_timer_handler);

    • Is your button_power_5sec_timer_id variable a global / static variable? It has to be.

    • Did you configured the timer as a APP_TIMER_MODE_SINGLE_SHOT / APP_TIMER_MODE_REPEATED timer?

    • Can you show me the code related to the APP_BUTTON_RELEASE part and the timer handler part?

    I think your code when pressing the button doesn't seem to be a problem.

    I cannot tell big issues without those parts.

Children
No Data
Related