Class GpioOutputPinDef

java.lang.Object
com.kosdev.kos.core.service.gpio.GpioPinBinding
com.kosdev.kos.core.service.gpio.GpioOutputPinDef

public class GpioOutputPinDef extends GpioPinBinding
Definition of a GPIO output pin. A pin is defined as a combination of a GPIO chip and a pin on that chip. See GpioPinBinding for details about how to specify the chip and pin number.

Output pins support a number of confuration options which are specified in the pin definition and supplied at the time the pin is created.

Since:
9
Version:
9
  • Constructor Details

    • GpioOutputPinDef

      public GpioOutputPinDef()
  • Method Details

    • getChipName

      public String getChipName()
      Return the chip name if set.
      Since:
      9
    • setChipName

      public GpioOutputPinDef setChipName(String name)
      Set the name of the chip to bind to. If set, this pin will only bind to a gpio chip with this name. Running on different with different chip names will prevent this pin from accidentally binding to an unexpected chip as it would when bound by chip number.
      Parameters:
      name - name of the gpio chip as returned by the kernel
      Since:
      9
    • getChipNum

      public Integer getChipNum()
      Return the chip number if set.
      Since:
      9
    • setChipNum

      public GpioOutputPinDef setChipNum(Integer num)
      Set the number of the chip to bind to. If set, this pin will unconditionally bind to the gpio chip with this number, assuming one exists. If running on different hardware, this pin will still bind to the chip with this number and may result in unexpected behavior due to different gpio mappings on different boards. Consider using chip name to only bind to a specific gpio chip.

      If name and number are both set, only name will be used.

      Parameters:
      num - the chip number to use
      Since:
      9
    • getPinName

      public String getPinName()
      Return the pin name if set.
      Since:
      9
    • setPinName

      public GpioOutputPinDef setPinName(String name)
      Set the name of the pin to bind to. This is the name of the pin on the selected chip as defined by the kernel. By binding to a chip and pin by name, it avoids the case where code running on different hardware accidentally uses gpio pins incorrectly for that hardware.

      It is common to bind to a chip by name and pin by number. However binding to pin by name provides insight into which pin is being used as pin names are relative to the chip, no the header the pins are exposed though.

      Parameters:
      name - the pin name to use
      Since:
      9
    • getPinNum

      public Integer getPinNum()
      Return the pin number if set.
      Since:
      9
    • setPinNum

      public GpioOutputPinDef setPinNum(Integer num)
      Set the number of the pin to bind to. If set, unconditionally bind to this pin number of the bound chip. If both pin name and number are set, only the pin name will be used.

      Pin numbers are relative to the associated chip as defined by the kernel. These do not necessarily correspond to positions on an external header.

      Parameters:
      num - the pin number to use
      Since:
      9
    • isInverted

      public boolean isInverted()
      Return the value of the inverted flag. When true, all pin values will be inverted internally. This can be used to handle active high vs active low configurations.
      Since:
      9
    • setInverted

      public GpioOutputPinDef setInverted(boolean inverted)
      Set the inverted flag. When set to true, all pin values will be inverted between this interface and actual hardware.
      Parameters:
      inverted - if true, invert pin values
      Since:
      9
    • getDrive

      public GpioOutputPinDef.Drive getDrive()
      Return the drive of the output pin.
      Since:
      9
    • setDrive

      public GpioOutputPinDef setDrive(GpioOutputPinDef.Drive drive)
      Set the drive of the output pin. By default the pin is push-pull, but it can be configured to open-source or open-drain if the hardware supports it.
      Parameters:
      drive - the drive for the output pin
      Since:
      9