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

Long Press to Wake-up

Hello,

Is there any methods to implement the "long press wake-up"? Pressing the button for 3 seconds to let device enter sleep mode and pressing the same button for 3 seconds to wake it up.

Already defined the wake-up gpio in "sleep_mode_enter()" function as below. The question is that how to measure the time when the device wake-up from the sleep mode?

[SDK12, nRF52]

 static void sleep_mode_enter(void)
{
		uint32_t err_code;
	
		//
		LEDS_OFF(LEDS_MASK);
	
		// init wakeup gpio
		nrf_drv_gpiote_in_uninit(5);

		nrf_drv_gpiote_in_config_t power_btn_config =   GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
		power_btn_config.pull = NRF_GPIO_PIN_PULLUP;
		err_code = nrf_drv_gpiote_in_init(5, &power_btn_config, NULL);
		APP_ERROR_CHECK(err_code);
		nrf_drv_gpiote_in_event_enable(5, true);

		nrf_delay_ms(500);

        // Go to system-off mode (this function will not return; wakeup will cause a reset).
        err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
}

Thanks.

Parents
  • Hello Sara,

    If you mean SYSTEM OFF by your "sleep" then NO, the only wake-up mechanism in your situation is simple GPIOTE level change, there is no clock running in SYSTEM OFF so obviously you cannot detect "long" press. If you need it for user experience then you can of course fake it by going back to OFF mode if the GPIO line doesn't hold "pressed" state long enough after nRF5x wakes up.

    CHeers Jan

Reply
  • Hello Sara,

    If you mean SYSTEM OFF by your "sleep" then NO, the only wake-up mechanism in your situation is simple GPIOTE level change, there is no clock running in SYSTEM OFF so obviously you cannot detect "long" press. If you need it for user experience then you can of course fake it by going back to OFF mode if the GPIO line doesn't hold "pressed" state long enough after nRF5x wakes up.

    CHeers Jan

Children
Related