Skip to content

Commit

Permalink
Merge pull request #31 from jbko6/PidWidget
Browse files Browse the repository at this point in the history
Add Spark PID controller widget
  • Loading branch information
jbko6 authored Feb 3, 2024
2 parents 620fe65 + 92631be commit e5d2fd6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/java/frc/team2412/robot/util/SparkPIDWidget.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit e5d2fd6

Please sign in to comment.