Skip to content

Commit 7c8ae9d

Browse files
committed
Extra info about setBoardModel
1 parent 465d615 commit 7c8ae9d

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

content/documentation/board-info.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,50 @@ console.println("Throttled states description: " + BoardInfoHelper.getBoardReadi
9999
[main] INFO com.pi4j.util.Console - - UNDERVOLTAGE_DETECTED
100100
[main] INFO com.pi4j.util.Console - - SOFT_TEMPERATURE_LIMIT_ACTIVE
101101
[main] INFO com.pi4j.util.Console - Throttled states description: Under-voltage detected, Soft temperature limit active
102-
```
102+
```
103+
104+
## Overriding the Detected Board
105+
106+
In case the detected board is wrong or unknown, you can override it since V3.0.1 with the following method. Make sure to do this before the Pi4J context is initialized, so the correct plugins are loaded.
107+
108+
```java
109+
// With default GpioD chip
110+
BoardInfoHelper.current().setBoardModel(BoardModel.GENERIC);
111+
var pi4j = Pi4J.newAutoContext();
112+
113+
// Or if you want to use a specific chip name
114+
BoardInfoHelper.current().setBoardModel(BoardModel.GENERIC);
115+
var pi4j = Pi4J.newContextBuilder()
116+
.add(GpioDDigitalInputProvider.newInstance())
117+
.setGpioChipName("gpiochip2")
118+
.build();
119+
```
120+
121+
Two generic boards where created for this use-case, but of course, you can also use one of the other [BoardModel](https://github.com/Pi4J/pi4j/blob/develop/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java) enum values.
122+
123+
```java
124+
// Generic model, this can be used to force the library
125+
// to load Raspberry Pi plugins on other board types
126+
GENERIC("Generic board compatible with Raspberry Pi 4", SINGLE_BOARD_COMPUTER,
127+
new ArrayList<>(),
128+
PiModel.MODEL_B,
129+
HeaderVersion.TYPE_3,
130+
LocalDate.now(),
131+
Soc.UNKNOWN,
132+
Cpu.UNKNOWN, 4,
133+
new ArrayList<>(),
134+
new ArrayList<>()),
135+
GENERIC_RP1("Generic board compatible with Raspberry Pi 5", SINGLE_BOARD_COMPUTER,
136+
new ArrayList<>(),
137+
PiModel.MODEL_B,
138+
HeaderVersion.TYPE_3,
139+
LocalDate.now(),
140+
Soc.UNKNOWN,
141+
Cpu.UNKNOWN, 4,
142+
new ArrayList<>(),
143+
new ArrayList<>(),
144+
new ArrayList<>(),
145+
true),
146+
```
147+
148+

0 commit comments

Comments
 (0)