Package com.casioeurope.mis.edt
Class EeicLibrary.GpioDevice
Object
GpioDevice
- Enclosing class:
- EeicLibrary
public static class EeicLibrary.GpioDevice extends Object
The GpioDevice class is used to control general purpose input / output pins
- Since:
- 2.00
-
Constructor Summary
Constructors Constructor Description GpioDevice()
-
Method Summary
Modifier and Type Method Description static int
getValue(int pinNo)
Gets the input value of the specified GPIO.static boolean
registerCallback(EeicLibrary.InterruptCallback callback, Handler handler)
Register a callback for an edge interrupt.static int
setInputDirection(int pinNo, int pinStatus)
Sets the specified GPIO as an input pin.static int
setInterruptEdge(int pinNo, int type)
Sets the interrupt edge of the specified GPIO.static int
setOutputDirection(int pinNo, int value)
Sets the specified GPIO as an output pin.static int
setValue(int pinNo, int value)
Output the value to the specified GPIO.static boolean
unregisterCallback(EeicLibrary.InterruptCallback callback)
Unregisters an interrupt detection callback.
-
Constructor Details
-
GpioDevice
public GpioDevice()
-
-
Method Details
-
setInputDirection
public static int setInputDirection(int pinNo, int pinStatus) throws RemoteException, UnsupportedOperationExceptionSets the specified GPIO as an input pin.- Parameters:
pinNo
-int
: GPIO number
Specify the target GPIO.
For details of the GPIO number, refer to ConstantspinStatus
-int
: Pin status
Specify the pin status by Pull up, Pull down, or High impedance.
For details of the pin status, refer toGPIO_DEVICE Constants
- Returns:
int
:ERROR_UNSUPPORTED
in case of failure, other values indicate success.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.
-
setOutputDirection
public static int setOutputDirection(int pinNo, int value) throws RemoteException, UnsupportedOperationExceptionSets the specified GPIO as an output pin.- Parameters:
pinNo
-int
: GPIO number
Specify the target GPIO.
For details of the GPIO number, refer to Constantsvalue
-int
: Output value
Specify the initial output by High or Low.
For details of output value, refer toGPIO_DEVICE Constants
- Returns:
int
:ERROR_UNSUPPORTED
in case of failure, other values indicate success.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.
-
setValue
public static int setValue(int pinNo, int value) throws RemoteException, UnsupportedOperationExceptionOutput the value to the specified GPIO. Only GPIO set as output direction can be used.- Parameters:
pinNo
-int
: GPIO number
Specify the target GPIO.
For details of the GPIO number, refer toGPIO_DEVICE Constants
value
-int
: Output
Specify the output by High or Low.
For details of output value, refer toGPIO_DEVICE Constants
- Returns:
int
:ERROR_UNSUPPORTED
in case of failure, other values indicate success.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.
-
getValue
public static int getValue(int pinNo) throws RemoteException, UnsupportedOperationException, IllegalStateExceptionGets the input value of the specified GPIO. Only GPIO set as input direction can be used.- Parameters:
pinNo
-int
: GPIO number
Specify the target GPIO.
For details of the GPIO number, refer toGPIO_DEVICE Constants
- Returns:
int
:ERROR_UNSUPPORTED
in case of failure, otherwise returns the value of the specified GPIO.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.
-
setInterruptEdge
public static int setInterruptEdge(int pinNo, int type) throws RemoteException, UnsupportedOperationExceptionSets the interrupt edge of the specified GPIO.- Parameters:
pinNo
-int
: GPIO number
Specify the target GPIO.
For details of the GPIO number, refer to Constantstype
-int
: Interrupt type
Specify the interrupt type by none, rising, falling, and both.
For details of the interrupt type, refer toGPIO_DEVICE Constants
- Returns:
int
:ERROR_UNSUPPORTED
in case of failure, other values indicate success.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.
-
registerCallback
public static boolean registerCallback(EeicLibrary.InterruptCallback callback, Handler handler) throws RemoteException, UnsupportedOperationExceptionRegister a callback for an edge interrupt. Handle all GPIOs with one callback. When an interrupt occurs, the GPIO number is notified by a callback argument.- Parameters:
callback
-InterruptCallback
: Callback
Specify the callback that handles the interrupt.
For details of the callback, refer toInterruptCallback
handler
-Handler
: If specified, the callback method will be posted on the thread belonging to thisHandler
Usenull
if you don't need a specific thread to handle the callback method.- Returns:
boolean
: Returns true on success and false on failure.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- API Note:
- The
handler
parameter is particularly useful in case you need to update a User Interface, in which case for instance you can use an Activity's Looper to get the Main UI Thread Handler like this:
Handler handler
= newHandler
(Looper
.getMainLooper()
);
Registered callbacks are being identified by theirInterruptCallback
object instance only and it's not allowed to register multiple callbacks with the sameInterruptCallback
object instance.
You can register as many uniqueInterruptCallback
callback objects as you like and all of them will get notified when acallback
is getting received.
-
unregisterCallback
public static boolean unregisterCallback(EeicLibrary.InterruptCallback callback) throws RemoteException, UnsupportedOperationExceptionUnregisters an interrupt detection callback.- Parameters:
callback
-InterruptCallback
: Callback
Specify the registered callback.
For details of the callback, refer toInterruptCallback
- Returns:
boolean
: Returns true on success and false on failure.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.
-