Skip to content

[HACKTOBERFEST] Examples#2

Open
MMMMMNG wants to merge 13 commits into
Ro5bert:masterfrom
MMMMMNG:examples
Open

[HACKTOBERFEST] Examples#2
MMMMMNG wants to merge 13 commits into
Ro5bert:masterfrom
MMMMMNG:examples

Conversation

@MMMMMNG

@MMMMMNG MMMMMNG commented Oct 23, 2023

Copy link
Copy Markdown
Contributor

Adds examples to the project

As hinted at in 2d9a118 :)

Changes

  • New source set: 'examples', compiles to an executable fatJar with the compiled MCP23S17 class included (so it mimics a third party app trying to use this class)
  • New task: runExamples takes the executable fatJar, puts it on the pi and runs it.

TODOs

  • add example where chips are used as outputs rather than inputs (or mixed maybe?)
  • test with actual chips and wires connected and all

Future TODOs

  • refactor the static factory methods to some kind of builder class or something, 'cuz the way it works now there would have to be a new method for every combination of enabled interrupt pins and enabled hardware address pins which doesn't seem very DRY.

copied that straight from the examples I made for rpi-ws281x-java 🔥
These dependencies should all already be in the classpath at runtime because the 'examples' implementation depends on the fatJar from MCP23S17.
Turns out the uberExampleJar task didn't properly merge the META-INF/services file. Now pi4j.newAutoContext() works again.
For choosing multiple examples you can use the `-Pexample=<ExampleClassName>` cli arg.
both examples were successfully tested.
The provider had to be explicitly requested in the GPIO & SPI ConfigBuilder, then it worked.
also added a wiring diagram and a gif showing the running test of ConsecutiveTurnOnExample.

Aight! The examples worked during my tests so that's it for me! 😀🔥
@MMMMMNG MMMMMNG marked this pull request as ready for review October 30, 2023 17:28
now that the mock-spi-plugin updates are officially released there is no need for the cumbersome workaround to execute tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants