DFRobot MCP23017 Interrupts example error

Evening all,

Breif outline:
I have been working on a button box project - had it all working but when completely compiled the number of toggle switches caused polling of the rotary encoders to be too slow missing inputs.

the main board is an Arduino Leonardo, attache to which is a DFRobot MCP23017 expander: Gravity: MCP23017 IIC 16 Digital IO Expansion Module Wiki - DFRobot
So on reaching out and doing a bit of research it seems I need to use interrups. I looked at the Adafruit library and now the DFRobot library.

Though I understand in concept what interrupts do, understanding the coding is ,for me, far more complicated so downloaded an example on the DFRobot Wiki. The IO sample code towards the bottom of the page: Gravity: MCP23017 IIC 16 Digital IO Expansion Module Wiki - DFRobot

However I can't seem to find a way of making it work, or rather it half does only reading and reporting change switch states on bank B, absolutely noting on bank A.

I was hoping someone might be able to explain why outside of my lack of knowledge? Many thanks.


#include <DFRobot_MCP23017.h>


DFRobot_MCP23017 mcp(Wire, 0x27);

bool intFlagA = false;  //INTA interrupt sign
bool intFlagB = false;  //INTB interrupt sign

/*Interrupt service function, prototype void func(int index), index represents the pin which is interrupted*/
void gpa0CB(int index) {
  String description = mcp.pinDescription(index);
  Serial.print(description);
  Serial.println(" Interruption occurs!");
}

void gpb7CB(int index) {
  String description = mcp.pinDescription(index);
  Serial.print(description);
  Serial.println(" Interruption occurs!");
}



void test(int index) {

  String description = mcp.pinDescription(index);
  Serial.print(description);


  Serial.println(" Interruption occurs!");
}
void setup() {
  Serial.begin(115200);

  pinMode(2, INPUT);  //use UNO external interrupt 0
  pinMode(3, INPUT);  //use UNO external interrupt 1



  (mcp.begin() != 0);
  {
  }
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPA0, /*mode = */ mcp.eHighLevel, /*cb = */ test);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPA1, /*mode = */ mcp.eHighLevel, /*cb = */ gpa0CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPA2, /*mode = */ mcp.eHighLevel, /*cb = */ gpa0CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPA3, /*mode = */ mcp.eHighLevel, /*cb = */ gpa0CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPA4, /*mode = */ mcp.eHighLevel, /*cb = */ gpa0CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPA5, /*mode = */ mcp.eHighLevel, /*cb = */ gpa0CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPA6, /*mode = */ mcp.eHighLevel, /*cb = */ gpa0CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPA7, /*mode = */ mcp.eHighLevel, /*cb = */ gpa0CB);

  mcp.pinModeInterrupt(/*pin = */ mcp.eGPB7, /*mode = */ mcp.eChangeLevel, /*cb = */ gpb7CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPB6, /*mode = */ mcp.eChangeLevel, /*cb = */ gpb7CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPB5, /*mode = */ mcp.eChangeLevel, /*cb = */ gpb7CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPB4, /*mode = */ mcp.eChangeLevel, /*cb = */ gpb7CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPB3, /*mode = */ mcp.eChangeLevel, /*cb = */ gpb7CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPB2, /*mode = */ mcp.eChangeLevel, /*cb = */ gpb7CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPB1, /*mode = */ mcp.eChangeLevel, /*cb = */ gpb7CB);
  mcp.pinModeInterrupt(/*pin = */ mcp.eGPB0, /*mode = */ mcp.eChangeLevel, /*cb = */ gpb7CB);


  attachInterrupt(/*Interrupt NO*/ 0, notifyA, RISING);  //Enable external interrupt 0, connect INTA to the main-controller's digital pin: UNO(2),Mega2560(2),Leonardo(3),microbit(P0)
  attachInterrupt(/*Interrupt NO*/ 1, notifyB, RISING);  //Enable external interrupt 1, connect INTB to the main-controller's digital pin: UNO(3),Mega2560(3),Leonardo(2),microbit(P1)
}
/*Interrupt service function*/
void notifyA() {
  intFlagA = true;
}
void notifyB() {
  intFlagB = true;
}

void loop() {
  if (intFlagA) {
    intFlagA = false;
    mcp.pollInterrupts(/*group = */ mcp.eGPIOA);
  }
  if (intFlagB) {
    intFlagB = false;
    mcp.pollInterrupts(/*group = */ mcp.eGPIOB);
  }
}

That's easily possible.

Get hold of an example code for the encoder and make that work. Then add the other things.

Nice picture but it is not completely annotated. A schematic would be much easier to follow.