Debugged it for a few hours yesterday. From an outside perspective, it looks like every time an interrupt is called, the Adafruit library either keeps the ISR from clearing the flag or sets all flags since any ISRs are reentered when it writes.
Since the library uses I2C, disabling interrupts is not an option. I have solved the problem using a workaround:
boolean initialFlank = true;
volatile boolean aThing = false;
int pin = 5;
void setup() {
pinMode( pin, INPUT_PULLUP );
attachInterrupt( digitalPinToInterrupt( pin ), pinISR, FALLING );
}
void loop() {
noInterrupts();
boolean _aThing = aThing;
aThing = false;
interrupts();
// if this is the first reported falling flank since it rose, it is valid
if( _aThing && initialFlank ){
initialFlank = false;
Serial.println( "Click" );
}
// if there is no interrupt being sent (just being careful here, may not be necessary)
// and the initialFlank was false (interrupt received) and the pin is high again(low active)
else if( !_aThing && !initialFlank && digitalRead( pin ) ){
initialFlank = true;
}
void pinISR( ){
aThing = true;
}
Since the activation of the isr by Adafruit is not linked to an actual falling edge and hardware debouncing is sufficiently good, there will most likely only be a single falling flank (even if it bounces, it would have done so anyways). Then, until the flank rises again, all interrupts are ignored (cant fall before it has risen).
This works, but I may want to add a timeout in case something goes wrong. Will think about it.
Thank you all for your help!