From efe6a0e350fa3a73d1528264b42f600e2d312496 Mon Sep 17 00:00:00 2001 From: Hayden Heroux Date: Mon, 22 Jan 2024 04:12:56 -0500 Subject: [PATCH] refactor: Add method to make widgets fullscreen. --- simgui.json | 1 + src/main/java/frc/lib/Telemetry.java | 16 +++++++--------- src/main/java/frc/robot/auto/Auto.java | 2 +- src/main/java/frc/robot/lights/Lights.java | 3 +++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/simgui.json b/simgui.json index fe8c0d2..33ba44e 100644 --- a/simgui.json +++ b/simgui.json @@ -3,6 +3,7 @@ "types": { "/FMSInfo": "FMSInfo", "/Shuffleboard/Auto/Auto Chooser": "String Chooser", + "/Shuffleboard/Auto/SendableChooser[0]": "String Chooser", "/Shuffleboard/Vision/Field": "Field2d", "/SmartDashboard/VisionSystemSim-visionSystem/Sim Field": "Field2d" }, diff --git a/src/main/java/frc/lib/Telemetry.java b/src/main/java/frc/lib/Telemetry.java index 08432e3..edeb859 100644 --- a/src/main/java/frc/lib/Telemetry.java +++ b/src/main/java/frc/lib/Telemetry.java @@ -4,10 +4,9 @@ import edu.wpi.first.networktables.BooleanEntry; import edu.wpi.first.networktables.DoubleEntry; import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.util.sendable.Sendable; import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; -import edu.wpi.first.wpilibj.shuffleboard.ComplexWidget; 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.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.shuffleboard.SuppliedValueWidget; @@ -66,15 +65,14 @@ public static ShuffleboardLayout addColumn(ShuffleboardTab tab, String columnTit } /** - * Adds a fullscreen sendable to a Shuffleboard tab. + * Makes a Shuffleboard component fullscreen. * - * @param tab the Shuffleboard tab to add the Sendable to. - * @param title the title of the sendable. - * @param sendable the sendable to add. - * @return the sendable widget. + * @param component the component to make fullscreen. + * @return the fullscreen component. */ - public static ComplexWidget addFullscreen(ShuffleboardTab tab, String title, Sendable sendable) { - return tab.add(title, sendable).withPosition(0, 0).withSize(10, 4); + // TODO + public static ShuffleboardComponent makeFullscreen(ShuffleboardComponent component) { + return component.withPosition(0, 0).withSize(10, 4); } /** diff --git a/src/main/java/frc/robot/auto/Auto.java b/src/main/java/frc/robot/auto/Auto.java index 490b0bd..5a7ba9a 100644 --- a/src/main/java/frc/robot/auto/Auto.java +++ b/src/main/java/frc/robot/auto/Auto.java @@ -79,7 +79,7 @@ public void periodic() {} @Override public void addToShuffleboard(ShuffleboardTab tab) { - Telemetry.addFullscreen(tab, "Auto Chooser", autoChooser); + Telemetry.makeFullscreen(tab.add("Auto Chooser", autoChooser)); } /** diff --git a/src/main/java/frc/robot/lights/Lights.java b/src/main/java/frc/robot/lights/Lights.java index 310cb16..5845149 100644 --- a/src/main/java/frc/robot/lights/Lights.java +++ b/src/main/java/frc/robot/lights/Lights.java @@ -4,6 +4,7 @@ import edu.wpi.first.wpilibj.shuffleboard.SimpleWidget; import edu.wpi.first.wpilibj.util.Color; import frc.lib.Subsystem; +import frc.lib.Telemetry; import frc.robot.lights.LEDControllerIO.LEDControllerIOValues; import frc.robot.lights.LightsConstants.Animations; import java.util.Map; @@ -62,6 +63,8 @@ public void addToShuffleboard(ShuffleboardTab tab) { tab.add("Light Color", true) .withProperties( Map.of("colorWhenFalse", "#000000", "colorWhenTrue", getColor().toHexString())); + + Telemetry.makeFullscreen(lightWidget); } /**