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.

Parents
  • Time out handler

    static void button_power_5sec_handler(void * p_context)

    {
    UNUSED_PARAMETER(p_context);    
    if(nrf_gpio_pin_read(BUTTON_POWER)==1) //if button 1 is still pressed
    {
        NRF_LOG_INFO("Button1 5sec long pressed\r\n");
    			v33_ctrl_off();
    			pwr_ctrl_off();
    }
    	app_timer_stop(button_power_5sec_timer_id);
    button_power_5sec_timer_enabled=false;
    

    }

Reply
  • Time out handler

    static void button_power_5sec_handler(void * p_context)

    {
    UNUSED_PARAMETER(p_context);    
    if(nrf_gpio_pin_read(BUTTON_POWER)==1) //if button 1 is still pressed
    {
        NRF_LOG_INFO("Button1 5sec long pressed\r\n");
    			v33_ctrl_off();
    			pwr_ctrl_off();
    }
    	app_timer_stop(button_power_5sec_timer_id);
    button_power_5sec_timer_enabled=false;
    

    }

Children
No Data
Related