Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

GPIO Handlers for same pin

FabioGMFabioGM Manaus, Brazil


I am trying to measure time a button is hold pushed. But when I set a handler for MGOS_GPIO_INT_EDGE_NEG and another for MGOS_GPIO_INT_EDGE_POS, it sets the last row of code:


input_success &= mgos_gpio_set_int_handler(mgos_sys_config_get_x120_hardreset(), MGOS_GPIO_INT_EDGE_NEG, press_handler, NULL);
input_success &= mgos_gpio_set_int_handler(mgos_sys_config_get_x120_hardreset(), MGOS_GPIO_INT_EDGE_POS, release_handler, NULL);

This code will set only release_handler

Any syggestions?


  • nliviunliviu Romania
    edited January 2019

    The last callback set by mgos_gpio_set_int_handler will be executed: source code
    You can try to set a callback for MGOS_GPIO_INT_EDGE_ANY and measure the time between the edges. You will need to add some debounce logic...

    Thanked by 1FabioGM
  • FabioGMFabioGM Manaus, Brazil
    edited January 2019

    According to this post MGOS_GPIO_INT_EDGE_ANY was removed.

    I tried using mgos_gpio_set_button_handler and using MGOS_GPIO_INT_EDGE_ANY, but it did not work out

  • AFAIK, MGOS_GPIO_INT_EDGE_ANY was removed for mgos_gpio_set_button_handler, not for mgos_gpio_set_int_handler

    Thanked by 1FabioGM
Sign In or Register to comment.