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

Button normal press and long press detect

Hi,

I need some clarification about how to differentiate the normal press and long press detect for a single button to assign awake and sleep mode.

I am using nRF52832 SDK15.3 in segger embedded studio .

Is there any predefined code for sleep and awake system?

Parents
  • Hi,

    Please see my answer in this thread for some suggestions on how you can differentiate between long and short button presses. What kind of sleep mode did you have in mind, system OFF or System ON mode? 

  • Hi Vidar,

    i didn't receive any link please resend it.

    when long press the button  system get into sleep mode or (system OFF)

    when the press the button with normal delay system get ON mode

    is it possible.

    any code reference is there?

  • Sorry, here's the link I was referring to: https://devzone.nordicsemi.com/f/nordic-q-a/43506/how-to-use-bsp_button_action_push-and-bsp_button_action_long_push-on-the-same-button-with-two-different-functions 

    You don't need to a button to enter System ON mode, just let the program return to your main loop. You can, however,  use a "long" button press to make the program enter System OFF.  

  • Hi, Vidar

    i have used the code when i press the button 1 . short press arrived

    but during long press no log came it shows only short press ..?!

    and one more thing

    as per ble_app_uart

    uses BSP_BLE_ module  link .  here

    as it is but i need is

    current status         button          action              event

    connected                 1              long push            BSP_EVENT_SLEEP

    not connected          1              long push            BSP_EVENT_SLEEP

    sleep                         1              long push            BSP_EVENT_WAKEUP

    shall we change it like this???

  • The implementations include code for using both BSP and button handling library, see #ifdefs. I have tested it with SDK 15.2.0

  • Vidar, Now i didn't change anything

    freshly opened ble_app_uart  (from sdk15.3)

    In bsp_btn_ble.c  file

    is changed to

    getting restarted

  • Coming back to your code which you given from the link

    i changed the value as

    #define USE_BSP 1

    and

    just called sleep_mode_enter(); in the LONG_PUSH event

    system getting  restarted  not when to off state

Reply
  • Coming back to your code which you given from the link

    i changed the value as

    #define USE_BSP 1

    and

    just called sleep_mode_enter(); in the LONG_PUSH event

    system getting  restarted  not when to off state

Children