Some questions about AikoEvents.

36 views
Skip to first unread message

James Harton

unread,
Jan 8, 2011, 5:13:49 AM1/8/11
to Aiko distributed platform
Hi all.

I finally got myself an Arduino for xmas, so I've been tinkering
around with it while I'm on holiday. I have two questions about
events with Aiko.

First, is it possible to pass in an a object method instead of a
function into Events.addHandler? Either that or allow the passing of
an argument into the callback somehow so that I can figure out the
context in which the callback was called?

Second, I'd really like to be able to set a handler to be called x
number of times only. Especially if the iteration number is passed as
an argument.

Thirdly, is there a way to stop or remove an existing recurring
handler?

Lastly, if I #include <AikoEvents.h> inside my own library this would
create a second instance of Events (ie it's not a singleton) right?
Essentially I'd like my classes to be able to create their own event
handlers and add them to the sketch's EventList whilst still letting
them have access to the object's context. Here's an oversimplified
example:

class myLed {
public:
int value;
int pin;
myLed(int _value, int _pin) {
value = _value;
pin = _pin;
Aiko::Events.addHandler(&updatePin, 70); // Approx 14Hz
}
void updatePin() {
analogWrite(pin,value);
}
};


I have spent a few hours this afternoon trying to figure this all out
for myself, but my C++ is just not up to the task yet, although I
think I'm doing pretty good for someone with less than 8 hours of C++
programming under his belt!

Any pointers, derision or solutions gratefully accepted!

James Harton
http://sociable.co.nz/
Reply all
Reply to author
Forward
0 new messages