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

How to use app_timer_cnt_diff_compute

Hi,

i need to handle a button detection Time, i mean when i push the button for 2 seconds something should happen. How can i use the app_timer_cnt_diff_compute function for that?

Best regards Nils

Parents
  • There isn't currently any automatic way to do this, and the easiest method is currently to register a user directly in app_gpiote. This module gives an event both on a falling and rising edge, and is what app_button relies on internally.

    By doing this, you can start a 2 second timer on the falling edge, and stop it on the rising edge. If the button is held for more than 2 seconds, the timeout handler will run, in which you can do whatever action you need.

    The app_gpiote module can be used with something like the attached file.

    app_gpiote_usage.c

Reply
  • There isn't currently any automatic way to do this, and the easiest method is currently to register a user directly in app_gpiote. This module gives an event both on a falling and rising edge, and is what app_button relies on internally.

    By doing this, you can start a 2 second timer on the falling edge, and stop it on the rising edge. If the button is held for more than 2 seconds, the timeout handler will run, in which you can do whatever action you need.

    The app_gpiote module can be used with something like the attached file.

    app_gpiote_usage.c

Children
Related