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.

  • Thanks! I will take a look and see if I can reproduce your problem.
    Where are you defining the BUTTON_POWER, BUTTON_A etc?
    I can see that you included the system.h, that is not from the SDK, maybe you could upload that file as well? So that when I test, it is as similar to your project as possible.
    Best regards.

  • Thanks Joakim!

    I defined the button and LED in a customized board definition header file (just modified from pca10028.h)

    #define BUTTON_POWER	 0//0
    

    #define BUTTON_A 10//

    The system.h is not needed and I have removed it from the project.

    As described above I am using SDK12.3 on a nrf51822 (QFACA10) and developing base on ble_app_template from peripheral examples; so I am using a softdevice S130.

    I am using APP_BUTTON for BUTTON_POWER, BUTTON_A for detection. When press detected each button will start it's OWN 5000ms single shot timer (two seperate timer); when the timer expired and the button is still being press it will be recognised as a long press.

    Problem I found is I found that when the system has been run for a while after started, a short press will immediately recognised as a long press.

    Some info for your reference:

    1. The softdevice is not yet paired to any device yet (i just started the development so I am now still working on the application part). I just put the device in a idle state (Not deep sleep ) after advertisement expired.

    2. The button must have been pressed ONCE first below this problem happens. (i.e. the 5000ms must have been started once first)

    3. In latest testing I tried to add a 1000ms repeating timer and start it immediately once the program start. And the issue is gone.

    Do you have any idea?

    Many thanks!

  • Hi mm81.
    Sorry for the delay. I couldn't seem to reproduce the problem you are having. Maybe I'm doing something different from you.
    You can take a look at Jørn's answer in this thread, that might be useful, as he is explaining how to acheive what you want.

Related