I wrote some code that handles rotary encoder using an interrupt, but I would like to get which pin generated the interrupt, so I'll be able to handle many interrupts in a single method.
Something like:
void ISREncoders()
{
int pin = GetCurentInterruptPin(); // <============= this
int dataPin = dataPins[pin];
int data = DigitalRead(dataPin);
if(data == HIGH)
{
encoders[pin] += 1;
}
else
{
encoders[pin] -= 1;
}
}
Is it anyhow possible?
As mentioned in the answer this is not possible. Still, after peeking some encoder libraries that use interrupt found out that they do the following:
The Encoder class contains several static ISR methods hard coded.
As you create new objects it increments an internal counter and sets proper ISR method on the interrupt.
This is for sure the best solution available, but this is not at all scalable, for instance if you have an imaginary board with thousand pins that handle thousands encoders you will have to hard code each ISR method.
two clock pins are in HIGH state
... there is a flaw in your thinking (not related to your question though) ... your thinking should betwo clock pins transition from LOW to HIGH state (or vice versa)