interrupts in libraries

Hi, do you know how can I declare and call an ISR inside a library? if I use this code in the cpp file:

int myclass::myMethod()
{
attachInterrupt(1, isrName(), RISING);
...
...
}


void myclass::isrName()     //This is the function that the interupt calls
{
	//isr code
}

i get error. Thanks

Hi, do you know how can I declare and call an ISR inside a library?

For which instance of the class do you want the ISR called?

You can't call a specific instance's method. You could make the method static (shared by all instances), then use the scope resolution operator:

int myclass::myMethod()
{
attachInterrupt(1, myclass::isrName, RISING);
...
...
}

Note that there are no parentheses after the method name.

thanks, I have tried as you told me to write
attachInterrupt(1, myclass::isrName, RISING);

but the complier tell me " error: argument of type 'void (myclass:: ) ()' does not match 'void (*)()' "

I havent understand this "You can't call a specific instance's method. You could make the method static" may be this is my problem.
Are you telling that myMethod must be static?
Why can't I call a specific instance's method?

thank you very much for your time!

Are you telling that myMethod must be static?

Yes.

Why can't I call a specific instance's method?

Because all you are telling the ISR is to call a function by address. You would have to get very creative to determine the address of the function to call when the function is an instance method.

may be you're sayng I must act in this way
http://jennaron.com.au/avr/classinterrupts.html
but I must know the name of my object instance ans so I can not write a generic library

this post is about the subject
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239522239

Suppose your object is a clown. You have 12 clowns. An interrupt occurs. Which clown should do something?

When you attach the interrupt handler, you need to specify which single function to call. Should it be clown1.doSomething() or clown7.doSomething()?

Clearly, it can't be Clown::doSomething(), because you have no way of knowing which instance of the Clown class should do something.

Unless, doSomething() is a static method, and that static method is able to determine, somehow, which clown should doSomething().

thank you very much PaulS! I have spent a lot of time trying to understand the logic, now with the clown example all is clear!!!