Added LineHelper for non-Raspberry Pi-boards - #696
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR extends LineHelper to support GPIO bank/line addressing for non-Allwinner SoC families (notably NVIDIA Tegra) by introducing a family-aware API while keeping existing callers working via an Allwinner default.
Changes:
- Added
GpioLineFamilyenum to define lines-per-bank for supported SoC GPIO families (ALLWINNER=32, TEGRA=8). - Introduced
LineHelper.getAddress(...)overloads that acceptGpioLineFamily, and deprecatedLineHelper.LINES_PER_BANKin favor of the enum. - Expanded unit tests to cover Tegra addressing and the family-aware overloads.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pi4j-core/src/main/java/com/pi4j/boardinfo/util/LineHelper.java | Adds family-aware overloads and routes existing API through ALLWINNER default; deprecates LINES_PER_BANK. |
| pi4j-core/src/main/java/com/pi4j/boardinfo/util/GpioLineFamily.java | Introduces SoC family enum defining lines-per-bank used by LineHelper. |
| pi4j-core/src/test/java/com/pi4j/boardinfo/util/LineHelperTest.java | Adds coverage for Allwinner-via-family and Tegra bank/line addressing + range checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * or the resulting offset would overflow {@code int} | ||
| */ | ||
| public static int getAddress(GpioLineFamily family, int bank, int line) { | ||
| int linesPerBank = family.getLinesPerBank(); |
| * @throws IllegalArgumentException if {@code bank} is not a letter or {@code line} is not in {@code 0}-{@code 31} | ||
| * @throws IllegalArgumentException if {@code bank} is not a letter or {@code line} is out of range | ||
| */ | ||
| public static int getAddress(char bank, int line) { |
There was a problem hiding this comment.
Are we sure the letters map the same for all chips?
| * or the resulting offset would overflow {@code int} | ||
| */ | ||
| public static int getAddress(int bank, int line) { | ||
| return getAddress(GpioLineFamily.ALLWINNER, bank, line); |
There was a problem hiding this comment.
Why stick to static instead of handing in the count / chip to a ctor?
Isn't it likely that multiple gpios will be created for the same chip?
For backwards compat (if desired?) just deprecate the existing static methods?



Related to #695
Draft extending LineHelper to support more GPIO interfaces