mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
committed by
Peter Johnson
parent
73302f6162
commit
cb66bcca3c
@@ -33,6 +33,9 @@ public class LiveWindow {
|
||||
private static boolean liveWindowEnabled;
|
||||
private static boolean telemetryEnabled = true;
|
||||
|
||||
private static Runnable enabledListener;
|
||||
private static Runnable disabledListener;
|
||||
|
||||
private static Component getOrAdd(Sendable sendable) {
|
||||
Component data = (Component) SendableRegistry.getData(sendable, dataHandle);
|
||||
if (data == null) {
|
||||
@@ -46,6 +49,14 @@ public class LiveWindow {
|
||||
throw new UnsupportedOperationException("This is a utility class!");
|
||||
}
|
||||
|
||||
public static synchronized void setEnabledListener(Runnable runnable) {
|
||||
enabledListener = runnable;
|
||||
}
|
||||
|
||||
public static synchronized void setDisabledListener(Runnable runnable) {
|
||||
disabledListener = runnable;
|
||||
}
|
||||
|
||||
public static synchronized boolean isEnabled() {
|
||||
return liveWindowEnabled;
|
||||
}
|
||||
@@ -65,11 +76,17 @@ public class LiveWindow {
|
||||
updateValues(); // Force table generation now to make sure everything is defined
|
||||
if (enabled) {
|
||||
System.out.println("Starting live window mode.");
|
||||
if (enabledListener != null) {
|
||||
enabledListener.run();
|
||||
}
|
||||
} else {
|
||||
System.out.println("stopping live window mode.");
|
||||
SendableRegistry.foreachLiveWindow(dataHandle, cbdata -> {
|
||||
cbdata.builder.stopLiveWindowMode();
|
||||
});
|
||||
if (disabledListener != null) {
|
||||
disabledListener.run();
|
||||
}
|
||||
}
|
||||
enabledEntry.setBoolean(enabled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user