I'm using 14.2 SDK.
I want to implement long pressure and short pressure.
key0= short press, key1= long press
You are using app_button.
And I checked that the current "button_init" can set the delay at once.
How can I implement long and short?
static void button_handler(uint8_t pin, uint8_t action)
{
switch(action)
{
case APP_BUTTON_PUSH:
switch (pin)
{
case KEY0:
led_off();
break;
case KEY1:
led_off();
break;
default:
break;
}
break;
case APP_BUTTON_RELEASE:
switch (pin)
{
case KEY0:
led_on();
break;
case KEY1:
led_on();
break;
default:
break;
}
break;
}
}
void buttons_init(void)
{
uint32_t err_code = 0;
static app_button_cfg_t buttons[] = {
{KEY0, false, NRF_GPIO_PIN_PULLDOWN, button_handler},
{KEY1, false, NRF_GPIO_PIN_PULLDOWN, button_handler}
};
err_code = app_button_init((app_button_cfg_t *)buttons,
sizeof(buttons) / sizeof(buttons[0]),
BUTTON_DETECTION_DELAY_SHORT);
APP_ERROR_CHECK(err_code);
err_code = app_button_enable();
APP_ERROR_CHECK(err_code);
}