[hal,wpilib] Rename DriverStation constants to all caps

This commit is contained in:
Peter Johnson
2026-03-13 01:04:29 -07:00
parent 614eb1db18
commit 227f01f3bd
51 changed files with 555 additions and 550 deletions

View File

@@ -29,7 +29,7 @@ HAL_RobotMode getDSMode(void) {
// We send the observes, otherwise the DS disables
HAL_ObserveUserProgram(word);
return HAL_ControlWord_IsEnabled(word) ? HAL_ControlWord_GetRobotMode(word)
: HAL_ROBOTMODE_UNKNOWN;
: HAL_ROBOT_MODE_UNKNOWN;
}
int main(void) {
@@ -44,19 +44,19 @@ int main(void) {
// Create an opmode per robot mode
static struct HAL_OpModeOption opmodes[] = {
{HAL_MAKE_OPMODEID(HAL_ROBOTMODE_AUTONOMOUS, 0),
{HAL_MAKE_OPMODEID(HAL_ROBOT_MODE_AUTONOMOUS, 0),
{"Auto", 4},
{"", 0},
{"", 0},
-1,
-1},
{HAL_MAKE_OPMODEID(HAL_ROBOTMODE_TELEOPERATED, 0),
{HAL_MAKE_OPMODEID(HAL_ROBOT_MODE_TELEOPERATED, 0),
{"Teleop", 6},
{"", 0},
{"", 0},
-1,
-1},
{HAL_MAKE_OPMODEID(HAL_ROBOTMODE_TEST, 0),
{HAL_MAKE_OPMODEID(HAL_ROBOT_MODE_TEST, 0),
{"Test", 4},
{"", 0},
{"", 0},
@@ -104,9 +104,9 @@ int main(void) {
HAL_RobotMode dsMode = getDSMode();
switch (dsMode) {
case HAL_ROBOTMODE_UNKNOWN:
case HAL_ROBOT_MODE_UNKNOWN:
break;
case HAL_ROBOTMODE_TELEOPERATED:
case HAL_ROBOT_MODE_TELEOPERATED:
status = 0;
if (HAL_GetDIO(dio, &status)) {
HAL_SetPWMPulseTimeMicroseconds(pwmPort, 2000, &status);
@@ -114,9 +114,9 @@ int main(void) {
HAL_SetPWMPulseTimeMicroseconds(pwmPort, 1500, &status);
}
break;
case HAL_ROBOTMODE_AUTONOMOUS:
case HAL_ROBOT_MODE_AUTONOMOUS:
break;
case HAL_ROBOTMODE_TEST:
case HAL_ROBOT_MODE_TEST:
break;
default:
break;

View File

@@ -9,7 +9,7 @@
void Robot::RobotPeriodic() {
// pull alliance port high if on red alliance, pull low if on blue alliance
m_allianceOutput.Set(wpi::DriverStation::GetAlliance() ==
wpi::DriverStation::kRed);
wpi::DriverStation::Alliance::RED);
// pull enabled port high if enabled, low if disabled
m_enabledOutput.Set(wpi::DriverStation::IsEnabled());

View File

@@ -25,7 +25,7 @@ void Robot::RobotPeriodic() {
std::string allianceString = "U";
auto alliance = wpi::DriverStation::GetAlliance();
if (alliance.has_value()) {
if (alliance == wpi::DriverStation::Alliance::kRed) {
if (alliance == wpi::DriverStation::Alliance::RED) {
allianceString = "R";
} else {
allianceString = "B";

View File

@@ -56,7 +56,7 @@ TEST_P(ArmSimulationTest, Teleop) {
// teleop init
{
wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TELEOPERATED);
wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED);
wpi::sim::DriverStationSim::SetEnabled(true);
wpi::sim::DriverStationSim::NotifyNewData();

View File

@@ -52,7 +52,7 @@ class ElevatorSimulationTest : public testing::Test {
TEST_F(ElevatorSimulationTest, Teleop) {
// teleop init
{
wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TELEOPERATED);
wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED);
wpi::sim::DriverStationSim::SetEnabled(true);
wpi::sim::DriverStationSim::NotifyNewData();

View File

@@ -57,15 +57,15 @@ TEST_P(AllianceTest, Alliance) {
bool isRed = false;
switch (alliance) {
case HAL_AllianceStationID_kBlue1:
case HAL_AllianceStationID_kBlue2:
case HAL_AllianceStationID_kBlue3:
case HAL_AllianceStationID_kUnknown:
case HAL_ALLIANCE_STATION_BLUE_1:
case HAL_ALLIANCE_STATION_BLUE_2:
case HAL_ALLIANCE_STATION_BLUE_3:
case HAL_ALLIANCE_STATION_UNKNOWN:
isRed = false;
break;
case HAL_AllianceStationID_kRed1:
case HAL_AllianceStationID_kRed2:
case HAL_AllianceStationID_kRed3:
case HAL_ALLIANCE_STATION_RED_1:
case HAL_ALLIANCE_STATION_RED_2:
case HAL_ALLIANCE_STATION_RED_3:
isRed = true;
break;
}
@@ -75,25 +75,25 @@ TEST_P(AllianceTest, Alliance) {
INSTANTIATE_TEST_SUITE_P(
DigitalCommunicationTests, AllianceTest,
testing::Values<HAL_AllianceStationID>(
HAL_AllianceStationID_kRed1, HAL_AllianceStationID_kRed2,
HAL_AllianceStationID_kRed3, HAL_AllianceStationID_kBlue1,
HAL_AllianceStationID_kBlue2, HAL_AllianceStationID_kBlue3,
HAL_AllianceStationID_kUnknown),
HAL_ALLIANCE_STATION_RED_1, HAL_ALLIANCE_STATION_RED_2,
HAL_ALLIANCE_STATION_RED_3, HAL_ALLIANCE_STATION_BLUE_1,
HAL_ALLIANCE_STATION_BLUE_2, HAL_ALLIANCE_STATION_BLUE_3,
HAL_ALLIANCE_STATION_UNKNOWN),
[](const testing::TestParamInfo<AllianceTest::ParamType>& info) {
switch (info.param) {
case HAL_AllianceStationID_kBlue1:
case HAL_ALLIANCE_STATION_BLUE_1:
return std::string{"Blue1"};
case HAL_AllianceStationID_kBlue2:
case HAL_ALLIANCE_STATION_BLUE_2:
return std::string{"Blue2"};
case HAL_AllianceStationID_kBlue3:
case HAL_ALLIANCE_STATION_BLUE_3:
return std::string{"Blue3"};
case HAL_AllianceStationID_kRed1:
case HAL_ALLIANCE_STATION_RED_1:
return std::string{"Red1"};
case HAL_AllianceStationID_kRed2:
case HAL_ALLIANCE_STATION_RED_2:
return std::string{"Red2"};
case HAL_AllianceStationID_kRed3:
case HAL_ALLIANCE_STATION_RED_3:
return std::string{"Red3"};
case HAL_AllianceStationID_kUnknown:
case HAL_ALLIANCE_STATION_UNKNOWN:
return std::string{"Unknown"};
}
return std::string{"Error"};
@@ -122,7 +122,7 @@ class AutonomousTest : public DigitalCommunicationTest<bool> {};
TEST_P(AutonomousTest, Autonomous) {
auto autonomous = GetParam();
wpi::sim::DriverStationSim::SetRobotMode(
autonomous ? HAL_ROBOTMODE_AUTONOMOUS : HAL_ROBOTMODE_TELEOPERATED);
autonomous ? HAL_ROBOT_MODE_AUTONOMOUS : HAL_ROBOT_MODE_TELEOPERATED);
wpi::sim::DriverStationSim::NotifyNewData();
EXPECT_TRUE(m_autonomousOutput.GetInitialized());

View File

@@ -65,17 +65,17 @@ TEST_P(AllianceTest, Alliance) {
char expected = 'U';
switch (alliance) {
case HAL_AllianceStationID_kBlue1:
case HAL_AllianceStationID_kBlue2:
case HAL_AllianceStationID_kBlue3:
case HAL_ALLIANCE_STATION_BLUE_1:
case HAL_ALLIANCE_STATION_BLUE_2:
case HAL_ALLIANCE_STATION_BLUE_3:
expected = 'B';
break;
case HAL_AllianceStationID_kRed1:
case HAL_AllianceStationID_kRed2:
case HAL_AllianceStationID_kRed3:
case HAL_ALLIANCE_STATION_RED_1:
case HAL_ALLIANCE_STATION_RED_2:
case HAL_ALLIANCE_STATION_RED_3:
expected = 'R';
break;
case HAL_AllianceStationID_kUnknown:
case HAL_ALLIANCE_STATION_UNKNOWN:
expected = 'U';
break;
}
@@ -85,25 +85,25 @@ TEST_P(AllianceTest, Alliance) {
INSTANTIATE_TEST_SUITE_P(
I2CCommunicationTests, AllianceTest,
testing::Values<HAL_AllianceStationID>(
HAL_AllianceStationID_kRed1, HAL_AllianceStationID_kRed2,
HAL_AllianceStationID_kRed3, HAL_AllianceStationID_kBlue1,
HAL_AllianceStationID_kBlue2, HAL_AllianceStationID_kBlue3,
HAL_AllianceStationID_kUnknown),
HAL_ALLIANCE_STATION_RED_1, HAL_ALLIANCE_STATION_RED_2,
HAL_ALLIANCE_STATION_RED_3, HAL_ALLIANCE_STATION_BLUE_1,
HAL_ALLIANCE_STATION_BLUE_2, HAL_ALLIANCE_STATION_BLUE_3,
HAL_ALLIANCE_STATION_UNKNOWN),
[](const testing::TestParamInfo<AllianceTest::ParamType>& info) {
switch (info.param) {
case HAL_AllianceStationID_kBlue1:
case HAL_ALLIANCE_STATION_BLUE_1:
return std::string{"Blue1"};
case HAL_AllianceStationID_kBlue2:
case HAL_ALLIANCE_STATION_BLUE_2:
return std::string{"Blue2"};
case HAL_AllianceStationID_kBlue3:
case HAL_ALLIANCE_STATION_BLUE_3:
return std::string{"Blue3"};
case HAL_AllianceStationID_kRed1:
case HAL_ALLIANCE_STATION_RED_1:
return std::string{"Red1"};
case HAL_AllianceStationID_kRed2:
case HAL_ALLIANCE_STATION_RED_2:
return std::string{"Red2"};
case HAL_AllianceStationID_kRed3:
case HAL_ALLIANCE_STATION_RED_3:
return std::string{"Red3"};
case HAL_AllianceStationID_kUnknown:
case HAL_ALLIANCE_STATION_UNKNOWN:
return std::string{"Unknown"};
}
return std::string{"Error"};
@@ -132,7 +132,7 @@ class AutonomousTest : public I2CCommunicationTest<bool> {};
TEST_P(AutonomousTest, Autonomous) {
auto autonomous = GetParam();
wpi::sim::DriverStationSim::SetRobotMode(
autonomous ? HAL_ROBOTMODE_AUTONOMOUS : HAL_ROBOTMODE_TELEOPERATED);
autonomous ? HAL_ROBOT_MODE_AUTONOMOUS : HAL_ROBOT_MODE_TELEOPERATED);
wpi::sim::DriverStationSim::NotifyNewData();
EXPECT_TRUE(HALSIM_GetI2CInitialized(m_port));