File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/main/java/frc/robot/subsystems Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 66import com .revrobotics .spark .SparkLowLevel ;
77import com .revrobotics .spark .config .SparkBaseConfig ;
88import com .revrobotics .spark .config .SparkFlexConfig ;
9+ import edu .wpi .first .wpilibj2 .command .Command ;
910import edu .wpi .first .wpilibj2 .command .SubsystemBase ;
1011import frc .robot .Constants ;
12+ import java .util .function .DoubleSupplier ;
1113
1214// initializes index and funnel motors
1315public class Index extends SubsystemBase {
@@ -48,4 +50,28 @@ public void setIndexSpeed(double speed) {
4850 public void setFunnelSpeed (double speed ) {
4951 this .funnelMotor .set (speed );
5052 }
53+
54+ private void run () {
55+ setIndexSpeed (Constants .Index .INDEX_SPEED );
56+ setFunnelSpeed (Constants .Index .FUNNEL_SPEED );
57+ }
58+
59+ private void stop () {
60+ setIndexSpeed (0 );
61+ setFunnelSpeed (0 );
62+ }
63+
64+ public Command runCommand () {
65+ return startEnd (() -> run (), () -> stop ());
66+ }
67+
68+ public Command runCommand (DoubleSupplier speedSupplier ) {
69+ return runEnd (
70+ () -> {
71+ double speed = speedSupplier .getAsDouble ();
72+ setIndexSpeed (speed );
73+ setFunnelSpeed (speed );
74+ },
75+ () -> stop ());
76+ }
5177}
You can’t perform that action at this time.
0 commit comments