Hi baptist,
I modified the MCP23017 example so that it can now handle input pins as well.
Disable the current MCP23017 program and import the new one attacched to this message. After importing you'll get a new "Example MCP23017" program next to the old one but witha different pid (>=1000).
In order to activate the new program, you have to:
1) click it in the list
2) clik 'edit program'
3) click 'edit source code'
4) eventually change the pinConfiguration list definitions that is located at the beginning of the code (just change the Direction field of the pins)
5) select Update from Actions menu
After that you'll get new modules of type Switch associated to the output pins and modules of type Sensor associated to the input pins.
Currently pins are configured as follow:
var pinConfiguration = new List<dynamic>(){
new { Address = "1", Pin = Mcp23017Pin.A0, Direction = Mcp23017PinDirection.Output, Status = false },
new { Address = "2", Pin = Mcp23017Pin.A1, Direction = Mcp23017PinDirection.Output, Status = false },
new { Address = "3", Pin = Mcp23017Pin.A2, Direction = Mcp23017PinDirection.Output, Status = false },
new { Address = "4", Pin = Mcp23017Pin.A3, Direction = Mcp23017PinDirection.Output, Status = false },
new { Address = "5", Pin = Mcp23017Pin.A4, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "6", Pin = Mcp23017Pin.A5, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "7", Pin = Mcp23017Pin.A6, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "8", Pin = Mcp23017Pin.A7, Direction = Mcp23017PinDirection.Input, Status = false },
//
new { Address = "9", Pin = Mcp23017Pin.B0, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "10", Pin = Mcp23017Pin.B1, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "11", Pin = Mcp23017Pin.B2, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "12", Pin = Mcp23017Pin.B3, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "13", Pin = Mcp23017Pin.B4, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "14", Pin = Mcp23017Pin.B5, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "15", Pin = Mcp23017Pin.B6, Direction = Mcp23017PinDirection.Input, Status = false },
new { Address = "16", Pin = Mcp23017Pin.B7, Direction = Mcp23017PinDirection.Input, Status = false }
};
Also you might want to change the polling interval for input pins that is actually set to 500ms (line 110).
I don't have a MCP23017/Piface for testing, so let me know if this is working.
Cheers,
g.