Class PlatformManager

    • Constructor Detail

      • PlatformManager

        public PlatformManager()
    • 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