-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ShuffleBoard Wrapper for Shooter
- Loading branch information
1 parent
ae5336c
commit 8d43307
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |