Private
Public Access
2
0

examples/java: Update, indent and add [Interesting] tags to examples

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 13:21:23 +03:00
committed by Brendan Le Foll
parent 013c04c7b9
commit 0e44dfac44
5 changed files with 133 additions and 108 deletions

View File

@@ -24,21 +24,32 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import mraa.Dir;
import mraa.Gpio;
import mraa.mraa;
public class GpioRead6 {
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);
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 argv[]) throws InterruptedException {
System.out.println(String.format("MRAA Version: %s\nStarting Read on IO6\n", mraa.getVersion()));
//! [Interesting]
Gpio gpio = new Gpio(6);
gpio.dir(Dir.DIR_IN);
while (true) {
System.out.format("Gpio is %d\n", gpio.read());
Thread.sleep(1000);
}
//! [Interesting]
}
}
public static void main(String argv[]) {
mraa.mraa.init();
mraa.Gpio gpio_in = new mraa.Gpio(6);
gpio_in.dir(mraa.Dir.DIR_IN);
System.out.format("Gpio is %d\n", gpio_in.read());
}
}