File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ public class Constants {
12
12
13
13
public static final double kLoopPeriodSecs = 0.02 ;
14
14
15
+ public static final double LOW_VOLTAGE_WARNING_THRESHOLD = 10.0 ;
16
+
15
17
public enum RobotMode {
16
18
REAL ,
17
19
SIM ,
Original file line number Diff line number Diff line change 13
13
14
14
package frc .robot ;
15
15
16
+ import edu .wpi .first .math .filter .Debouncer ;
17
+ import edu .wpi .first .wpilibj .Alert ;
16
18
import edu .wpi .first .wpilibj .DriverStation ;
17
19
import edu .wpi .first .wpilibj .RobotController ;
18
20
import edu .wpi .first .wpilibj .Threads ;
@@ -37,6 +39,10 @@ public class Robot extends LoggedRobot {
37
39
private Command autonomousCommand ;
38
40
private final RobotContainer robotContainer ;
39
41
42
+ private final Alert lowBatteryVoltageAlert =
43
+ new Alert ("Battery voltage is too low, change the battery" , Alert .AlertType .kWarning );
44
+ private final Debouncer batteryVoltageDebouncer = new Debouncer (0.5 );
45
+
40
46
public Robot () {
41
47
super (Constants .kLoopPeriodSecs );
42
48
@@ -86,6 +92,11 @@ public void robotPeriodic() {
86
92
// Run command scheduler
87
93
CommandScheduler .getInstance ().run ();
88
94
95
+ // Update Battery Voltage Alert
96
+ lowBatteryVoltageAlert .set (
97
+ batteryVoltageDebouncer .calculate (
98
+ RobotController .getBatteryVoltage () <= Constants .LOW_VOLTAGE_WARNING_THRESHOLD ));
99
+
89
100
// Return to normal thread priority
90
101
Threads .setCurrentThreadPriority (false , 10 );
91
102
}
You can’t perform that action at this time.
0 commit comments