Convert RobotTime into a singleton

This commit is contained in:
Keenan D. Buckley
2020-03-28 21:42:08 -06:00
parent 850f503889
commit e373211f27
5 changed files with 43 additions and 26 deletions
+6 -5
View File
@@ -21,7 +21,8 @@ import frc4388.utility.RobotTime;
*/
public class Robot extends TimedRobot {
Command m_autonomousCommand;
private RobotTime m_robotTime = RobotTime.getInstance();
private RobotContainer m_robotContainer;
/**
@@ -45,7 +46,7 @@ public class Robot extends TimedRobot {
*/
@Override
public void robotPeriodic() {
RobotTime.updateTimes();
m_robotTime.updateTimes();
// Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled
// commands, running already-scheduled commands, removing finished or interrupted commands,
// and running subsystem periodic() methods. This must be called from the robot's periodic
@@ -60,7 +61,7 @@ public class Robot extends TimedRobot {
*/
@Override
public void disabledInit() {
RobotTime.endMatchTime();
m_robotTime.endMatchTime();
}
@Override
@@ -85,7 +86,7 @@ public class Robot extends TimedRobot {
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
}
RobotTime.startMatchTime();
m_robotTime.startMatchTime();
}
/**
@@ -104,7 +105,7 @@ public class Robot extends TimedRobot {
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
}
RobotTime.startMatchTime();
m_robotTime.startMatchTime();
}
/**
+4 -5
View File
@@ -25,15 +25,14 @@ import frc4388.utility.RobotGyro;
public class RobotMap {
public RobotMap() {
configureLEDSubsystem();
configureDriveSubsystem();
configureLEDMotorControllers();
configureDriveMotorControllers();
}
/* LED Subsystem */
public final Spark LEDController = new Spark(LEDConstants.LED_SPARK_ID);
void configureLEDSubsystem() {
void configureLEDMotorControllers() {
}
/* Drive Subsystem */
@@ -44,7 +43,7 @@ public class RobotMap {
public final DifferentialDrive driveTrain = new DifferentialDrive(leftFrontMotor, rightFrontMotor);
public final RobotGyro gyroDrive = new RobotGyro(new PigeonIMU(DriveConstants.DRIVE_PIGEON_ID));
void configureDriveSubsystem() {
void configureDriveMotorControllers() {
/* factory default values */
leftFrontMotor.configFactoryDefault();
@@ -24,6 +24,8 @@ public class Drive extends SubsystemBase {
// Put methods for controlling this subsystem
// here. Call these from Commands.
private RobotTime m_robotTime = RobotTime.getInstance();
private WPI_TalonSRX m_leftFrontMotor;
private WPI_TalonSRX m_rightFrontMotor;
private WPI_TalonSRX m_leftBackMotor;
@@ -49,7 +51,7 @@ public class Drive extends SubsystemBase {
public void periodic() {
m_gyro.updatePigeonDeltas();
if (RobotTime.m_frameNumber % DriveConstants.SMARTDASHBOARD_UPDATE_FRAME == 0) {
if (m_robotTime.m_frameNumber % DriveConstants.SMARTDASHBOARD_UPDATE_FRAME == 0) {
updateSmartDashboard();
}
}