[Project] Updated README for new interface GpioBridge
This commit is contained in:
parent
16efd2a498
commit
2f6930848e
|
@ -34,7 +34,7 @@ The `GpioBridge.getGpio()`-method will throw an exception if:
|
||||||
### Reading Input Pins
|
### Reading Input Pins
|
||||||
To read the current signal of a pin use the `GpioBridge.readValue()`-method:
|
To read the current signal of a pin use the `GpioBridge.readValue()`-method:
|
||||||
<pre>
|
<pre>
|
||||||
GpioBridge gpioBridge = GpioBridge.getInstance();
|
GpioBridge gpioBridge = GpioBridgeImpl.getInstance();
|
||||||
Gpio pin8_07 = gpioBridge.getGpio(Pin.P8_07, Direction.IN);
|
Gpio pin8_07 = gpioBridge.getGpio(Pin.P8_07, Direction.IN);
|
||||||
Signal currentSignal = gpioBridge.readValue(pin8_07);
|
Signal currentSignal = gpioBridge.readValue(pin8_07);
|
||||||
System.out.println(pin8_07 + " currently has signal " + currentSignal);
|
System.out.println(pin8_07 + " currently has signal " + currentSignal);
|
||||||
|
@ -43,7 +43,7 @@ System.out.println(pin8_07 + " currently has signal " + currentSignal);
|
||||||
### Writing Output Pins
|
### Writing Output Pins
|
||||||
To write the signal of a pin use the `GpioBridge.writeValue()`-method:
|
To write the signal of a pin use the `GpioBridge.writeValue()`-method:
|
||||||
<pre>
|
<pre>
|
||||||
GpioBridge gpioBridge = GpioBridge.getInstance();
|
GpioBridge gpioBridge = GpioBridgeImpl.getInstance();
|
||||||
Gpio pin8_08 = gpioBridge.getGpio(Pin.P8_08, Direction.OUT);
|
Gpio pin8_08 = gpioBridge.getGpio(Pin.P8_08, Direction.OUT);
|
||||||
gpioBridge.writeValue(pin8_08, Signal.HIGH);
|
gpioBridge.writeValue(pin8_08, Signal.HIGH);
|
||||||
System.out.println("Set signal of " + pin8_08 + " to " + Signal.HIGH);
|
System.out.println("Set signal of " + pin8_08 + " to " + Signal.HIGH);
|
||||||
|
@ -52,7 +52,7 @@ System.out.println("Set signal of " + pin8_08 + " to " + Signal.HIGH);
|
||||||
### Observing Input Pins
|
### Observing Input Pins
|
||||||
To be notified of changes to an input GPIO, register a `GpioSignalListener`:
|
To be notified of changes to an input GPIO, register a `GpioSignalListener`:
|
||||||
<pre>
|
<pre>
|
||||||
GpioBridge gpioBridge = GpioBridge.getInstance();
|
GpioBridge gpioBridge = GpioBridgeImpl.getInstance();
|
||||||
Gpio pin8_07 = gpioBridge.getGpio(Pin.P8_07, Direction.IN);
|
Gpio pin8_07 = gpioBridge.getGpio(Pin.P8_07, Direction.IN);
|
||||||
gpioBridge.register(pin8_07, gpio -> System.out.println("Signal of "+pin8_07 + " has changed to " + gpio.getSignal()));
|
gpioBridge.register(pin8_07, gpio -> System.out.println("Signal of "+pin8_07 + " has changed to " + gpio.getSignal()));
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ch.eitchnet.beaglebone;
|
package ch.eitchnet.beaglebone;
|
||||||
|
|
||||||
public interface GpioBridge {
|
public interface GpioBridge {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Public API method to write the given {@link Signal} on the given {@link Gpio}'s pin.
|
* Public API method to write the given {@link Signal} on the given {@link Gpio}'s pin.
|
||||||
|
|
Loading…
Reference in New Issue