|
| 1 | +// Copyright (c) FIRST and other WPILib contributors. |
| 2 | +// Open Source Software; you can modify and/or share it under the terms of |
| 3 | +// the WPILib BSD license file in the root directory of this project. |
| 4 | + |
| 5 | +package frc.robot.subsystems.Hopper; |
| 6 | + |
| 7 | +import com.revrobotics.PersistMode; |
| 8 | +import com.revrobotics.ResetMode; |
| 9 | +import com.revrobotics.spark.SparkLowLevel.MotorType; |
| 10 | +import com.revrobotics.spark.SparkMax; |
| 11 | +import com.revrobotics.spark.config.SparkBaseConfig.IdleMode; |
| 12 | +import com.revrobotics.spark.config.SparkMaxConfig; |
| 13 | +import edu.wpi.first.wpilibj.DriverStation; |
| 14 | +import edu.wpi.first.wpilibj2.command.Command; |
| 15 | +import edu.wpi.first.wpilibj2.command.SubsystemBase; |
| 16 | +import frc.robot.Constants; |
| 17 | + |
| 18 | +public class Hopper extends SubsystemBase { |
| 19 | + /** Creates a new Hopper. */ |
| 20 | + SparkMax Hopper = new SparkMax(Constants.HopperConstants.HOPPERID, MotorType.kBrushless); |
| 21 | + |
| 22 | + public Hopper() { |
| 23 | + SparkMaxConfig config = new SparkMaxConfig(); |
| 24 | + config.smartCurrentLimit(50).idleMode(IdleMode.kCoast); |
| 25 | + |
| 26 | + // Persist parameters to retain configuration in the event of a power cycle |
| 27 | + Hopper.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); |
| 28 | + } |
| 29 | + |
| 30 | + public Command SpinCMD() { |
| 31 | + |
| 32 | + return runOnce( |
| 33 | + () -> { |
| 34 | + Hopper.set(1); |
| 35 | + DriverStation.reportWarning("StartHopper", false); |
| 36 | + }); |
| 37 | + } |
| 38 | + |
| 39 | + public Command StopCMD() { |
| 40 | + |
| 41 | + return runOnce( |
| 42 | + () -> { |
| 43 | + Hopper.set(0); |
| 44 | + DriverStation.reportWarning("StopHopper", false); |
| 45 | + }); |
| 46 | + } |
| 47 | + |
| 48 | + @Override |
| 49 | + public void periodic() { |
| 50 | + // This method will be called once per scheduler run |
| 51 | + |
| 52 | + } |
| 53 | +} |
0 commit comments