Skip to content

Commit

Permalink
Added board info output
Browse files Browse the repository at this point in the history
  • Loading branch information
FDelporte committed Apr 24, 2024
1 parent a5d5112 commit d2c8164
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,27 @@

<!-- DEPENDENCIES VERSIONS -->
<slf4j.version>2.0.12</slf4j.version>
<pi4j.version>2.5.1</pi4j.version>
<pi4j.version>2.6.0-SNAPSHOT</pi4j.version>

<!-- BUILD PLUGIN VERSIONS -->
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
</properties>

<repositories>
<repository>
<id>oss-snapshots-repo</id>
<name>Sonatype OSS Maven Repository</name>
<url>https://oss.sonatype.org/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/pi4j/example/MinimalExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit d2c8164

Please sign in to comment.