|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sentilla.platform.tmote.Action
com.sentilla.platform.tmote.DigitalPin
public class DigitalPin
An object representation of a digital input/output pin for the Tmote platform.
Creates an action of a specific unit of digital input/output. The action
verbs are read
and write
. Its
setters are setWrite
and setRead
. Its
main getter is getValue
. Its auxiliary getter
getId
returns the identifier of a particular digital
input/output pin. And getTime
provides a marker of when the
input/output operation occured.
NOTE: DigitalPin objects should be created by the DigitalPinDriver factory.
This instance is specific to the Tmote platform.
DigitalPinDriver
Field Summary | |
---|---|
protected byte |
digitalPinCmd
The Action command for this DigitalPin object. |
protected byte |
digitalPinId
The digital pin id for this DigitalPin object. |
protected byte |
digitalPinPortmask
The portmask to use for port-wise read/write operations. |
protected int |
digitalPinTime
The time that the last operation completed. |
protected byte |
digitalPinValue
The value of the digital pin after the last operation. |
protected static byte |
EDGE_CHANGE
Action identifier for interrupt operations (implemented by InterruptPin) |
protected static byte |
EDGE_FALLING
Action identifier for interrupt operations (implemented by InterruptPin) |
protected static byte |
EDGE_RISING
Action identifier for interrupt operations (implemented by InterruptPin) |
protected static byte |
GET_PORT
Action identifier for initiating a port read operation |
protected static byte |
GET_VALUE
Action identifier for initiating a read operation |
protected static byte |
SET_PORT
Action identifier for initiating a port write operation |
protected static byte |
SET_VALUE
Action identifier for initiating a write operation |
Fields inherited from class com.sentilla.platform.tmote.Action |
---|
actionAuto, actionId, actionState, isolateOwner |
Fields inherited from interface com.sentilla.system.Action |
---|
DONE, ERROR, IDLE, PENDING |
Constructor Summary | |
---|---|
DigitalPin(int id)
Create an object to read and write the values of a digital input/output pin. |
Method Summary | |
---|---|
protected boolean |
checkId(int id)
Checks that the Id is within bounds for this platform. |
int |
getId()
Asynchronous interface to get the pin id for this DigitalPin object. |
int |
getTime()
Asynchronous interface to get the time that the last operation, read or write, occured. |
boolean |
getValue()
Asynchronous interface to get the last value read from or written to the digital pin. |
boolean |
read()
Read the value of a specified digital pin. |
boolean |
read(int id)
Read the value of a specified digital pin. |
byte |
readPort(byte portmask)
|
void |
setId(int id)
Asynchronous interface to set the pin id for this DigitalPin object. |
DigitalPin |
setRead()
Asynchronous interface to initiate a read operation. |
DigitalPin |
setWrite(boolean high)
Asynchronous interface to initiate a write operation. |
void |
write(boolean high)
Write a value to a specified digital pin. |
void |
write(int id,
boolean high)
Write a value to a specified digital pin. |
void |
writePort(byte portmask,
byte value)
Write the values of only a subset of pins of a port. |
Methods inherited from class com.sentilla.platform.tmote.Action |
---|
block, block, cancel, getActionState, initAction, isDone, lookup, submit |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.sentilla.system.Action |
---|
block, block, cancel, getActionState, isDone, submit |
Field Detail |
---|
protected static final byte SET_VALUE
protected static final byte GET_VALUE
protected static final byte EDGE_FALLING
InterruptPin
,
Constant Field Valuesprotected static final byte EDGE_RISING
InterruptPin
,
Constant Field Valuesprotected static final byte EDGE_CHANGE
InterruptPin
,
Constant Field Valuesprotected static final byte SET_PORT
protected static final byte GET_PORT
protected byte digitalPinId
protected byte digitalPinCmd
protected byte digitalPinValue
protected byte digitalPinPortmask
protected int digitalPinTime
Constructor Detail |
---|
public DigitalPin(int id)
id is specified by port and pin value in hex. For example, Port 2, Pin 3 is represented by id 0x23.
id
- The digital pin identifier
IllegalArgumentException
- when the given id does not exist on the tmote platformMethod Detail |
---|
protected boolean checkId(int id)
id
- Pin identity to check
public void write(int id, boolean high)
read()
and
write()
operations will use the new pin id.
The write operation sets the pin in output mode and the pin remains in this mode after the write operation completes.
id is specified by port and pin value in hex. For example, Port 2, Pin 3 is represented by id 0x23.
id
- The digital pin identifier.high
- true to set the pin high, false to set the pin lowpublic void write(boolean high)
DigitalPin
The write operation sets the pin in output mode and the pin remains in this mode after the write operation completes.
write
in interface DigitalPin
high
- true to set the pin high, false to set the pin lowpublic boolean read(int id)
read()
and
write()
operations will use the new pin id.
The read operation is also used to set the pin to input mode.
The value of the pin may be ignored if read()
is
used to set the direction of the pin to input.
id is specified by port and pin value in hex. For example, Port 2, Pin 3 is represented by id 0x23.
id
- The digital pin identifier.
public boolean read()
DigitalPin
The read operation is also used to set the pin to input mode.
The value of the pin may be ignored if read()
is
used to set the direction of the pin to input.
read
in interface DigitalPin
public void writePort(byte portmask, byte value)
DigitalPin
The portmask designates a subset of the pins that need to be changed (set to 1). The subset pins are set bit-to-bit.
writePort
in interface DigitalPin
portmask
- mask of the pins that should be changedvalue
- specifies the values of the pinspublic byte readPort(byte portmask)
public DigitalPin setWrite(boolean high)
DigitalPin
Prepares the Action to write a value but does not initiate the write operation
until submit()
is called.
setWrite
in interface DigitalPin
high
- true to set the pin high, false to set the pin low
public DigitalPin setRead()
DigitalPin
Prepares the Action to read a value but does not initiate the read operation
until submit()
is called.
setRead
in interface DigitalPin
public boolean getValue()
DigitalPin
This function will not initiate a read or write operation.
getValue
in interface DigitalPin
public void setId(int id)
id is specified by port and pin value in hex. For example, Port 2, Pin 3 is represented by id 0x23.
id
- The digital pin identifierpublic int getId()
DigitalPin
id is specified by port and pin value in hex. For example, Port 2, Pin 3 is represented by id 0x23.
getId
in interface DigitalPin
public int getTime()
DigitalPin
getTime
in interface DigitalPin
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |