Skip to content

Commit

Permalink
feat: ShuffleBoard Wrapper for Shooter
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammingSR committed Feb 10, 2024
1 parent ae5336c commit 8d43307
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/main/java/frc/robot/ShuffleBoardWrapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardComponent;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj2.command.Subsystem;
import frc.robot.subsystems.ShooterSubsystem;

/** Add your docs here. */
public class ShuffleBoardWrapper {
public static ShuffleBoardWrapper m_default = new ShuffleBoardWrapper("Default");

private String m_name;

private static boolean checkForTitle(String title, ShuffleboardLayout lay) {
for (ShuffleboardComponent<?> com : lay.getComponents()) {
if (com.getTitle() == title) return false;
}
return true;
}

private ShuffleBoardWrapper(String name) {
m_name = name;
ShuffleboardLayout lay = Shuffleboard.getTab(m_name).getLayout("Match Info", BuiltInLayouts.kList);
if (checkForTitle("Timer", lay))
lay.addNumber("Timer", () -> MathUtil.clamp(DriverStation.getMatchTime(), 0, 255));
if (checkForTitle("Enabled", lay))
lay.addBoolean("Enabled", () -> DriverStation.isEnabled());
if (checkForTitle("Driver Controller", lay)) // Assumes port 0 driver
lay.addBoolean("Driver Controller ", () -> DriverStation.isJoystickConnected(0));
if (checkForTitle("Operator Controller", lay)) // Assumes port 1 driver
lay.addBoolean("Operator Controller", () -> DriverStation.isJoystickConnected(1));
}

protected void addShooter(ShooterSubsystem shooter) {
ShuffleboardLayout lay = Shuffleboard.getTab(m_name).getLayout("Shooter", BuiltInLayouts.kList);
if(checkForTitle("Dummy", lay)){
//lay.addBoolean("DUmmy", () -> DummyThing);
}
}
}

0 comments on commit 8d43307

Please sign in to comment.