Pages: [1]   Go Down
Author Topic: time based function calls - any interest?  (Read 433 times)
0 Members and 1 Guest are viewing this topic.
Austin, TX
Offline Offline
Full Member
***
Karma: 2
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Chris J. Kiick
Robot builder and all around geek.

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Austin, TX
Offline Offline
Full Member
***
Karma: 2
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Chris J. Kiick
Robot builder and all around geek.

SF Bay Area (USA)
Online Online
Tesla Member
***
Karma: 134
Posts: 6763
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)
Logged

Pages: [1]   Go Up
Jump to: