Skip to content

Commit 079127d

Browse files
Frank Delporteeitch
authored andcommitted
Better definition of usesRP1
1 parent 40b2fbb commit 079127d

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public enum BoardModel {
6666
Cpu.ARM1176JZF_S, 1,
6767
List.of(700),
6868
List.of(256 * 1024, 512 * 1024),
69-
List.of("Amount of memory changed to 512Mb on 20160810")),
69+
List.of("Amount of memory changed to 512Mb on 20160810"),
70+
false),
7071
MODEL_3_A_PLUS("Raspberry Pi 3 Model A+", SINGLE_BOARD_COMPUTER,
7172
List.of("9020e0", "9020e1"),
7273
PiModel.MODEL_A,
@@ -75,7 +76,9 @@ public enum BoardModel {
7576
Soc.BCM2837B0,
7677
Cpu.CORTEX_A53, 4,
7778
List.of(1400),
78-
List.of(512 * 1024)),
79+
List.of(512 * 1024),
80+
new ArrayList<>(),
81+
false),
7982
MODEL_1_B("Raspberry Pi 1 Model B", SINGLE_BOARD_COMPUTER,
8083
List.of("0002", "0003", "0004", "0005", "0006", "000d", "000e", "000f"),
8184
PiModel.MODEL_B,
@@ -85,7 +88,8 @@ public enum BoardModel {
8588
Cpu.ARM1176JZF_S, 1,
8689
List.of(700),
8790
List.of(256 * 1024, 512 * 1024),
88-
List.of("Amount of memory changed to 512Mb on 20121015")),
91+
List.of("Amount of memory changed to 512Mb on 20121015"),
92+
false),
8993
MODEL_1_B_PLUS("Raspberry Pi 1 Model B+", SINGLE_BOARD_COMPUTER,
9094
List.of("0010", "0013", "900032"),
9195
PiModel.MODEL_B,
@@ -157,7 +161,9 @@ public enum BoardModel {
157161
Soc.BCM2712,
158162
Cpu.CORTEX_A76, 4,
159163
List.of(2400),
160-
List.of(2048 * 1024, 4096 * 1024, 8192 * 1024, 16384 * 1024)),
164+
List.of(2048 * 1024, 4096 * 1024, 8192 * 1024, 16384 * 1024),
165+
new ArrayList<>(),
166+
true),
161167
MODEL_500("Raspberry Pi 500", ALL_IN_ONE_COMPUTER,
162168
List.of("d04190"),
163169
PiModel.MODEL_B,
@@ -169,7 +175,8 @@ public enum BoardModel {
169175
List.of(8192 * 1024),
170176
List.of(
171177
"20241209: Confirmed by Jeff Geerling who has evaluation version: d04190."
172-
)),
178+
),
179+
true),
173180
COMPUTE_1("Compute Module 1", STACK_ON_COMPUTER,
174181
List.of("0011", "0014", "900061"),
175182
PiModel.COMPUTE,
@@ -231,7 +238,8 @@ public enum BoardModel {
231238
"20241129: Confirmed by Jeff Geerling who has evaluation version: c04180 for the 4Gb version.",
232239
"When compared with Compute 4, we can assume the other boards should have be a, b, d.",
233240
"Will be further completed or modified when more info is available."
234-
)),
241+
),
242+
true),
235243
ZERO_PCB_1_2("Raspberry Pi Zero PCB V1.2", SINGLE_BOARD_COMPUTER,
236244
List.of("900092", "920092"),
237245
PiModel.ZERO,
@@ -286,7 +294,8 @@ public enum BoardModel {
286294
Cpu.CORTEX_MO_PLUS, 1,
287295
List.of(133),
288296
List.of(264 + 2048),
289-
List.of("Same form factor as PICO but with Wi-Fi")),
297+
List.of("Same form factor as PICO but with Wi-Fi"),
298+
false),
290299
PICO_2("Raspberry Pi Pico 2", MICROCONTROLLER,
291300
new ArrayList<>(),
292301
PiModel.PICO,
@@ -324,7 +333,9 @@ public enum BoardModel {
324333
Soc.UNKNOWN,
325334
Cpu.UNKNOWN, 4,
326335
new ArrayList<>(),
327-
new ArrayList<>()),
336+
new ArrayList<>(),
337+
new ArrayList<>(),
338+
true),
328339
// Unknown model
329340
UNKNOWN("Unknown", BoardType.UNKNOWN,
330341
new ArrayList<>(),
@@ -350,6 +361,7 @@ public enum BoardModel {
350361
private final List<Integer> versionsProcessorSpeedInMhz;
351362
private final List<Integer> versionsMemoryInKb;
352363
private final List<String> remarks;
364+
private final Boolean usesRP1;
353365

354366
/**
355367
* Constructor for creating a {@code BoardModel} without remarks.
@@ -371,7 +383,7 @@ public enum BoardModel {
371383
Soc soc, Cpu cpu, Integer numberOfCpu,
372384
List<Integer> versionsProcessorSpeedInMhz, List<Integer> versionsMemoryInKb) {
373385
this(label, boardType, boardCodes, model, headerVersion, releaseDate, soc, cpu, numberOfCpu,
374-
versionsProcessorSpeedInMhz, versionsMemoryInKb, new ArrayList<>());
386+
versionsProcessorSpeedInMhz, versionsMemoryInKb, new ArrayList<>(), false);
375387
}
376388

377389
/**
@@ -389,12 +401,14 @@ public enum BoardModel {
389401
* @param versionsProcessorSpeedInMhz list of processor speeds in MHz
390402
* @param versionsMemoryInKb list of memory sizes in KB
391403
* @param remarks any remarks or notes about the board
404+
* @param usesRP1 board contains the RP1 chip to control GPIOs
392405
*/
393406
BoardModel(String label, BoardType boardType, List<String> boardCodes,
394407
PiModel model, HeaderVersion headerVersion, LocalDate releaseDate,
395408
Soc soc, Cpu cpu, Integer numberOfCpu,
396409
List<Integer> versionsProcessorSpeedInMhz, List<Integer> versionsMemoryInKb,
397-
List<String> remarks) {
410+
List<String> remarks,
411+
Boolean usesRP1) {
398412
this.label = label;
399413
this.boardType = boardType;
400414
this.boardCodes = boardCodes;
@@ -407,6 +421,7 @@ public enum BoardModel {
407421
this.versionsProcessorSpeedInMhz = versionsProcessorSpeedInMhz;
408422
this.versionsMemoryInKb = versionsMemoryInKb;
409423
this.remarks = remarks;
424+
this.usesRP1 = usesRP1;
410425
}
411426

412427
/**
@@ -561,4 +576,11 @@ public List<Float> getVersionsMemoryInGb() {
561576
public List<String> getRemarks() {
562577
return remarks;
563578
}
579+
580+
/**
581+
* @return board contains the RP1 chip to control GPIOs
582+
*/
583+
public boolean usesRP1() {
584+
return usesRP1;
585+
}
564586
}

pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ private BoardInfo detectBoardInfo(OperatingSystem os, JavaInfo java) {
173173
* @return {@code true} if the board is a Raspberry Pi Model 5B, otherwise {@code false}.
174174
*/
175175
public static boolean usesRP1() {
176-
return current().getBoardModel() == BoardModel.MODEL_5_B
177-
|| current().getBoardModel() == BoardModel.MODEL_500
178-
|| current().getBoardModel() == BoardModel.GENERIC_RP1;
176+
return current().getBoardModel().usesRP1();
179177
}
180178

181179
/**

pi4j-core/src/test/java/com/pi4j/boardinfo/model/ModelTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ void testMemoryParsing() {
6262
);
6363
}
6464

65+
@Test
66+
void testRP1() {
67+
assertAll(
68+
() -> assertFalse(BoardModel.MODEL_1_B.usesRP1(), "MODEL_1_B"),
69+
() -> assertTrue(BoardModel.MODEL_5_B.usesRP1(), "MODEL_5_B"),
70+
() -> assertTrue(BoardModel.MODEL_500.usesRP1(), "MODEL_500"),
71+
() -> assertTrue(BoardModel.COMPUTE_5.usesRP1(), "COMPUTE_5"),
72+
() -> assertFalse(BoardModel.GENERIC.usesRP1(), "GENERIC"),
73+
() -> assertTrue(BoardModel.GENERIC_RP1.usesRP1(), "GENERIC_RP1")
74+
);
75+
}
76+
6577
@Test
6678
void testBoardModelOverwrite() {
6779
var boardInfo = BoardInfoHelper.current();

0 commit comments

Comments
 (0)