Class GpioPin

java.lang.Object
com.codename1.hardware.GpioPin

public final class GpioPin extends Object

A claimed GPIO line, opened through Hardware.openGpioOutput(String, int, boolean) or Hardware.openGpioInput(String, int, int, int).

The line stays claimed until close(); another process cannot drive it in the meantime.

  • Field Details

    • BIAS_DEFAULT

      public static final int BIAS_DEFAULT
      Leave the line's bias as the board configured it.
      See Also:
    • BIAS_DISABLED

      public static final int BIAS_DISABLED
      Disable internal pull resistors.
      See Also:
    • BIAS_PULL_UP

      public static final int BIAS_PULL_UP
      Enable the internal pull-up resistor.
      See Also:
    • BIAS_PULL_DOWN

      public static final int BIAS_PULL_DOWN
      Enable the internal pull-down resistor.
      See Also:
    • EDGE_NONE

      public static final int EDGE_NONE
      Report no edges.
      See Also:
    • EDGE_RISING

      public static final int EDGE_RISING
      Report low-to-high transitions.
      See Also:
    • EDGE_FALLING

      public static final int EDGE_FALLING
      Report high-to-low transitions.
      See Also:
    • EDGE_BOTH

      public static final int EDGE_BOTH
      Report both transitions.
      See Also:
  • Method Details

    • getChip

      public String getChip()
      The controller this line belongs to.
    • getLine

      public int getLine()
      The line offset within its controller.
    • isOutput

      public boolean isOutput()
      true when the line was opened as an output.
    • isHigh

      public boolean isHigh() throws HardwareException

      Reads the line level. For an output this is the level it is driven to.

      Throws
      • HardwareException: when the read fails or the pin is closed
      Throws:
      HardwareException
    • setHigh

      public void setHigh(boolean value) throws HardwareException

      Drives an output line.

      Throws
      • HardwareException: when the line is an input, closed, or the write fails
      Throws:
      HardwareException
    • setListener

      public void setListener(GpioListener l) throws HardwareException

      Delivers the edges this input was opened for to l on the event dispatch thread, or stops delivery when l is null. Edges are waited for on a background thread owned by this pin.

      Throws
      • HardwareException: when the line is an output or closed
      Throws:
      HardwareException
    • getListener

      public GpioListener getListener()
      The listener set with setListener(GpioListener), or null.
    • close

      public void close()
      Releases the line. Further calls on this pin throw; closing twice is harmless.