can I register more than one GPIO events at a time

Discussion and questions about programming with Ultibo.
laodingding
Posts: 7
Joined: Wed Jul 25, 2018 1:23 pm

can I register more than one GPIO events at a time

Postby laodingding » Thu Aug 02, 2018 9:05 pm

I registered 2 GPIO events using GPIOInputEvent, one for Rising and the other for Falling , only 1st one was fired, I am not sure what is going on.
AM I doing this right way?

can anyone help, Thanks a lot!
User avatar
Ultibo
Site Admin
Posts: 2002
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: can I register more than one GPIO events at a time

Postby Ultibo » Fri Aug 03, 2018 3:12 am

laodingding wrote:I registered 2 GPIO events using GPIOInputEvent, one for Rising and the other for Falling , only 1st one was fired, I am not sure what is going on.
AM I doing this right way?

If you want to detect both rising and falling events then you should register one event for the special value GPIO_TRIGGER_EDGE which will register both rising and falling edge detection internally.

Just so you know, there are a couple of simple rules for GPIO events due to the way the device works and the way the API is structured.

1. You can register multiple times for different events on different pins.
2. You can register multiple times for the same event on the same pin.
3. If you use either the GPIO_EVENT_FLAG_REPEAT or GPIO_EVENT_FLAG_INTERRUPT flags, then you can only register one event on that pin.

Hope that helps.
Ultibo.org | Make something amazing
https://ultibo.org
laodingding
Posts: 7
Joined: Wed Jul 25, 2018 1:23 pm

Re: can I register more than one GPIO events at a time

Postby laodingding » Fri Aug 03, 2018 1:10 pm

Thanks for your prompt response!
laodingding
Posts: 7
Joined: Wed Jul 25, 2018 1:23 pm

Re: can I register more than one GPIO events at a time

Postby laodingding » Mon Aug 06, 2018 2:30 am

Hi,
I am using both GPIO_EVENT_FLAG_REPEAT and GPIO_EVENT_FLAG_INTERRUPT, Can I register one event(say EDGE) multiple times for different pins, one for each?

Edit:
After experiments, I found the answer is YES

User avatar
Ultibo
Site Admin
Posts: 2002
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: can I register more than one GPIO events at a time

Postby Ultibo » Mon Aug 06, 2018 10:01 am

laodingding wrote:
Edit:
After experiments, I found the answer is YES

That's correct, you can register any number of events on different pins and it doesn't matter if they are for the same event or different. You can even have some that are interrupt and some that are not, or some that are repeating and others that are not.
Ultibo.org | Make something amazing
https://ultibo.org

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests