From 92631be1828208b90674fc0876682e6fe5d6d296 Mon Sep 17 00:00:00 2001 From: DriverStation3 <58869582+jbko6@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:17:31 -0800 Subject: [PATCH] add spark pid controller widget --- .../team2412/robot/util/SparkPIDWidget.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/frc/team2412/robot/util/SparkPIDWidget.java diff --git a/src/main/java/frc/team2412/robot/util/SparkPIDWidget.java b/src/main/java/frc/team2412/robot/util/SparkPIDWidget.java new file mode 100644 index 00000000..322d84f3 --- /dev/null +++ b/src/main/java/frc/team2412/robot/util/SparkPIDWidget.java @@ -0,0 +1,26 @@ +package frc.team2412.robot.util; + +import com.revrobotics.SparkPIDController; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; + +public class SparkPIDWidget implements NTSendable { + + public final SparkPIDController controller; + + public SparkPIDWidget(SparkPIDController controller) { + this.controller = controller; + + SendableRegistry.add(this, "Spark PID Controller"); + } + + @Override + public void initSendable(NTSendableBuilder builder) { + builder.setSmartDashboardType("PIDController"); + + builder.addDoubleProperty("p", controller::getP, controller::setP); + builder.addDoubleProperty("i", controller::getI, controller::setI); + builder.addDoubleProperty("d", controller::getD, controller::setD); + } +}