From d348a100b1f3fd4a5d715fd65f96f24f6ea4da9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=AEZach=20Wilke?= <90875734+76842@users.noreply.github.com> Date: Thu, 28 Oct 2021 16:20:00 -0600 Subject: [PATCH] USB edition Digital Deluxe --- README.md | 4 +-- src/main/java/frc4388/robot/Constants.java | 4 +++ .../java/frc4388/robot/RobotContainer.java | 6 +++- src/main/java/frc4388/robot/RobotMap.java | 6 +++- .../frc4388/robot/commands/ShootYourShot.java | 2 +- .../frc4388/robot/subsystems/ShootTube.java | 31 ++++++++++++----- src/main/java/frc4388/utility/DPrint.java | 33 +++++++++++++++++++ 7 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 src/main/java/frc4388/utility/DPrint.java diff --git a/README.md b/README.md index 9020b7f..3b3b94e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# Robot-Essentials - Basic code for any Ridgebotics robot project +# To-Shoot-TShirt + Code to shoot any small and light object out of a barrel on the T-shirt cannon robot. \ No newline at end of file diff --git a/src/main/java/frc4388/robot/Constants.java b/src/main/java/frc4388/robot/Constants.java index 75456ce..8554e43 100644 --- a/src/main/java/frc4388/robot/Constants.java +++ b/src/main/java/frc4388/robot/Constants.java @@ -54,4 +54,8 @@ public final class Constants { public static final int SHOOTER_SOLENOID_6_ID = 7; public static final int SHOOTER_SOLENOID_7_ID = 8; } + public static final class DebugConstants { + public static final boolean SHOW_INFO = true; + public static final Str TYPE_INFO = "INFO"; + } } \ No newline at end of file diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index 9c3e1ee..2d54476 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -1,4 +1,3 @@ -/* Dumb Command Version, Smart Subsytem Version */ /*----------------------------------------------------------------------------*/ /* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ @@ -54,6 +53,7 @@ public class RobotContainer { private final ShootTube m_robotShooter = new ShootTube(SolenoidArray); + private final DPrinter m_debugLogger = m_robotMap.DPrinter /* Controllers */ private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID); private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID); @@ -117,6 +117,10 @@ public class RobotContainer { .whenPressed(() -> m_robotShooter.ShootTubeALL(true)) .whenReleased(() -> m_robotShooter.ShootTubeALL(false)); + /* Just A test of the DPrint object */ + new JoystickButton(getOperatorJoystick(), XboxController.B_BUTTON) + .whenPressed(() -> m_debugLogger.println("This is a Debug Message")); + } diff --git a/src/main/java/frc4388/robot/RobotMap.java b/src/main/java/frc4388/robot/RobotMap.java index 50f7b17..fd5c672 100644 --- a/src/main/java/frc4388/robot/RobotMap.java +++ b/src/main/java/frc4388/robot/RobotMap.java @@ -19,6 +19,7 @@ import frc4388.robot.Constants.DriveConstants; import frc4388.robot.Constants.HornConstants; import frc4388.robot.Constants.LEDConstants; import frc4388.utility.RobotGyro; +import frc4388.utility.DPrint; /** * Defines and holds all I/O objects on the Roborio. This is useful for unit @@ -81,5 +82,8 @@ public class RobotMap { public final Solenoid ShooterSolenoid4 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_4_ID); public final Solenoid ShooterSolenoid5 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_5_ID); public final Solenoid ShooterSolenoid6 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_6_ID); - public final Solenoid ShooterSolenoid7 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_7_ID); + public final Solenoid ShooterSolenoid7 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_7_ID); + + /* DPrint Utility */ + public final DPrint DPrinter = new DPrint(DebugConstants.TYPE_INFO); } \ No newline at end of file diff --git a/src/main/java/frc4388/robot/commands/ShootYourShot.java b/src/main/java/frc4388/robot/commands/ShootYourShot.java index cb6b346..bfa7751 100644 --- a/src/main/java/frc4388/robot/commands/ShootYourShot.java +++ b/src/main/java/frc4388/robot/commands/ShootYourShot.java @@ -1,8 +1,8 @@ -/* Dumb Command Version, Smart Subsytem Version */ // 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. +/* This Command has been gutted. Like a fish */ package frc4388.robot.commands; import edu.wpi.first.wpilibj2.command.CommandBase; diff --git a/src/main/java/frc4388/robot/subsystems/ShootTube.java b/src/main/java/frc4388/robot/subsystems/ShootTube.java index 371781b..53dbffd 100644 --- a/src/main/java/frc4388/robot/subsystems/ShootTube.java +++ b/src/main/java/frc4388/robot/subsystems/ShootTube.java @@ -1,4 +1,3 @@ -/* Dumb Command Version, Smart Subsytem Version */ // 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. @@ -6,11 +5,12 @@ package frc4388.robot.subsystems; import edu.wpi.first.wpilibj2.command.SubsystemBase; - +import frc4388.utility.DPrint; +import frc4388.robot.Constants.DebugConstants; import edu.wpi.first.wbilib.Solnoid; +DPrint DPrinter = new DPrint(DebugConstants.TYPE_INFO) public class ShootTube extends SubsystemBase { - /** Creates a new ShootTube. */ Solenoid[] m_solenoids; int m_cycleCount = 0; int m_maxCount; @@ -19,39 +19,52 @@ public class ShootTube extends SubsystemBase { m_maxCount = m_solenoids.length; } /* - Functions designed for the DPAD left and right buttions to - Cycle the tube to be shooting out of + Functions designed for the Left and Right Bumpers to + Cycle the tube slected manualy. */ public void CycleUp() { m_cycleCount++; if (m_cycleCount >= m_maxCount || m_cycleCount < 0) { m_cycleCount = 0; - } + } + DPrinter.println("Current CycleCount: "+m_cycleCount) } public void CycleDown() { m_cycleCount--; if (m_cycleCount >= m_maxCount || m_cycleCount < 0) { m_cycleCount = 0; - } + } + DPrinter.println("Current CycleCount: "+m_cycleCount) } /* Normal Shoot Tube and Normal Shoot Tube Index Functions */ + /* Function "ShootTubeSet" cycles up automaticly */ public void ShootTubeSet(Boolean arg) { m_solenoids[CycleCount].set(arg); + /* If closing valve: + Increse the CycleCount by one, + if the CycleCount >= the length of the array OR CycleCount < 0: + set CycleCount to 0 */ if (arg == false) { - CycleCount++; + m_cycleCount++; if (m_cycleCount >= m_maxCount || m_cycleCount < 0) { m_cycleCount = 0; } } + DPrinter.println("Current CycleCount: "+m_cycleCount) } + /* Function "ShootTubeIndex" won't cycle up automaticly */ + /* Not used, yet Useful */ public void ShootTubeIndex(Boolean arg, int i) { m_solenoids[i].set(arg); } /* Just Normal Shoot Tube But it Shoots all of the tubes - Designed for DPAD Down + in the array in enumeration + can't do m_solenoids[1].set(true), m_solenoids[2].set(true) due to + the fact that the object needs to be variable in the length of the array + Designed for the X buttion */ public void ShootTubeALL(Boolean arg) { for (Solenoid x : m_solenoids) { diff --git a/src/main/java/frc4388/utility/DPrint.java b/src/main/java/frc4388/utility/DPrint.java new file mode 100644 index 0000000..6b5c72f --- /dev/null +++ b/src/main/java/frc4388/utility/DPrint.java @@ -0,0 +1,33 @@ +/* Simple Debug Log To Console Utility. */ +package frc4388.utility; + +import frc4388.robot.Constants.DebugConstants; + +public class DPrint { + str m_debugMsgType = DebugConstants.TYPE_INFO; + public DPrint(str type) { + m_debugMsgType = type; + } + public println(str[] mesage) { + switch (m_debugMsgType) { + case DebugConstants.TYPE_INFO: + if (DebugConstants.SHOW_INFO) { + system.out.println("Debug_INFO: "+mesage); + } + ; + default: + ; + } + } + public print(str[] mesage) { + switch (m_debugMsgType) { + case DebugConstants.TYPE_INFO: + if (DebugConstants.SHOW_INFO) { + system.out.print("Debug_INFO: "+mesage); + } + ; + default: + ; + } + } +} \ No newline at end of file