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
-
Field Summary
Fields Modifier and Type Field Description static EnumSet<DeviceMode>
ANALOG_INPUT
static EnumSet<DeviceMode>
ANALOG_OUTPUT
static String
DEFAULT_HEADER
static EnumSet<DeviceMode>
DIGITAL_ANALOG_INPUT
static EnumSet<DeviceMode>
DIGITAL_IN
static EnumSet<DeviceMode>
DIGITAL_IN_OUT
static EnumSet<DeviceMode>
DIGITAL_IN_OUT_PWM
static EnumSet<DeviceMode>
DIGITAL_OUT
static EnumSet<DeviceMode>
DIGITAL_PWM_OUTPUT
static String
GROUND
static int
NOT_DEFINED
static EnumSet<DeviceMode>
PWM_OUTPUT
static String
VCC_3V3
static String
VCC_5V
-
Constructor Summary
Constructors Constructor Description PinInfo(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes)
PinInfo(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes, int sysFsNumber, int chip, int line)
-
Method Summary
Modifier and Type Method Description int
getChip()
the Linux GPIO chip number for this GPIO as defined by the Linux GPIO character device; see /sys/gpiochip<n>, rungpiodetect
to listint
getDeviceNumber()
Get the logical device GPIO numberString
getHeader()
Get the name of the board header to which this pin is attachedString
getKeyPrefix()
Internal only attribute used byAbstractDeviceFactory
when provisioning GPIO devicesint
getLineOffset()
Get the line number offset for this GPIO on the GPIO chip - Linux GPIO character device;run gpioinfo <n>
to listCollection<DeviceMode>
getModes()
Get the set of validmodes
for this pinString
getName()
Get the name of this pinint
getPhysicalPin()
Get the physical header pin numberint
getSysFsNumber()
Get sysfs number for this pin.boolean
isAnalogInputSupported()
boolean
isAnalogOutputSupported()
boolean
isDigitalInputSupported()
boolean
isDigitalOutputSupported()
boolean
isPwmOutputSupported()
boolean
isSupported(DeviceMode mode)
Check if the specifiedmode
is supported by this pinvoid
setChip(int chip)
Internal method - do not callvoid
setLineOffset(int lineOffset)
Internal method - do not callString
toString()
-
Field Details
-
DIGITAL_IN
-
DIGITAL_OUT
-
DIGITAL_IN_OUT
-
DIGITAL_IN_OUT_PWM
-
PWM_OUTPUT
-
DIGITAL_PWM_OUTPUT
-
DIGITAL_ANALOG_INPUT
-
ANALOG_INPUT
-
ANALOG_OUTPUT
-
NOT_DEFINED
public static final int NOT_DEFINED- See Also:
- Constant Field Values
-
DEFAULT_HEADER
- See Also:
- Constant Field Values
-
GROUND
- See Also:
- Constant Field Values
-
VCC_5V
- See Also:
- Constant Field Values
-
VCC_3V3
- See Also:
- Constant Field Values
-
-
Constructor Details
-
PinInfo
public PinInfo(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes) -
PinInfo
public PinInfo(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes, int sysFsNumber, int chip, int line)
-
-
Method Details
-
getKeyPrefix
Internal only attribute used byAbstractDeviceFactory
when provisioning GPIO devices- Returns:
- the key prefix for this pin
-
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>, rungpiodetect
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
Get the name of this pin- Returns:
- the name of this pin
-
getModes
Get the set of validmodes
for this pin- Returns:
- the set of valid
modes
for this pin
-
isSupported
Check if the specifiedmode
is supported by this pin- Parameters:
mode
- thedevice 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() -
toString
-