Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
import frc.robot.LimelightHelpers.PoseEstimate;

public class Robot extends TimedRobot {

private static final double kLowBatteryVoltage = 11.8;
private static final double kLowBatteryDisabledTime = 1.5; //seconds

private final Timer batteryTimer = new Timer();
private boolean lowBatteryAlert = false;


private Command m_autonomousCommand;

private final RobotContainer m_container = new RobotContainer();
Expand Down Expand Up @@ -124,6 +132,8 @@ public void robotInit() {
DriverStation.silenceJoystickConnectionWarning(true);
}

batteryTimer.start();

}

@Override
Expand Down Expand Up @@ -164,6 +174,19 @@ public void robotPeriodic() {
}
*/
}

if(DriverStation.isEnabled()){
batteryTimer.reset();
}
double batteryVoltage = RobotController.getBatteryVoltage();

if(batteryVoltage<= kLowBatteryVoltage && batteryTimer.hasElapsed(kLowBatteryDisabledTime)){
lowBatteryAlert = true;
} else {
lowBatteryAlert = false;
}

SmartDashboard.putBoolean("LowBattery", lowBatteryAlert);
}

@Override
Expand Down Expand Up @@ -221,4 +244,4 @@ public void simulationPeriodic() {
// If you have physics simulation, put it here
// For now: do nothing fast
}
}
}