Files
To-Shoot-TShirt/src/main/java/frc4388/robot/subsystems/ShootTube.java
T

79 lines
2.6 KiB
Java
Raw Normal View History

2021-10-07 17:31:03 -06:00
// 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 frc4388.robot.subsystems;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
2021-10-28 16:20:00 -06:00
import frc4388.utility.DPrint;
import frc4388.robot.Constants.DebugConstants;
2021-10-07 17:31:03 -06:00
import edu.wpi.first.wbilib.Solnoid;
2021-10-28 16:20:00 -06:00
DPrint DPrinter = new DPrint(DebugConstants.TYPE_INFO)
2021-10-07 17:31:03 -06:00
public class ShootTube extends SubsystemBase {
2021-10-25 16:21:50 -06:00
Solenoid[] m_solenoids;
int m_cycleCount = 0;
int m_maxCount;
public ShootTube(Solenoid[] solenoids) {
m_solenoids = solenoids;
2021-10-25 16:21:50 -06:00
m_maxCount = m_solenoids.length;
}
/*
2021-10-28 16:20:00 -06:00
Functions designed for the Left and Right Bumpers to
Cycle the tube slected manualy.
2021-10-25 16:21:50 -06:00
*/
public void CycleUp() {
m_cycleCount++;
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
m_cycleCount = 0;
2021-10-28 16:20:00 -06:00
}
DPrinter.println("Current CycleCount: "+m_cycleCount)
2021-10-25 16:21:50 -06:00
}
public void CycleDown() {
m_cycleCount--;
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
m_cycleCount = 0;
2021-10-28 16:20:00 -06:00
}
DPrinter.println("Current CycleCount: "+m_cycleCount)
2021-10-25 16:21:50 -06:00
}
/*
Normal Shoot Tube and Normal Shoot Tube Index Functions
*/
2021-10-28 16:20:00 -06:00
/* Function "ShootTubeSet" cycles up automaticly */
2021-10-25 16:21:50 -06:00
public void ShootTubeSet(Boolean arg) {
m_solenoids[CycleCount].set(arg);
2021-10-28 16:20:00 -06:00
/* If closing valve:
Increse the CycleCount by one,
if the CycleCount >= the length of the array OR CycleCount < 0:
set CycleCount to 0 */
2021-10-25 16:21:50 -06:00
if (arg == false) {
2021-10-28 16:20:00 -06:00
m_cycleCount++;
2021-10-25 16:21:50 -06:00
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
m_cycleCount = 0;
}
}
2021-10-28 16:20:00 -06:00
DPrinter.println("Current CycleCount: "+m_cycleCount)
2021-10-25 16:21:50 -06:00
}
2021-10-28 16:20:00 -06:00
/* Function "ShootTubeIndex" won't cycle up automaticly */
/* Not used, yet Useful */
2021-10-25 16:21:50 -06:00
public void ShootTubeIndex(Boolean arg, int i) {
m_solenoids[i].set(arg);
}
/*
Just Normal Shoot Tube But it Shoots all of the tubes
2021-10-28 16:20:00 -06:00
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
2021-10-25 16:21:50 -06:00
*/
public void ShootTubeALL(Boolean arg) {
for (Solenoid x : m_solenoids) {
x.set(arg);
}
m_cycleCount = 0;
}
@Override
public void periodic() {
// This method will be called once per scheduler run
}
}