Skip to content

Commit

Permalink
BoardInfo logging
Browse files Browse the repository at this point in the history
  • Loading branch information
FDelporte committed May 27, 2024
1 parent bdc8b04 commit 865ed30
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import com.pi4j.Pi4J;
import com.pi4j.boardinfo.definition.BoardModel;
import com.pi4j.boardinfo.definition.HeaderPins;
import com.pi4j.boardinfo.util.BoardInfoHelper;
import com.pi4j.context.Context;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;

import java.util.Arrays;
Expand All @@ -13,10 +16,22 @@
@Service
public class Pi4JInfoService {

private static final Logger logger = LogManager.getLogger(Pi4JInfoService.class);

private final Context pi4j;

public Pi4JInfoService() {
this.pi4j = Pi4J.newAutoContext();

logger.info("Board model: {}", pi4j.boardInfo().getBoardModel().getLabel());
logger.info("Operating system: {}", pi4j.boardInfo().getOperatingSystem());
logger.info("Java versions: {}", pi4j.boardInfo().getJavaInfo());

logger.info("Board model: {}", BoardInfoHelper.current().getBoardModel().getLabel());
logger.info("Raspberry Pi model with RP1 chip (Raspberry Pi 5): {}", BoardInfoHelper.usesRP1());
logger.info("OS is 64-bit: {}", BoardInfoHelper.is64bit());
logger.info("JVM memory used (MB): {}", BoardInfoHelper.getJvmMemory().getUsedInMb());
logger.info("Board temperature (°C): {}", BoardInfoHelper.getBoardReading().getTemperatureInCelsius());
}

public Context getPi4JContext() {
Expand Down

0 comments on commit 865ed30

Please sign in to comment.