Package com.crossbotics.ftchelper.robot
Class Pad.Button
java.lang.Object
com.crossbotics.ftchelper.teleop.Key
com.crossbotics.ftchelper.robot.Pad.Button
- Enclosing class:
Pad
One button or trigger. Each method gives it a job and hands the button back. It is a
Key too, so lib.pause(g1.a) can move a library job onto it.-
Method Summary
Modifier and TypeMethodDescriptiondoubleTap(Runnable)with an action.Two quick taps runjob(the first tap alone runs the tap job, if any).free()No job: it stays free, even if a module suggested one for it.heldFor(double, Runnable)with an action.Held down forseconds:jobruns once (a safe "are you sure?" for big moves, like re-homing a lift).RunswhileHeldevery loop while it is held.hold(Runnable), andonReleaseonce when it is let go.This button's job needs these parts: while one of them is not on the robot (markedoptional()in Robot.java and not in the configuration), the button does nothing and the button map shows "off: IntakeDeploy not on the robot".Starts the action; pressing again while it runs cancels it.RunsonPressonce each time it is pressed.RunsonReleaseonce each time it is let go.rumble()Feedback: the gamepad buzzes when this job runs (a hold: when it starts).rumble(int buzzes) rumble()withbuzzesshort buzzes (1 to 3).Words for the help page, e.g.slow()Slow driving, for one driver (Tunables.Drive.slowSpeed).tap(Runnable)with an action (a tap again while it runs cancels it).A quick tap (press and let go) runsjob.tapOrDoubleTap(Runnable tap, Runnable doubleTap) taps(int, Runnable)with an action.nquick taps in a row (2 to 5) runjob, e.g.tapThenHold(Runnable whileHeld) A quick tap, then press again and hold:whileHeldruns every loop while held (last season's "spray": tap, then hold fire).tapThenHold(Runnable whileHeld, Runnable onRelease) tapThenHold(Runnable), andonReleaseonce when it is let go.toggle(Toggleable part) Each press switches the part (an intake, a launcher, a claw, a mode) on or off.Each press flips between runningonEnableandonDisable.toString()"G2 RT".with(Pad.Button other, Action action) with(Button, Runnable)with an action.with(Pad.Button other, Runnable job) A pair: hold this button (the "shift key"), then pressotherto runjob.
-
Method Details
-
toString
"G2 RT". -
press
RunsonPressonce each time it is pressed. -
press
Starts the action; pressing again while it runs cancels it. -
tapOrDoubleTap
One tap runstap; a second tap soon after (withinPad.DOUBLE_TAP_SEC) runsdoubleTapinstead. The first tap of a double-tap has already runtap, so make the two work together, e.g. tap = intake on/off, double-tap = push out. -
release
RunsonReleaseonce each time it is let go. -
hold
RunswhileHeldevery loop while it is held. Alone it starts at once; with other gestures on the same button (tap, double-tap...) it starts once the press lastsTunables.Buttons.holdSec(0.3 s), so a quick tap stays a tap. -
hold
hold(Runnable), andonReleaseonce when it is let go. -
tap
A quick tap (press and let go) runsjob. It runs at once when pressed, unless the button also has a longer gesture (hold, double-tap...): then it runs as soon as that can no longer happen (when let go, orTunables.Buttons.tapGapSeclater). -
tap
tap(Runnable)with an action (a tap again while it runs cancels it). -
doubleTap
Two quick taps runjob(the first tap alone runs the tap job, if any). -
doubleTap
doubleTap(Runnable)with an action. -
taps
nquick taps in a row (2 to 5) runjob, e.g. 3 taps = intake backward. -
taps
taps(int, Runnable)with an action. -
tapThenHold
A quick tap, then press again and hold:whileHeldruns every loop while held (last season's "spray": tap, then hold fire). -
tapThenHold
tapThenHold(Runnable), andonReleaseonce when it is let go. -
heldFor
Held down forseconds:jobruns once (a safe "are you sure?" for big moves, like re-homing a lift). Let go sooner and nothing happens (or the tap job runs). -
heldFor
heldFor(double, Runnable)with an action. -
with
A pair: hold this button (the "shift key"), then pressotherto runjob. The shift key gets no job of its own;otherkeeps its own job when pressed alone. Both on the same gamepad. -
with
with(Button, Runnable)with an action. -
rumble
Feedback: the gamepad buzzes when this job runs (a hold: when it starts). On a toggle: two buzzes = on, one = off. After a gesture, it is for that gesture. -
rumble
rumble()withbuzzesshort buzzes (1 to 3). -
toggle
Each press switches the part (an intake, a launcher, a claw, a mode) on or off. -
toggle
Each press flips between runningonEnableandonDisable. -
slow
Slow driving, for one driver (Tunables.Drive.slowSpeed). On a trigger, e.g.g1.lt.slow(): the further it is pulled, the slower, down toslowSpeedat a full squeeze (like the two-driver LT). On a button: slow while it is held. (With two drivers, G1 LT already does this; afterlib.slow(null)inlibraryButtonsyou may use it with two drivers too.) -
free
No job: it stays free, even if a module suggested one for it. Listed as free on the help page. -
needs
This button's job needs these parts: while one of them is not on the robot (markedoptional()in Robot.java and not in the configuration), the button does nothing and the button map shows "off: IntakeDeploy not on the robot". The whole button (all its gestures). A part's own buttons andtoggle(Toggleable)know their part already.g1.x.press(Actions.deployIntake(robot)).says("deploy intake").needs(robot.intakeDeploy);- Parameters:
parts- one or more parts from Robot.java- Returns:
- this button
-
says
Words for the help page, e.g..says("score high"). After a gesture, for that gesture.
-