PaulStoffregen / Encoder

Quadrature Encoder Library for Arduino
http://www.pjrc.com/teensy/td_libs_Encoder.html
561 stars 242 forks source link

ISR vectors multiple defined #58

Open LineF opened 4 years ago

LineF commented 4 years ago

Hello, I just tried to use your Encoder library in Platformio (platform=atmelavr). First, everything compiled well, but then I switched on ENCODER_OPTIMIZE_INTERRUPTS.

After that I got multiple definitions of __vector_1 and __vector_2 when linking all together.

I'm using Encoder.h in multiple CPP files, so the ISR(INTx_vect) are multiply compiled and the linker throws an error.

My quick solution was to move the last part of Encoder.h (that part which is outside the class definition) to Encoder.cpp. So this part is only compiled once and the linker succeeds.

Maybe there is another, better solution?

Kind regards, Martin