Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class GpioPin

  1. Object
  2. GpioPin

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.

Fields

public static final int BIAS_DEFAULT = 0Leave the line’s bias as the board configured it.
public static final int BIAS_DISABLED = 1Disable internal pull resistors.
public static final int BIAS_PULL_UP = 2Enable the internal pull-up resistor.
public static final int BIAS_PULL_DOWN = 3Enable the internal pull-down resistor.
public static final int EDGE_NONE = 0Report no edges.
public static final int EDGE_RISING = 1Report low-to-high transitions.
public static final int EDGE_FALLING = 2Report high-to-low transitions.
public static final int EDGE_BOTH = 3Report both transitions.

Methods

public String getChip()The controller this line belongs to.
public int getLine()The line offset within its controller.
public boolean isOutput()true when the line was opened as an output.
public boolean isHigh() throws HardwareExceptionReads the line level.
public void setHigh(boolean value) throws HardwareExceptionDrives an output line.
public void setListener(GpioListener l) throws HardwareExceptionDelivers the edges this input was opened for to l on the event dispatch thread, or stops delivery when l is null.
public GpioListener getListener()The listener set with setListener(GpioListener), or null.
public void close()Releases the line.

Inherited methods

Field details

BIAS_DEFAULT

public static final int BIAS_DEFAULT = 0
Leave the line’s bias as the board configured it.

BIAS_DISABLED

public static final int BIAS_DISABLED = 1
Disable internal pull resistors.

BIAS_PULL_UP

public static final int BIAS_PULL_UP = 2
Enable the internal pull-up resistor.

BIAS_PULL_DOWN

public static final int BIAS_PULL_DOWN = 3
Enable the internal pull-down resistor.

EDGE_NONE

public static final int EDGE_NONE = 0
Report no edges.

EDGE_RISING

public static final int EDGE_RISING = 1
Report low-to-high transitions.

EDGE_FALLING

public static final int EDGE_FALLING = 2
Report high-to-low transitions.

EDGE_BOTH

public static final int EDGE_BOTH = 3
Report both transitions.

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

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

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

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.