Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from Gongoliers/3_4_2024_dashboard
Browse files Browse the repository at this point in the history
refactor: Rename methods.
  • Loading branch information
haydenheroux authored Mar 4, 2024
2 parents 81ea947 + a06f0a6 commit ed20ceb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
3 changes: 3 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"/FMSInfo": "FMSInfo",
"/Shuffleboard/Auto/Auto Chooser": "String Chooser",
"/Shuffleboard/Auto/SendableChooser[0]": "String Chooser",
"/Shuffleboard/Dashboard/Auto Chooser": "String Chooser",
"/Shuffleboard/Dashboard/Auto/Auto Chooser": "String Chooser",
"/Shuffleboard/Dashboard/Auto/SendableChooser[0]": "String Chooser",
"/Shuffleboard/Odometry/Field/Field": "Field2d",
"/Shuffleboard/Vision/Field": "Field2d",
"/SmartDashboard/Arm Mechanism": "Mechanism2d",
Expand Down
34 changes: 23 additions & 11 deletions src/main/java/frc/lib/Telemetry.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
/** Helper class for managing robot telemetry. */
public class Telemetry {

private static final HashMap<String, Integer> tabColumnCount = new HashMap<>();
private static final HashMap<String, Integer> tabColumn = new HashMap<>();

/**
* Initializes a subsystem's Shuffleboard tab.
*
* @param subsystem the subsystem to initialize.
*/
public static void initializeShuffleboard(Subsystem subsystem) {
public static void initializeTab(Subsystem subsystem) {
String name = subsystem.getName();

ShuffleboardTab tab = Shuffleboard.getTab(name);
Expand All @@ -37,9 +37,9 @@ public static void initializeShuffleboard(Subsystem subsystem) {
*
* @param subsystems the subsystems to initialize.
*/
public static void initializeShuffleboards(Subsystem... subsystems) {
public static void initializeTabs(Subsystem... subsystems) {
for (Subsystem subsystem : subsystems) {
Telemetry.initializeShuffleboard(subsystem);
Telemetry.initializeTab(subsystem);
}
}

Expand All @@ -48,21 +48,33 @@ public static void initializeShuffleboards(Subsystem... subsystems) {
*
* @param tab the Shuffleboard tab to add the column to.
* @param columnTitle the title of the column.
* @param width the width of the column.
* @return the added Shuffleboard column.
*/
public static ShuffleboardLayout addColumn(ShuffleboardTab tab, String columnTitle) {
public static ShuffleboardLayout addColumn(ShuffleboardTab tab, String columnTitle, int width) {
String tabTitle = tab.getTitle();

int currentColumnCount = tabColumnCount.getOrDefault(tabTitle, 0);
// Increment the column count for the next call
tabColumnCount.put(tabTitle, currentColumnCount + 1);
int column = tabColumn.containsKey(tabTitle) ? tabColumn.get(tabTitle) + width : 0;

// Increment the column number for the next call
tabColumn.put(tabTitle, column);

final int kColumnWidth = 2;
final int kColumnHeight = 4;

return tab.getLayout(columnTitle, BuiltInLayouts.kList)
.withSize(kColumnWidth, kColumnHeight)
.withPosition(currentColumnCount * kColumnWidth, 0);
.withSize(width, kColumnHeight)
.withPosition(column, 0);
}

/**
* Adds a column to a Shuffleboard tab.
*
* @param tab the Shuffleboard tab to add the column to.
* @param columnTitle the title of the column.
* @return the added Shuffleboard column.
*/
public static ShuffleboardLayout addColumn(ShuffleboardTab tab, String columnTitle) {
return addColumn(tab, columnTitle, 2);
}

/**
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ public static RobotContainer getInstance() {

/** Initializes subsystem telemetry. */
private void initializeTelemetry() {
if (RobotConstants.USE_TELEMETRY) {
Telemetry.initializeShuffleboards(arm, climber, intake, odometry, shooter, swerve);
SmartDashboard.putData("Mechanism", RobotMechanisms.getInstance().getMechanism());
}

SmartDashboard.putData(auto.getAutonomousChooser());
Telemetry.initializeTabs(arm, auto, climber, intake, odometry, shooter, swerve);
SmartDashboard.putData("Mechanism", RobotMechanisms.getInstance().getMechanism());
}

/** Configures operator controller bindings. */
Expand Down

0 comments on commit ed20ceb

Please sign in to comment.