mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
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:

committed by
Mihai Tudor Panu

parent
27f34face1
commit
e34863f223
@ -22,42 +22,40 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class CJQ4435Sample{
|
||||
|
||||
public class CJQ4435Sample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_cjq4435");
|
||||
}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]
|
||||
// Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
|
||||
upm_cjq4435.CJQ4435 mosfet = new upm_cjq4435.CJQ4435(3);
|
||||
|
||||
upm_cjq4435.CJQ4435 mosfet = new upm_cjq4435.CJQ4435(3);
|
||||
|
||||
mosfet.setPeriodMS(10);
|
||||
mosfet.enable(true);
|
||||
|
||||
while(true){
|
||||
|
||||
while (true) {
|
||||
// start with a duty cycle of 0.0 (off) and increment to 1.0 (on)
|
||||
for (float i=0; i <= 1; i+=0.1){
|
||||
for (float i = 0; i <= 1; i += 0.1) {
|
||||
mosfet.setDutyCycle(i);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
|
||||
|
||||
// Now take it back down
|
||||
// start with a duty cycle of 1.0 (on) and decrement to 0.0 (off)
|
||||
for (float i=1; i >= 0; i-=0.1){
|
||||
for (float i = 1; i >= 0; i -= 0.1) {
|
||||
mosfet.setDutyCycle(i);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user