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 Reply
  • Vidar, Now i didn't change anything

    freshly opened ble_app_uart  (from sdk15.3)

    In bsp_btn_ble.c  file

    static uint32_t connection_buttons_configure()
    {
        uint32_t err_code;
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_SLEEP,
                                                     BTN_ACTION_SLEEP,
                                                     BSP_EVENT_DEFAULT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_WHITELIST_OFF,
                                                     BTN_ACTION_WHITELIST_OFF,
                                                     BSP_EVENT_WHITELIST_OFF);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT,
                                                     BTN_ACTION_DISCONNECT,
                                                     BSP_EVENT_DISCONNECT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        return NRF_SUCCESS;
    }
    

    is changed to

    static uint32_t connection_buttons_configure()
    {
        uint32_t err_code;
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_SLEEP,
                                                     BTN_ACTION_SLEEP,
                                                     BSP_EVENT_DEFAULT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_WHITELIST_OFF,
                                                     BTN_ACTION_WHITELIST_OFF,
                                                     BSP_EVENT_WHITELIST_OFF);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT,
                                                     BTN_ACTION_DISCONNECT,
                                                     BSP_EVENT_SLEEP);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        return NRF_SUCCESS;
    }

    getting restarted

Children
Related