|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GPIOPin
Interface for GPIO pin.
Application can access each GPIO pin through this interface. Each GPIO pin has its own ID. ID is integer value. Application can obtain value of current GPIO pin by usinggetValue()
method and set specific value to GPIO pin by using
setValue(boolean)
method.
Hint may be used for getting more detailed information about given GPIO pin.
For example, If button for toggling LED is attached to "pin10".
then OEM can assign hint as "LED switch". this can be used for generating
more readable source code.
Application can read value from pin by using polling. but event driven way
(interrupt) is also supported by registering listener for GPIO pin.In order
to use interrupt. first, application implement
PinListener
and then register it with setInputListener()
method. then notification begins. application can stop notification and remove
listener by calling removeInputListener()
.Listener can be set
just only for input pin.this means interrupt is only supported by input pins.
If try to set listener to output pins then it will get InvalidOperationException
Listener for GPIO port is also available.
class GPIOInterruptTest implement PinListener{
...
public void startRead(){
GPIOPin pin = GPIO.getPin(pinID);
pin.setInputListener(this);
}
...
void valueChanged(GPIOPin pin,boolean value){
System.out.println("pin value" + value);
}
...
}
Application should return GPIOPin by calling release()
method of Peripheral interface when GPIOPin is no longer used.
Field Summary | |
static int |
INPUT
|
static int |
OUTPUT
|
Method Summary | |
int |
getDirection()
Returns the current direction of pin. |
boolean |
getValue()
Returns the current value of the pin, this can be called on both outputs and inputs. |
void |
setDirection(int direction)
Set the current direction of pin. |
void |
setInputListener(PinListener listener)
Register listener for receiving callback from input pin. |
void |
setValue(boolean value)
Set pin value. |
Methods inherited from interface com.oracle.deviceaccess.Peripheral |
close, getID, getName |
Field Detail |
static final int INPUT
static final int OUTPUT
Method Detail |
boolean getValue() throws java.io.IOException, PeripheralNotAvailableException
java.lang.SecurityException
- throws when application has not enough permission.
java.io.IOException
- error occured while writing data to port.
PeripheralNotAvailableException
void setValue(boolean value) throws java.io.IOException, PeripheralNotAvailableException
value
- binary value
java.lang.SecurityException
- throws when application has not enough permission.
java.io.IOException
- error occured while writing data to port.
PeripheralNotAvailableException
int getDirection() throws java.io.IOException, PeripheralNotAvailableException
java.io.IOException
PeripheralNotAvailableException
void setDirection(int direction) throws PeripheralNotAvailableException, java.io.IOException
direction
- OUTPUT for output pin and INPUT for input pin
java.lang.SecurityException
- throws when application has not enough permission.
PeripheralNotAvailableException
java.io.IOException
void setInputListener(PinListener listener) throws PeripheralNotAvailableException
listener
- Listener for this pin.ad
java.lang.SecurityException
- throws when application has not enough permission.
PeripheralNotAvailableException
|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |