2N Indoor Touch Api Manual page 16

Api
Hide thumbs Also See for Indoor Touch:
Table of Contents

Advertisement

3.3.2.7 Active Low Pin Value Setting
int IndoorTouch.GPIOSetActiveLow(int
Pin is the PIN index, refer to
G P I O _ P I N _ I O 1
The return value is as follows:
IndoorTouch.RC_OK = 0;
IndoorTouch.RC_ERR_CONN = -1; API daemon connection error
IndoorTouch.RC_ERR_SYS = -6; system error (the value cannot be set, etc.)
IndoorTouch.RC_ERR_DENIED = -7; GPIO does not exist or is unswitchable
3.3.2.8 GPIO Input Value Change Detection
As the Java GUI interface is primarily controlled by messages and periodical reading
of GPIO inputs is complicated for programmers and speed-limiting due to high JNI
operational costs and delay caused by Java-daemon communication intervals, an
auxiliary nested static class
GPIO value changes. When its instance is created,
thread, which periodically checks the GPIO input states and, having detected a
change, calls
public void OnGPIOChanged(int gpio, int value)
the content of this method is executed in the UI thread. Hence, to monitor the GPIO
state, the user creates a son of this class and overrides this method. Then the user
creates an instance of this class. Example:
class
MyWatcher
public MyWatcher(int
super(mask);
}
@Override
public void OnGPIOChanged(int
if
(gpio == IndoorTouch.GPIO_PIN_IN1) {
// do the magic
}
}
}
protected
IndoorTouch.GPIOWatcher mWatch =
GPIO_PIN_IN1 | IndoorTouch.GPIO_PIN_IN2);
GPIOWatcher has the following two constructors:
public GPIOWatcher(int watchMask)
2N TELEKOMUNIKACE a.s., www.2n.cz
3.3.2.1 GPIO Pin Reading
IndoorTouch.GPIOWatcher
extends
IndoorTouch.GPIOWatcher {
mask) {
pin,
int
value);
, and value is {0,1}. Applicable for
a n d
is available for detection of
IndoorTouch.GPIOWatcher
gpio,
int
value) {
new
MyWatcher( IndoorTouch.
G P I O _ P I N _ I O 2 .
starts a
via Android Looper, i.e.
16/42

Advertisement

Table of Contents
loading

Table of Contents