mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] Add methods to check game and enabled state together (#2661)
This avoids users having to call both IsOperatorControl() and IsEnabled() to figure out if their robot is enabled and in the teleop state. The expression above involves calling two methods that each have their own lock. These new methods should only involve locking one mutex, since only one call is made to HAL_GetControlWord().
This commit is contained in:
committed by
GitHub
parent
5d1220e629
commit
526f26685d
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -55,7 +55,7 @@ public class Robot extends RobotBase {
|
||||
m_ds.InAutonomous(true);
|
||||
autonomous();
|
||||
m_ds.InAutonomous(false);
|
||||
while (isAutonomous() && !isDisabled()) {
|
||||
while (isAutonomousEnabled()) {
|
||||
m_ds.waitForData();
|
||||
}
|
||||
} else if (isTest()) {
|
||||
@@ -73,7 +73,7 @@ public class Robot extends RobotBase {
|
||||
m_ds.InOperatorControl(true);
|
||||
teleop();
|
||||
m_ds.InOperatorControl(false);
|
||||
while (isOperatorControl() && !isDisabled()) {
|
||||
while (isOperatorControlEnabled()) {
|
||||
m_ds.waitForData();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user