diff options
Diffstat (limited to 'src/org/usfirst/frc/team4272/robotlib/ToggleButton.java')
-rw-r--r-- | src/org/usfirst/frc/team4272/robotlib/ToggleButton.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/org/usfirst/frc/team4272/robotlib/ToggleButton.java b/src/org/usfirst/frc/team4272/robotlib/ToggleButton.java new file mode 100644 index 0000000..1b70ad8 --- /dev/null +++ b/src/org/usfirst/frc/team4272/robotlib/ToggleButton.java @@ -0,0 +1,13 @@ +package org.usfirst.frc.team4272.robotlib; + +public class ToggleButton { + private boolean prev = false; + private boolean state = false; + public boolean update(boolean next) { + if (next && ! prev) { + state = !state; + } + prev = next; + return state; + } +} |