ENCODER_OPTIMIZE_INTERRUPTS Problem with Encoder library with 4X counting

I am trying to use http://www.pjrc.com/teensy/td_libs_Encoder.html fast encoder library.

UPDATE: "Coding Badly" found the problem. By declaring the update function in the Encoder.h file to be public rather than private, the compile suceeds.

When I define ENCODER_OPTIMIZE_INTERRUPTS the sample programs eg Speedtest fail to compile on Arduino 1.0.3

In file included from SpeedTest.pde:39:
C:\Users\Dell\Dropbox\Arduino\libraries\Encoder/Encoder.h: In function 'void __vector_1()':
C:\Users\Dell\Dropbox\Arduino\libraries\Encoder/Encoder.h:184: error: 'static void Encoder::update(Encoder_internal_state_t*)' is private
C:\Users\Dell\Dropbox\Arduino\libraries\Encoder/Encoder.h:914: error: within this context
C:\Users\Dell\Dropbox\Arduino\libraries\Encoder/Encoder.h: In function 'void __vector_2()':
C:\Users\Dell\Dropbox\Arduino\libraries\Encoder/Encoder.h:184: error: 'static void Encoder::update(Encoder_internal_state_t*)' is private
C:\Users\Dell\Dropbox\Arduino\libraries\Encoder/Encoder.h:917: error: within this context

My target board is a Uno.

I understand the library is specific for the board type. What board type is it known to work with?

Any advice welcome....

I understand the library is specific for the board type. What board type is it known to work with?

Well looking at the URL I would say a teesey. It looks like you have not installed the libary in the correct place.

The web site does say:

When used on Teensy and Arduino, Encoder uses very optimized interrupt routines written in assembly language.

Has anyone managed to get it to work with an Arduino?

The library must be installed correctly as there are no unresolved references.

SpeedTest.pde

Is that something you wrote or an example?

It's one of the 4 example files supplied with the library. I specified it in the post to avoid confusion. The #defines ENCODER_OPTIMIZE_INTERRUPTS is commented out in the example, which I take as an indication that the codes author has limited the support to just those modules he manufactures and not Arduino. I found one post where support of Leonardo is specifically excluded.

I could be wrong... but if there is no support for Arduino, people should be aware of it before wasting time on this library.

Anyone manage to get ENCODER_OPTIMIZE_INTERRUPTS to work on an Arduino?

GroundAttack: I could be wrong... but if there is no support for Arduino, people should be aware of it before wasting time on this library.

Why do you believe the Arduino boards are not supported?

// This optional setting causes Encoder to use more optimized code, // but the downside is a conflict if any other part of your sketch // or any other library you're using requires attachInterrupt(). // It must be defined before Encoder.h is included.

Have you tried the library without enabling ENCODER_OPTIMIZE_INTERRUPTS? The comment hints that it will work just without the "more optimized code".

I could be wrong… but if there is no support for Arduino, people should be aware of it before wasting time on this library.

“No support”. That’s a bit harsh. Especially given…

Anyone manage to get ENCODER_OPTIMIZE_INTERRUPTS to work on an Arduino?

The compiler told you what was wrong. The fix is trivial…

public:
static void update(Encoder_internal_state_t *arg) {

Thanks "Coding Badly" making it public certainly makes the compiler error go away. I will test it out tonight. Yes, it works fine without ENCODER_OPTIMIZE_INTERRUPTS defined.

I have just a vague handle on what's being done:

public:
    static void update(Encoder_internal_state_t *arg) {
#if defined(__AVR__)
        // The compiler believes this is just 1 line of code, so
        // it will inline this function into each interrupt
        // handler.  That's a tiny bit faster, but grows the code.
        // Especially when used with ENCODER_OPTIMIZE_INTERRUPTS,
        // the inline nature allows the ISR prologue and epilogue
        // to only save/restore necessary registers, for very nice
        // speed increase.

Is it necessary to declare the function private in order to get the compiler to inline the function?

Also, let me apologize for any harshness in my post which is not my intention.

It is because talented people give their time freely that the whole Arduino thing is so approachable and usable by people like me who are just learning.

Seems to work with the redeclaration of the update function from private to public.

That seems to close the matter, Thanks "Coding Badly" for sorting it.

I will try to ammend my first posting so that others having the problem can go straight to the solution.

You are welcome. Thank you for the follow-up.

Is there any reason why this fix wouldn't work in 1.5.4? I haven't tried in 1.0.5 yet but changing to public didn't work for me. Same vector errors.

Tried both Uno and Mega ...

I got my other problem fixed for the Due and it does work on the Due without changing it to public, still using private. Strange.

The other problem was can't use variable name index for Due.