MCP23017 as GPIO provider example
See original GitHub issueHi,
First of all a big thank you for your great effort in releasing the pi4j v2 library, you did an amazing job.
I’d like to use the MCP23017 as a GPIO provider, but the codes you posted as examples are very simple and in some cases confuse me. For example: https://github.com/Pi4J/pi4j-example-minimal/blob/main/src/main/java/com/pi4j/example/MinimalExample.java
// Here we will create I/O interfaces for a (GPIO) digital output
// and input pin. Since no specific 'provider' is defined, Pi4J will
// use the default `DigitalOutputProvider` for the current default platform.
var ledConfig = DigitalOutput.newConfigBuilder(pi4j)
.id("led")
.name("LED Flasher")
.address(PIN_LED)
.shutdown(DigitalState.LOW)
.initial(DigitalState.LOW)
.provider("pigpio-digital-output");
var led = pi4j.create(ledConfig);
You wrote: “Since no specific ‘provider’ is defined” but some provider is there: “.provider(“pigpio-digital-output”)”. BTW: how do I know what strings you predefined to put in the provider (e.g. to avoid the same strings in my custom implementations)?
I tried to create MCP23017 as my custom provider, but unfortunately I was not successful. The documentation is very limited and there is no complete example of how to create such a provider. Could you please help and create an example of an “advanced IO provider”?
Many thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:39 (28 by maintainers)
Top GitHub Comments
@taartspi
Sorry. I must have dropped the ball on that one.
Let’s work from here: https://github.com/savageautomate/pi4j-plugin-microchip and just focus on Microchip devices at this time. Feel free to create issues/questions in that repo as well.
Once we get a fully working plugin defined and work out all the configuration details we can use it as a reference to create other plugins/providers for other chipsets.
Thanks, Robert
@tatery
A few more improvements to the prototype code today. It should work for both DIGITAL INPUT and OUTPUT but only when polling input states. The code to handle MCP23017 interrupts and propagate GPIO events for inputs is not implemented yet.
@FDelporte (RE: https://github.com/Pi4J/pi4j-device-tca9548/tree/master/src/main/java/com/pi4j/devices/mcp23017) That code is not really following the “Provider” model. So I don’t think its pluggable into the Pi4J framework as a reusable GPIO digital input/output provider. If we can get https://github.com/savageautomate/pi4j-plugin-microchip fully working this could be moved under the Pi4J GitHub umbrella and serve as an example for others.