generated from OakvilleDynamics/frc-robot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from OakvilleDynamics/Dump
New Dump Code
- Loading branch information
Showing
3 changed files
with
113 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
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.commands; | ||
|
||
import edu.wpi.first.wpilibj.Joystick; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.Constants.OperatorConstants; | ||
import frc.robot.subsystems.Dump; | ||
|
||
public class DumpControl extends Command { | ||
|
||
private static Dump DumpSubsystem; | ||
|
||
private static Joystick Controller = new Joystick(OperatorConstants.COPILOT_CONTROLLER); | ||
|
||
/** Creates a new PneumaticsControl. */ | ||
public DumpControl(Dump subsystem) { | ||
DumpSubsystem = subsystem; | ||
addRequirements(subsystem); | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() {} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
if (Controller.getRawButton(1)) { | ||
DumpSubsystem.open(); | ||
} else if (Controller.getRawButton(2)) { | ||
DumpSubsystem.close(); | ||
} | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) {} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
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,46 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can mhhhodify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystems; | ||
|
||
import edu.wpi.first.wpilibj.DoubleSolenoid; | ||
import edu.wpi.first.wpilibj.PneumaticsModuleType; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants.PneumaticsConstants; | ||
import frc.robot.Constants.PneumaticsConstants.DumpConstants; | ||
|
||
public class Dump extends SubsystemBase { | ||
|
||
// The double solenoid that controls the piston | ||
private DoubleSolenoid doubleSolenoid = | ||
new DoubleSolenoid( | ||
PneumaticsConstants.PneumaticsMoudleID, | ||
PneumaticsModuleType.REVPH, | ||
DumpConstants.IN, | ||
DumpConstants.OUT); | ||
|
||
/** Creates a new Pneumatics subsystem. */ | ||
public Dump() { | ||
System.out.println("Pneumatics initialized"); | ||
SmartDashboard.putBoolean(getName(), false); | ||
} | ||
|
||
/** Opens the piston */ | ||
public void open() { | ||
doubleSolenoid.set(DoubleSolenoid.Value.kForward); | ||
SmartDashboard.putBoolean(getName(), true); | ||
} | ||
|
||
/** Closes the piston */ | ||
public void close() { | ||
doubleSolenoid.set(DoubleSolenoid.Value.kReverse); | ||
SmartDashboard.putBoolean(getName(), false); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
} |