Pi4J, LCD and MCP23017 expander

107 views
Skip to first unread message

Bryce Renninger

unread,
Nov 24, 2015, 10:16:40 PM11/24/15
to Pi4J
Hello,

I am trying to use the MCP23017 expander chip to run my Adafruit LCD. I have the LCD running completely fine and perfect without the expander. However I am trying to find out how I declare what the int value is for the expander chip.


int lcdScreen= Lcd.lcdInit(LCD_ROWS,     // number of row supported by LCD
                                   LCD_COLUMNS,  // number of columns supported by LCD
                                   LCD_BITS,     // number of bits used to communicate to LCD 
                                   11,           // LCD RS pin
                                   10,           // LCD strobe pin
                                   0,            // LCD data bit 1
                                   1,            // LCD data bit 2
                                   2,            // LCD data bit 3
                                   3,            // LCD data bit 4
                                   0,            // LCD data bit 5 
                                   0,            // LCD data bit 6 
                                   0,            // LCD data bit 7 
                                   0);           // LCD data bit 8

Here is how I initialize the LCD without using the expander. So how to do I declare what the value is when I am using the expander chip?
 
final GpioPinDigitalOutput light = gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B2, "MyOutput-B0", PinState.LOW); 
How do I get that value into the int value for the LCD data bit?

Thanks for your help!

Robert Savage

unread,
Dec 2, 2015, 10:31:20 PM12/2/15
to Pi4J
Hi Bryce,

I don't have great news for you :-(

The LCD interface you are using is a direct JNI interface wrapping the WiringPi LCD implementation native code here:

So I don't see a simple way to use the Gpio Expander MCP23017 implementation in Pi4J in conjunction with this LCD interface.  
You could re-create that logic from WiringPi's LCD imlp in Java using the Pi4J GPIO interfaces and then be able to use Pi4J's MCP23017 impl.

Or WiringPi also includes its own extension impl for the MCP23017:

However, Pi4J does not provide the JNI wrappers for this functionality so you would have to use native C and WiringPi directly or create the JNI wrapper logic yourself.

Thanks, Robert

Andrew Chandler

unread,
Dec 3, 2015, 6:59:53 AM12/3/15
to Pi4J
Could a variation of the one I wrote for the 8468 (not sure that's the right number) i2c backpack be updated? I'm still half asleep but I'll check when I get to work. I believe you pulled it in a year or two ago
Reply all
Reply to author
Forward
0 new messages