serialEvent(1/2/3) in library class

Hi,

I was wondering if it is possible to have the serialEvent(1/2/3) function to be replaced by class::serialEvent(1/2/3) in one of my library classes. Is this possible or is there any other way to do something similar?

Thanks in advance

I was wondering if it is possible to have the serialEvent(1/2/3) function to be replaced by class::serialEvent(1/2/3) in one of my library classes. Is this possible or is there any other way to do something similar?

The IDE detects that you have defined a serialEventN() function, and registers that to be called (sometimes) at the end of loop(), if there is serial data on that port.

It doesn't look in your classes for similarly named methods, because similarly named methods are only that. The only similarity is in the method name. The IDE would have no idea which instance of the class the method should be called for, nor does it have a clue that there might only be one such instance.

So, no, it is not directly possible.

Of course, your sketch could provide the serialEventN() function that calls instance.method() as needed.