Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

GPIO Handlers for same pin

FabioGMFabioGM Manaus, Brazil

Hi...

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:

Example:

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?

Comments

  • nliviunliviu Romania
    edited January 5

    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 5

    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

  • nliviunliviu Romania

    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.