]> git.taranathan.com Git - FRC2026.git/commitdiff
more smartdashboard stuff
authoriefomit <timofei.stem@gmail.com>
Mon, 16 Feb 2026 22:48:01 +0000 (14:48 -0800)
committeriefomit <timofei.stem@gmail.com>
Mon, 16 Feb 2026 22:48:01 +0000 (14:48 -0800)
src/main/java/frc/robot/subsystems/spindexer/Spindexer.java

index 2b387aced3484c6c2c6d9e74eed574ef15315f23..1a1729a294d556e4f64751c5e0efe2ece3160d3e 100644 (file)
@@ -6,6 +6,7 @@ import com.ctre.phoenix6.hardware.TalonFX;
 import org.littletonrobotics.junction.Logger;
 
 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
+import edu.wpi.first.wpilibj2.command.InstantCommand;
 import edu.wpi.first.wpilibj2.command.SubsystemBase;
 import frc.robot.constants.Constants;
 import frc.robot.constants.IdConstants;
@@ -21,21 +22,28 @@ public class Spindexer extends SubsystemBase implements SpindexerIO {
 
     public Spindexer() {
         updateInputs();
-        
+
         // configure current limit
         CurrentLimitsConfigs limitConfig = new CurrentLimitsConfigs();
         limitConfig.StatorCurrentLimit = SpindexerConstants.currentLimit;
         limitConfig.StatorCurrentLimitEnable = true;
         motor.getConfigurator().apply(limitConfig);
+
+        SmartDashboard.putData("Max speed spindexer", new InstantCommand(() -> maxSpindexer()));
+        SmartDashboard.putData("Turn off spindexer", new InstantCommand(() -> stopSpindexer()));
+        SmartDashboard.putData("Spindexer 50%", new InstantCommand(() -> setSpindexer(0.5)));
     }
 
     @Override
     public void periodic() {
         updateInputs();
 
-        double dashboardPower = SmartDashboard.getNumber("Spindexer Power", -1.0);
-        if (dashboardPower != -1.0) {
-            power = dashboardPower;
+        // if speed was set
+        if (SmartDashboard.containsKey("Spindexer Power")) {
+            double dashboardPower = SmartDashboard.getNumber("Spindexer Power", 0.0);
+            if (dashboardPower != power) {
+                power = dashboardPower;
+            }
         }
 
         motor.set(power);
@@ -59,6 +67,10 @@ public class Spindexer extends SubsystemBase implements SpindexerIO {
         power = 0.0;
     }
 
+    public void setSpindexer(double power) {
+        this.power = power;
+    }
+
     @Override
     public void updateInputs() {
         inputs.spindexerVelocity = motor.getVelocity().getValueAsDouble();