mjs513
Senior Member+
Hi all. I just downloaded KurtE's fork of the core libs to give the Serial changes a try and noticed that eventResponder was included. So I figured I would give it a shot and test the example that Paul posted. As expected it worked no issue. So I started to looking at what's its doing and of modifying the code. So if I can ask a few questions:
Ok so with that said if I change the example to add another repeating timer (think I did this right):
It never executes dotimer2. It appears that the earlier trigger resets all timers to zero, I never see "repeating timer event":
Also if I noticed if I remove the delay from the loop everything hangs and I have to reset to get the ide/sm working again. Know I have to be missing something. Help.
thanks
Mike
- In the loop the call to myevent.triggerEvent(); is starting the event process, turning it on?
- The "doSomething" function has a call to mytimer.begin(550, mytimerevent);, not 100% sure what that does - sets the trigger for every 550 ms or starts it after 550ms?
- The mytimer2.beginRepeating(750, mytimerevent2) sets the trigger to go off every 750 ms?
Ok so with that said if I change the example to add another repeating timer (think I did this right):
Code:
#include <EventResponder.h>
EventResponder myevent;
EventResponder mytimerevent;
EventResponder mytimerevent2;
EventResponder mytimerevent3;
MillisTimer mytimer;
MillisTimer mytimer3;
MillisTimer mytimer2;
void setup() {
while (!Serial) ;
Serial.println("EventResponder test");
myevent.attach(dosomething);
mytimerevent.attach(dotimer);
mytimerevent2.attach(dotimer2);
mytimerevent3.attach(dotimer3);
mytimer2.beginRepeating(750, mytimerevent2);
mytimer3.beginRepeating(250, mytimerevent3);
}
void loop() {
Serial.println("loop trigger dosomething");
myevent.triggerEvent();
delay(2000);
}
void dosomething(EventResponderRef event)
{
Serial.println("dosomething event");
mytimer.begin(550, mytimerevent);
}
void dotimer(EventResponderRef event)
{
Serial.println("oneshot timer event");
}
void dotimer2(EventResponderRef event)
{
Serial.println(" repeating timer event");
}
void dotimer3(EventResponderRef event)
{
Serial.println(" what a wonderful world");
}
It never executes dotimer2. It appears that the earlier trigger resets all timers to zero, I never see "repeating timer event":
Code:
loop trigger dosomething
dosomething event
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
loop trigger dosomething
dosomething event
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
what a wonderful world
Also if I noticed if I remove the delay from the loop everything hangs and I have to reset to get the ide/sm working again. Know I have to be missing something. Help.
thanks
Mike
Last edited: