[Major] GpioBridge is now a singleton
This commit is contained in:
parent
4d5a58f8e5
commit
5121a179f5
|
@ -19,7 +19,17 @@ public class GpioBridge {
|
|||
private Thread thread;
|
||||
private volatile boolean run;
|
||||
|
||||
public GpioBridge() {
|
||||
private static final GpioBridge instance;
|
||||
|
||||
static {
|
||||
instance = new GpioBridge();
|
||||
}
|
||||
|
||||
public static GpioBridge getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private GpioBridge() {
|
||||
this.cache = new HashMap<>();
|
||||
this.listeners = Collections.synchronizedMap(new HashMap<>());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class GpioBridgeTest {
|
|||
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
|
||||
GpioBridge gpioBridge = new GpioBridge();
|
||||
GpioBridge gpioBridge = GpioBridge.getInstance();
|
||||
|
||||
System.out.println("Preparing pins...");
|
||||
greenBtn = gpioBridge.getGpio(Pin.P8_07, Direction.IN).setLabel("Green");
|
||||
|
|
Loading…
Reference in New Issue