-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Scheduled Interrupt #4609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scheduled Interrupt #4609
Conversation
@hreintke have you considered proposing this to the Arduino cores (AVR/ARM) as well? It would be great if we could keep such features more or less in sync. |
@igrr No I did not (yet). Isn't schedule_function an ESP8266 only functionality ? |
@hreintke I've been looking at this on and off (I keep getting interrupted... don't laugh). There is a subtlety with using the scheduled functions from a gpio isr. I am describing this here for reference. The number of functions that can be scheduled for the next loop run is currently limited. If the isr were to trigger more times than that limit before the next schedule service after the loop, calls would be lost, because the scheduled function list would be filled up.
I think there is some additional work that should accompany this implementation (not necessarily in this same PR):
|
@devyte Nice catch on the number of interrupts, didn't think of that. Remarks on 2/ limit 3/protection. |
In case of trigger during a loop pass:
If we change the execution of the scheduled functions to before the loop, the new behavior would be this:
In case of trigger during a loop pass:
|
Possible Schedule implementation. I added the following functionality :
Did not yet integrate with Schedule.h & FunctionalInterrupt. Example sketch :
|
@hreintke there seem to be warnings with this, hence failing CI. Could you please take a look? |
@devyte Done |
ok, my (shallow) testing shows this working, I have nothing to add to the code changes, and there is one report of the memleak being fixed. I'm merging. |
(fix proposed by @shimarin, verified by @marcvtew esp8266#4866)
@devyte This PR also included the WIP of ScheduledFuncion (.h & cpp). |
@hreintke you're right, and I now realize that I have some comments in there. |
@devyte Yes I will. PS : See you are busy, no problem that it takes some time. |
Hi,
This PR adds the possibility to schedule (= execute after loop) the ISR routine.
In this way
This builds on top of the functional interrupt functionality (#2745)
In this implementation I took std::function<void(InterruptInfo)>
InterruptInfo containing pin, pinstatus and micros() from time of interrupt.
@devyte : This also solves the memory leak you mentioned for FunctionalInterrupt
Comments are welcome.