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

How to use BSP_BUTTON_ACTION_PUSH and BSP_BUTTON_ACTION_LONG_PUSH on the same button, with two different functions?

Hi, I have seen a few similar questions to this but the answers weren't too clear...I am trying to use both the long button push and the button push actions to generate separate events to be handled by the bsp_event_handler() but cannot seem to assign a new action to an event/button. How can i use the bsp_event_to_button_action_assign() to enable both a long push and a short push on a single button that call separate functions? I am also slightly confused as to which files are used to control the push buttons as there seem to be a few ways to control them depending on if BLE is used...I read on the online infocenter the buttons can be controlled using BSP, Button Handling Library, GPIOTE, and also the BLE files. Is there a common practice to getting the long push to work? I also saw in another thread that timers could be use to distinguish between a long and short push, however the bsp_board_button_state_get() function would always return true, even when the button wasn't pressed when the timer ended and the bsp_board_button_state_get() function was called. Am I closer to a long push with this approach? (I was able to get a "double" press effect, but it needs to be a long press)

What I am working with: Using nRF52840 and SDK 15.2.0 developing on Mac OS using Segger. The app uses the ble_app_template and has the following path: 

nRF5_SDK_15.2.0_9412b96/examples/ble_peripheral/my_project_file_name/pca10056/s140/ses/ble_app_template_pca10056_s140.emProject

I included the path because I'm not sure if which example type it is included in affects which modules control the buttons. 

Any help is greatly appreciated, Thanks!

Related