Private
Public Access
2
0

examples: make main loops finite to ensure proper cleanup

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Alex Tereschenko
2017-06-05 18:22:29 +02:00
committed by Brendan Le Foll
parent 32340f6819
commit c36e4add5a
15 changed files with 112 additions and 28 deletions

View File

@@ -44,11 +44,12 @@ public class AioA0 {
public static void main(String[] args) {
Aio a0 = new Aio(0);
while (true) {
for (int i = 100; i > 0; --i) {
int adc_value = a0.read();
float adc_value_float = a0.readFloat();
System.out.println(String.format("ADC A0 read %X - %d", adc_value, adc_value));
System.out.println(String.format("ADC A0 read %.5f", adc_value_float));
Thread.sleep(500);
}
}

View File

@@ -61,7 +61,7 @@ public class BlinkIO {
System.exit(1);
}
while (true) {
for (int i = 100; i > 0; --i) {
gpio.write(1);
Thread.sleep(1000);
gpio.write(0);

View File

@@ -64,7 +64,7 @@ public class BlinkOnboard {
}
boolean state = false;
while (true) {
for (int i = 100; i > 0; --i) {
if (gpio_in != null && gpio_in.read() == 0) {
return;
}

View File

@@ -44,7 +44,7 @@ public class CyclePwm3 {
pwm.enable(true);
float value = 0;
while (true) {
for (int i = 100; i > 0; --i) {
value += 0.01;
pwm.write(value);
Thread.sleep(50);

View File

@@ -50,8 +50,8 @@ public class FTDITest {
/* Blink FTDI board LED */
Gpio led = new Gpio(514);
led.dir(Dir.DIR_OUT);
for (int i = 0;; i = (i + 1) % 2) {
led.write(i);
for (int i = 100; i > 0; --i) {
led.write(i % 2);
Thread.sleep(500);
}
} else {

View File

@@ -50,7 +50,7 @@ public class GpioMmapped {
gpio.useMmap(true);
while (true) {
for (int i = 1000; i > 0; --i) {
gpio.write(1);
Thread.sleep(50);
gpio.write(0);

View File

@@ -46,7 +46,7 @@ public class GpioRead6 {
gpio.dir(Dir.DIR_IN);
while (true) {
for (int i = 100; i > 0; --i) {
System.out.format("Gpio is %d\n", gpio.read());
Thread.sleep(1000);
}

View File

@@ -110,7 +110,7 @@ public class I2cCompass {
conf_buf[1] = HMC5883L_CONT_MODE;
i2c.write(conf_buf);
while (true) {
for (int i = 100; i > 0; --i) {
i2c.address(HMC5883L_I2C_ADDR);
i2c.writeByte(HMC5883L_DATA_REG);

View File

@@ -43,7 +43,7 @@ public class SpiMCP4261 {
System.out.println("Hello, SPI initialised");
byte data[] = {0x00, 100};
while (true) {
for (int cnt = 100; cnt > 0; --cnt) {
for (int i = 90; i < 130; i++) {
data[1] = (byte) i;
byte[] recv = spi.write(data);