Private
Public Access
2
0

Isr.java: Fix ISR example to use pin 6 and sleep properly

Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Petre Eftime
2015-09-30 16:12:26 +03:00
committed by Brendan Le Foll
parent 42d169e003
commit 06e5e7dc11
2 changed files with 23 additions and 8 deletions

View File

@@ -30,6 +30,17 @@ import mraa.Aio;
public class AioA0 {
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
public static void main(String[] args) {
Aio a0 = new Aio(0);
@@ -42,4 +53,4 @@ public class AioA0 {
}
}
//! [Interesting]
//! [Interesting]

View File

@@ -22,6 +22,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import mraa.Dir;
import mraa.Edge;
import mraa.Gpio;
import mraa.IsrCallback;
public class Isr {
static {
try {
@@ -34,18 +39,17 @@ public class Isr {
}
}
public static void main(String argv[]) throws InterruptedException {
mraa.mraa.init();
Gpio gpio = new Gpio(6);
mraa.Gpio gpio = new mraa.Gpio(7);
IsrCallback callback = new JavaCallback();
mraa.IsrCallback callback = new JavaCallback();
gpio.isr(mraa.Edge.EDGE_RISING, callback);
Thread.sleep(0);
gpio.isr(Edge.EDGE_RISING, callback);
while (true)
Thread.sleep(999999);
};
}
class JavaCallback extends mraa.IsrCallback {
class JavaCallback extends IsrCallback {
public JavaCallback() { super(); }
public void run() { System.out.println("JavaCallback.run()"); }