Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HACKTOBERFEST] Update to pi4j-v2 & Multi-Chip support #1

Merged
merged 46 commits into from
Oct 27, 2023

Conversation

MMMMMNG
Copy link
Contributor

@MMMMMNG MMMMMNG commented Oct 23, 2023

Changes

  • Update everything to pi4j-v2
  • Add multipleNewOnSameBus() factory method. This means multiple chips can now be used on the same bus, using hardware address pins.
  • Add automated testing with an updated version of the pi4j-mock-spi-plugin (there was a bug in the transfer() method, see #301. Since those changes aren't in maven central yet I bodged together a workaround solution with github actions, see the [...]-SNAPSHOT branch)

NOTE:

The Interface for the static factory methods changed:

//old
public static MCP23S17 newWithInterrupts(SpiChannel spiChannel,
                                             GpioPinDigitalOutput chipSelect,
                                             GpioPinDigitalInput portAInterrupt,
                                             GpioPinDigitalInput portBInterrupt) 
//new: ChipSelect and Channel are all handled by the single Pi4j-v2 class `Spi`
public static MCP23S17 newWithInterrupts(Spi bus,
                                             DigitalInput portAInterrupt,
                                             DigitalInput portBInterrupt)

Why

We used this library (or my updated version of it) extensively in our project, so by the end I was quite familiar with it. When I heard of Hacktoberfest, I thought this was the perfect opportunity to contribute what I can offer.
@Ro5bert I would appreciate it if you could label this PR "hacktoberfest-accepted" (if you like it, that is), that way it counts towards my hacktoberfest contributions.
screenshot of the rule
Taken from https://hacktoberfest.com/participation/

Thanks!

Feel free to provide feedback and I'll try to get to it asap.

Have a good one!
Cheers!

-MNG

MMMMMNG added 30 commits October 4, 2023 17:20
including temporary reference to local snapshot version of the pi4j-mock-plugin.
this means that the class is updated to pi4j V2 and supports multiple chips on the same SPI bus in one single commit.
Commit isn't functional (still depends on pi4j Component parents log() and delay() methods) but useful to see what has been affected.
Mainly used to assertArrayEquals without having to punch in hundreds of magic numbers.
Also used to fill the MockSpi.raw data buffer with prepared data.
add Mockito dependency
…oader doesn't support cross-workflow artifact sharing
@Ro5bert Ro5bert merged commit 0e83769 into Ro5bert:master Oct 27, 2023
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