Package com.pi4j.platform
Class PlatformManager
- java.lang.Object
-
- com.pi4j.platform.PlatformManager
-
public class PlatformManager extends Object
This class provides static methods to configure the Pi4J library's default platform. Pi4J supports the following platforms: RaspberryPi
- Author:
- Robert Savage (http://www.savagehomeautomation.com)
- See Also:
- https://pi4j.com/
-
-
Constructor Summary
Constructors Constructor Description PlatformManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static Platform
getDefaultPlatform()
Internal method to get the default platform.static Platform
getPlatform()
Get the selected system platform.static void
setPlatform(Platform platform)
Set the runtime platform for Pi4J to use.
-
-
-
Method Detail
-
getPlatform
public static Platform getPlatform()
Get the selected system platform. If a platform has not explicitly been set, then the default platform: 'RASPBERRY_PI' will be selected and returned.- Returns:
- selected platform
-
setPlatform
public static void setPlatform(Platform platform) throws PlatformAlreadyAssignedException
Set the runtime platform for Pi4J to use. This platform selection will be used to determine the default GPIO providers and I2C providers specific to the selected platform. A platform assignment can only be set once. If a second attempt to set a platform is attempted, the 'PlatformAlreadyAssignedException' will be thrown. Please note that platform assignment can be made automatically if you use a provider class prior to manually assigning a platform.- Parameters:
platform
- platform to assign- Throws:
PlatformAlreadyAssignedException
-
getDefaultPlatform
protected static Platform getDefaultPlatform()
Internal method to get the default platform. It will attempt to first get the platform using the 'PI4J_PLATFORM' environment variable, if the environment variable is not configured, then it will attempt to use the system property "pi4j.platform". If the system property is not found or the value is not legal, then return the default 'RASPBERRY_PI' platform.- Returns:
- default platform enumeration
-
-