I2C keypad on Due ?

I have been trying to use a keypad with an I2C PCF8574 chip hooked up to a Due, but there is some problem with the Wire.h / Wire.cpp implementation. Specifically, the constructor for TwoWire for AVR and SAM are different:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src :

** ** TwoWire();** **

C:\Users\bowzee\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.8\libraries\Wire\src :

** ** TwoWire(Twi *twi, void(*begin_cb)(void), void(*end_cb)(void));** **

In the Keypad_I2C library by Joe Young et al. ( arduino_keypads/Keypad_I2C at master · joeyoung/arduino_keypads · GitHub ) this is the constructor:

** **   class Keypad_I2C : public Keypad, public TwoWire {        public:        Keypad_I2C(char* userKeymap, byte* row, byte* col, byte numRows, byte numCols, byte address, byte width = 1) : Keypad(userKeymap, row, col, numRows, numCols) { i2caddr = address; i2cwidth = width;} ...** **

so TwoWire does not get the required three parameters for SAM / Due.

Is there an easy workaround for this?

Hi @facchinm,

(I am re-posting here because I am not sure if you are going to read this at Wire.h Wire.cpp library consistency: AVR vs. SAM · Issue #5165 · arduino/Arduino · GitHub )

I do not want to rewrite Joe Young's libraries. What I am trying to report is the inconsistency, there is no TwoWire::TwoWire() for SAM (Due), so an exact same program written for AVR will not work with Due (it will not get compiled). Like the examples included with these libraries.

I agree that there probably is no need for inheritance (in fact it gets confusing), but that is not my code.

Hi. Did you solve the problem?
I can compile i2c keypad library (mcp23017) with avr, esp8266, but not in DUE


Hello there!

I haven't used that keypad and chip before so forgive me if this doesn't make sense. I have used the standard Wire library on the Due fairly extensively. Is there a way you can use wire and then just read the registers of the chip or something?