Go Down

Topic: time based function calls - any interest? (Read 467 times) previous topic - next topic

ckiick

Hello,
I have implemented a pretty basic callout handler.  A callout is a function that runs at a specific time in the future.  So you could, say, write a function to change the state of an LED to off, and have it run 1 second from now.  Meanwhile loop() can keep on rolling.

It's not a true library, because I had to add a hook into the counter0 timeout ISR, which means I had to edit one of the core files.

Would anyone be interested in this?
Chris J. Kiick
Robot builder and all around geek.

mem

I haven't tried it in the arduino environment so I don't know if it will work (or is even advisable) but I wonder if you have checked to see if patching the interrupt vector table is documented. If it is then your library initialisation routine could hot patch the vector for your new isr which presumably would also service the old handler.

Just a thought.

follower

I realise they're not identical but is there some overlap between your work and Metro?

Might be worth considering transferring some ideas and/or code betwen the two?

--Phil.

ckiick

Hmm... I hadn't seen that before.
But no, they don't really overlap that much.  Metro is basically a stop watch that you can check periodically to see if it's time to do something yet.  You could get the same effect with millis().

The callouts actually call a function when the timer expires.

Thanks for the heads up.
Chris J. Kiick
Robot builder and all around geek.

westfw

Do a version that is explicitly polled by a function called from loop() instead of tying into the ISR.  That'll do nearly the same thing for the people who don't want to modify their core files, but who would like the time-based calls.  It should be pretty easy (but not quite as precise.)

Go Up