Class PinInfo

  • Direct Known Subclasses:
    PwmPinInfo

    public class PinInfo
    extends Object

    Describe the various attributes of an individual General-Purpose Input/Output (GPIO) pin. GPIO pin functions include Digital Input / Output, PWM Output and Analog Input / Output.

    Always access instances of this class via the BoardPinInfo accessor methods rather than constructing instances yourself. For example, BoardPinInfo.getByGpioNumber(gpio) and BoardPinInfo.getByChipAndLineOffset(chip, lineOffset).

    A board has a number of headers, each header has a number of physical pins connected to it. For example, the Raspberry Pi model B has the main 40-pin J8 header as well as the 8-pin P5 header (that doesn't have header pins soldered by default). Non-GPIO pins such as Vcc and GND are also included for information purposes only.

    A pin has the following attributes:

    keyPrefix
    internal only attribute used by AbstractDeviceFactory when provisioning GPIO devices
    header
    the name of the board header to which this pin is attached
    physicalPin
    the physical header pin number
    deviceNumber
    the logical device GPIO number
    sysFsNumber
    typically the same as the GPIO / device number; can be different for PWM pins that are controlled via Linux sysfs
    chip
    the Linux GPIO chip number for this GPIO as defined by the Linux GPIO character device; see /sys/gpiochip<n>, run gpiodetect to list
    lineOffset
    the line number offset for this GPIO on the GPIO chip - Linux GPIO character device; run gpioinfo <n> to list
    name
    the name of this pin
    modes
    the set of valid modes for this pin
    • Method Detail

      • getKeyPrefix

        public String getKeyPrefix()
        Internal only attribute used by AbstractDeviceFactory when provisioning GPIO devices
        Returns:
        the key prefix for this pin
      • getHeader

        public String getHeader()
        Get the name of the board header to which this pin is attached
        Returns:
        the header name to which this pin is attached
      • getPhysicalPin

        public int getPhysicalPin()
        Get the physical header pin number
        Returns:
        the physical header pin number
      • getDeviceNumber

        public int getDeviceNumber()
        Get the logical device GPIO number
        Returns:
        the logical device GPIO number
      • getSysFsNumber

        public int getSysFsNumber()
        Get sysfs number for this pin. This is typically the same as the GPIO / device number; can be different for PWM pins that are controlled via Linux sysfs
        Returns:
        the sysfs number for this pin
      • getChip

        public int getChip()
        the Linux GPIO chip number for this GPIO as defined by the Linux GPIO character device; see /sys/gpiochip<n>, run gpiodetect to list
        Returns:
        the GPIO chip number for this pin
      • setChip

        public void setChip​(int chip)
        Internal method - do not call
        Parameters:
        chip - the GPIO chip number for this pin
      • getLineOffset

        public int getLineOffset()
        Get the line number offset for this GPIO on the GPIO chip - Linux GPIO character device; run gpioinfo <n> to list
        Returns:
        the GPIO line offset
      • setLineOffset

        public void setLineOffset​(int lineOffset)
        Internal method - do not call
        Parameters:
        lineOffset - the GPIO chip line offset number for this pin
      • getName

        public String getName()
        Get the name of this pin
        Returns:
        the name of this pin
      • isSupported

        public boolean isSupported​(DeviceMode mode)
        Check if the specified mode is supported by this pin
        Parameters:
        mode - the device mode to check
        Returns:
        true if the device mode is supported
      • isDigitalInputSupported

        public boolean isDigitalInputSupported()
      • isDigitalOutputSupported

        public boolean isDigitalOutputSupported()
      • isPwmOutputSupported

        public boolean isPwmOutputSupported()
      • isAnalogInputSupported

        public boolean isAnalogInputSupported()
      • isAnalogOutputSupported

        public boolean isAnalogOutputSupported()