Constructor and Description |
---|
FirmataPin(FirmataDevice device,
byte index)
Constructs Firmata pin for the specified device.
|
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(PinEventListener listener)
Adds the specified listener to receive events from this pin.
|
FirmataDevice |
getDevice()
Return an
IODevice the pin belongs to. |
byte |
getIndex()
Returns the index of the pin on its device.
|
Pin.Mode |
getMode()
Returns current mode of the pin.
|
Set<Pin.Mode> |
getSupportedModes()
Returns a set of modes supported by the pin.
|
long |
getValue()
Returns current value of the pin.
|
void |
removeAllEventListeners()
Remove all listeners from this pin.
|
void |
removeEventListener(PinEventListener listener)
Removes the specified listener so that it no longer receives events from
this pin.
|
void |
setMode(Pin.Mode mode)
Assigns new mode to the pin.
|
void |
setValue(long value)
Sets the value to the pin.
|
boolean |
supports(Pin.Mode mode)
Checks if the pin supports the mode
|
public FirmataPin(FirmataDevice device, byte index)
device
- the device the pin belongs toindex
- the index of pin on the devicepublic FirmataDevice getDevice()
Pin
IODevice
the pin belongs to.public byte getIndex()
Pin
public Pin.Mode getMode()
Pin
public void setMode(Pin.Mode mode) throws IOException
Pin
setMode
in interface Pin
mode
- the mode the pin should get intoIOException
- when assigning is failed due a communication issuepublic boolean supports(Pin.Mode mode)
Pin
public Set<Pin.Mode> getSupportedModes()
Pin
getSupportedModes
in interface Pin
public long getValue()
Pin
public void setValue(long value) throws IOException, IllegalStateException
Pin
Pin.Mode.INPUT
or Pin.Mode.ANALOG
.setValue
in interface Pin
value
- the value to be assigned to the pinIOException
- when setting fails due a communication issueIllegalStateException
- when the pin is in input mode such as
Pin.Mode.INPUT
or Pin.Mode.ANALOG
.public void addEventListener(PinEventListener listener)
Pin
addEventListener
in interface Pin
listener
- the listenerpublic void removeEventListener(PinEventListener listener)
Pin
removeEventListener
in interface Pin
listener
- the listenerpublic void removeAllEventListeners()
Pin
removeAllEventListeners
in interface Pin
Copyright © 2017. All rights reserved.