Browse Source

groveButton: Corrected GroveButtonSample and GroveButton_intrSample

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Stefan Andritoiu 9 years ago
parent
commit
9bfda4219d
2 changed files with 7 additions and 16 deletions
  1. 2
    11
      examples/java/GroveButtonSample.java
  2. 5
    5
      examples/java/GroveButton_intrSample.java

+ 2
- 11
examples/java/GroveButtonSample.java View File

@@ -24,19 +24,10 @@
24 24
 
25 25
 public class GroveButtonSample {
26 26
 
27
-	static {
28
-		try {
29
-			System.loadLibrary("javaupm_grove");
30
-		} catch (UnsatisfiedLinkError e) {
31
-			System.err.println("error in loading native library");
32
-			System.exit(-1);
33
-		}
34
-	}
35
-
36 27
 	public static void main(String[] args) throws InterruptedException {
37 28
 		// ! [Interesting]
38
-		// Create the button object using UART
39
-		upm_grove.GroveButton button = new upm_grove.GroveButton(0);
29
+		// Create the button object using GPIO pin 2
30
+		upm_grove.GroveButton button = new upm_grove.GroveButton(2);
40 31
 
41 32
 		while (true) {
42 33
 			System.out.println(button.name() + " value is " + button.value());

+ 5
- 5
examples/java/GroveButton_intrSample.java View File

@@ -1,5 +1,3 @@
1
-import upm_grove.IsrCallback;
2
-
3 1
 /*
4 2
  * Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
5 3
  * Copyright (c) 2015 Intel Corporation.
@@ -24,6 +22,8 @@ import upm_grove.IsrCallback;
24 22
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 23
  */
26 24
 
25
+import upm_grove.IsrCallback;
26
+
27 27
 //NOT TESTED!!!
28 28
 public class GroveButton_intrSample {
29 29
 
@@ -31,7 +31,7 @@ public class GroveButton_intrSample {
31 31
 
32 32
 	static {
33 33
 		try {
34
-			System.loadLibrary("javaupm_grove");
34
+			System.loadLibrary("mraajava");
35 35
 		} catch (UnsatisfiedLinkError e) {
36 36
 			System.err.println("error in loading native library");
37 37
 			System.exit(-1);
@@ -43,7 +43,7 @@ public class GroveButton_intrSample {
43 43
 		upm_grove.GroveButton b = new upm_grove.GroveButton(2);
44 44
 
45 45
 		IsrCallback callback = new ButtonISR();
46
-		b.installISR(0, callback);
46
+		b.installISR(mraa.Edge.EDGE_RISING.swigValue(), callback);
47 47
 
48 48
 		while (true) {
49 49
 			System.out.println("Counter: " + counter);
@@ -60,6 +60,6 @@ class ButtonISR extends IsrCallback {
60 60
 
61 61
 	public void run() {
62 62
 		GroveButton_intrSample.counter++;
63
-		System.out.println("+++++++++");
63
+		System.out.println("Button pressed!");
64 64
 	}
65 65
 }