diff --git a/src/main/java/frc/robot/ShuffleBoardWrapper.java b/src/main/java/frc/robot/ShuffleBoardWrapper.java new file mode 100644 index 0000000..e2db17b --- /dev/null +++ b/src/main/java/frc/robot/ShuffleBoardWrapper.java @@ -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); + } + } +} \ No newline at end of file