com.sentilla.system
Interface DigitalPin

All Superinterfaces:
Action
All Known Subinterfaces:
InterruptPin

public interface DigitalPin
extends Action

An object representation of a digital input/output pin on a microprocessor.

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.

DigitalPin objects should be created by the DigitalPinDriver factory.

See Also:
DigitalPinDriver

Field Summary
 
Fields inherited from interface com.sentilla.system.Action
DONE, ERROR, IDLE, PENDING
 
Method Summary
 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.
 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 writePort(byte portmask, byte value)
          Write the values of only a subset of pins of a port.
 
Methods inherited from interface com.sentilla.system.Action
block, block, cancel, getActionState, isDone, submit
 

Method Detail

write

void write(boolean high)
Write a value to a specified digital pin. The pin identity is specified at object creation by the factory.

The write operation sets the pin in output mode and the pin remains in this mode after the write operation completes.

Parameters:
high - true to set the pin high, false to set the pin low

read

boolean read()
Read the value of a specified digital pin. The pin identity is specified at object creation by the factory.

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.

Returns:
true if the pin is high, false if the pin is low

writePort

void writePort(byte portmask,
               byte value)
Write the values of only a subset of pins of a port. The port identity is specified at object creation by the factory.

The portmask designates a subset of the pins that need to be changed (set to 1). The subset pins are set bit-to-bit.

Parameters:
portmask - mask of the pins that should be changed
value - specifies the values of the pins

setWrite

DigitalPin setWrite(boolean high)
Asynchronous interface to initiate a write operation.

Prepares the Action to write a value but does not initiate the write operation until submit() is called.

Parameters:
high - true to set the pin high, false to set the pin low
Returns:
The DigitalPin object that has been set to the specified state

setRead

DigitalPin setRead()
Asynchronous interface to initiate a read operation.

Prepares the Action to read a value but does not initiate the read operation until submit() is called.

Returns:
The DigitalPin object that has been set to the specified state

getValue

boolean getValue()
Asynchronous interface to get the last value read from or written to the digital pin.

This function will not initiate a read or write operation.

Returns:
true if the value was high, false if it was low

getId

int getId()
Asynchronous interface to get the pin id for this DigitalPin object.

id is specified by port and pin value in hex. For example, Port 2, Pin 3 is represented by id 0x23.

Returns:
id The digital pin identifier

getTime

int getTime()
Asynchronous interface to get the time that the last operation, read or write, occured.

Returns:
the local system time in milliseconds


Copyright © 2007 Sentilla Corporation. All Rights Reserved.