From d2c81646ac76452d6f391b9410f32712e11cf5f2 Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Wed, 24 Apr 2024 14:08:07 +0200 Subject: [PATCH] Added board info output --- pom.xml | 16 +++++++++++++++- .../java/com/pi4j/example/MinimalExample.java | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6b8e3e..89238d1 100644 --- a/pom.xml +++ b/pom.xml @@ -22,13 +22,27 @@ 2.0.12 - 2.5.1 + 2.6.0-SNAPSHOT 1.6.0 3.8.1 + + + oss-snapshots-repo + Sonatype OSS Maven Repository + https://oss.sonatype.org/content/groups/public + + false + + + true + + + + org.slf4j diff --git a/src/main/java/com/pi4j/example/MinimalExample.java b/src/main/java/com/pi4j/example/MinimalExample.java index 157547f..62b38b4 100644 --- a/src/main/java/com/pi4j/example/MinimalExample.java +++ b/src/main/java/com/pi4j/example/MinimalExample.java @@ -28,6 +28,7 @@ */ import com.pi4j.Pi4J; +import com.pi4j.boardinfo.util.BoardInfoHelper; import com.pi4j.io.gpio.digital.DigitalInput; import com.pi4j.io.gpio.digital.DigitalState; import com.pi4j.io.gpio.digital.PullResistance; @@ -101,6 +102,24 @@ public static void main(String[] args) throws Exception { PrintInfo.printDefaultPlatform(console, pi4j); PrintInfo.printProviders(console, pi4j); + // ------------------------------------------------------------ + // Output Pi4J Board information + // ------------------------------------------------------------ + // When the Pi4J Context is initialized, a board detection is + // performed. You can use this info in case you need board-specific + // functionality. + // OPTIONAL + console.println("Board model: " + pi4j.boardInfo().getBoardModel().getLabel()); + console.println("Operating system: " + pi4j.boardInfo().getOperatingSystem()); + console.println("Java versions: " + pi4j.boardInfo().getJavaInfo()); + // This info is also available directly from the BoardInfoHelper, + // and with some additional realtime data. + console.println("Board model: " + BoardInfoHelper.current().getBoardModel().getLabel()); + console.println("Raspberry Pi model with RP1 chip (Raspberry Pi 5): " + BoardInfoHelper.usesRP1()); + console.println("OS is 64-bit: " + BoardInfoHelper.is64bit()); + console.println("JVM memory used (MB): " + BoardInfoHelper.getJvmMemory().getUsedInMb()); + console.println("Board temperature (°C): " + BoardInfoHelper.getBoardReading().getTemperatureInCelsius()); + // Here we will create the I/O interface for a LED with minimal code. var led = pi4j.digitalOutput().create(PIN_LED);