Class GpioPin
java.lang.Object
com.codename1.hardware.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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intLeave the line's bias as the board configured it.static final intDisable internal pull resistors.static final intEnable the internal pull-down resistor.static final intEnable the internal pull-up resistor.static final intReport both transitions.static final intReport high-to-low transitions.static final intReport no edges.static final intReport low-to-high transitions. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases the line.getChip()The controller this line belongs to.intgetLine()The line offset within its controller.The listener set withsetListener(GpioListener), ornull.booleanisHigh()Reads the line level.booleanisOutput()truewhen the line was opened as an output.voidsetHigh(boolean value) Drives an output line.voidDelivers the edges this input was opened for tolon the event dispatch thread, or stops delivery whenlisnull.
-
Field Details
-
BIAS_DEFAULT
public static final int BIAS_DEFAULTLeave the line's bias as the board configured it.- See Also:
-
BIAS_DISABLED
public static final int BIAS_DISABLEDDisable internal pull resistors.- See Also:
-
BIAS_PULL_UP
public static final int BIAS_PULL_UPEnable the internal pull-up resistor.- See Also:
-
BIAS_PULL_DOWN
public static final int BIAS_PULL_DOWNEnable the internal pull-down resistor.- See Also:
-
EDGE_NONE
public static final int EDGE_NONEReport no edges.- See Also:
-
EDGE_RISING
public static final int EDGE_RISINGReport low-to-high transitions.- See Also:
-
EDGE_FALLING
public static final int EDGE_FALLINGReport high-to-low transitions.- See Also:
-
EDGE_BOTH
public static final int EDGE_BOTHReport both transitions.- See Also:
-
-
Method Details
-
getChip
The controller this line belongs to. -
getLine
public int getLine()The line offset within its controller. -
isOutput
public boolean isOutput()truewhen the line was opened as an output. -
isHigh
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
Drives an output line.
Throws
HardwareException: when the line is an input, closed, or the write fails
- Throws:
HardwareException
-
setListener
Delivers the edges this input was opened for to
lon the event dispatch thread, or stops delivery whenlisnull. 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
The listener set withsetListener(GpioListener), ornull. -
close
public void close()Releases the line. Further calls on this pin throw; closing twice is harmless.
-