java: Added java samples and applied coding style rules to all previous samples

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Stefan Andritoiu
2015-10-08 14:30:12 +03:00
committed by Mihai Tudor Panu
parent 27f34face1
commit e34863f223
71 changed files with 2433 additions and 649 deletions

View File

@ -28,35 +28,35 @@ public class ULN200XASample {
static {
try {
System.loadLibrary("javaupm_uln200xa");
}catch (UnsatisfiedLinkError e) {
} catch (UnsatisfiedLinkError e) {
System.err.println("error in loading native library");
System.exit(-1);
}
}
public static void main(String[] args) throws InterruptedException {
//! [Interesting]
// ! [Interesting]
// Instantiate a Stepper motor on a ULN200XA Dual H-Bridge.
// Wire the pins so that I1 is pin D8, I2 is pin D9, I3 is pin D10 and
// I4 is pin D11
upm_uln200xa.ULN200XA uln200xa = new upm_uln200xa.ULN200XA(4096, 8, 9, 10, 11);
uln200xa.setSpeed(5);
System.out.println("Rotating 1 revolution clockwise.");
uln200xa.setDirection(upm_uln200xa.ULN200XA.ULN200XA_DIRECTION_T.DIR_CW);
uln200xa.stepperSteps(4096);
System.out.println("Sleeping for 2 seconds...");
Thread.sleep(2000);
System.out.println("Rotating 1/2 revolution counter clockwise.");
uln200xa.setDirection(upm_uln200xa.ULN200XA.ULN200XA_DIRECTION_T.DIR_CCW);
uln200xa.stepperSteps(2048);
// turn off the power
uln200xa.release();
//! [Interesting]
// ! [Interesting]
System.out.println("Exiting...");
}