mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
[wpilib] Split DriverStation into smaller classes (#8628)
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "wpi/commands2/CommandPtr.hpp"
|
||||
#include "wpi/commands2/Subsystem.hpp"
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/driverstation/RobotState.hpp"
|
||||
#include "wpi/framework/RobotBase.hpp"
|
||||
#include "wpi/framework/TimedRobot.hpp"
|
||||
#include "wpi/hal/UsageReporting.hpp"
|
||||
@@ -99,7 +99,7 @@ void CommandScheduler::Schedule(Command* command) {
|
||||
RequireUngrouped(command);
|
||||
|
||||
if (m_impl->disabled || m_impl->scheduledCommands.contains(command) ||
|
||||
(wpi::DriverStation::IsDisabled() && !command->RunsWhenDisabled())) {
|
||||
(wpi::RobotState::IsDisabled() && !command->RunsWhenDisabled())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ void CommandScheduler::Run() {
|
||||
loopCache->Poll();
|
||||
m_watchdog.AddEpoch("buttons.Run()");
|
||||
|
||||
bool isDisabled = wpi::DriverStation::IsDisabled();
|
||||
bool isDisabled = wpi::RobotState::IsDisabled();
|
||||
// create a new set to avoid iterator invalidation.
|
||||
for (Command* command : wpi::util::SmallSet(m_impl->scheduledCommands)) {
|
||||
if (!IsScheduled(command)) {
|
||||
|
||||
@@ -16,51 +16,51 @@ Trigger CommandGenericHID::Button(int button, wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, button] { return m_hid.GetRawButton(button); });
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POV(wpi::DriverStation::POVDirection angle,
|
||||
Trigger CommandGenericHID::POV(wpi::POVDirection angle,
|
||||
wpi::EventLoop* loop) const {
|
||||
return POV(0, angle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POV(int pov, wpi::DriverStation::POVDirection angle,
|
||||
Trigger CommandGenericHID::POV(int pov, wpi::POVDirection angle,
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop,
|
||||
[this, pov, angle] { return m_hid.GetPOV(pov) == angle; });
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUp(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::UP, loop);
|
||||
return POV(wpi::POVDirection::UP, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUpRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::UP_RIGHT, loop);
|
||||
return POV(wpi::POVDirection::UP_RIGHT, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::RIGHT, loop);
|
||||
return POV(wpi::POVDirection::RIGHT, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDownRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::DOWN_RIGHT, loop);
|
||||
return POV(wpi::POVDirection::DOWN_RIGHT, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDown(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::DOWN, loop);
|
||||
return POV(wpi::POVDirection::DOWN, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDownLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::DOWN_LEFT, loop);
|
||||
return POV(wpi::POVDirection::DOWN_LEFT, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::LEFT, loop);
|
||||
return POV(wpi::POVDirection::LEFT, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUpLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::UP_LEFT, loop);
|
||||
return POV(wpi::POVDirection::UP_LEFT, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVCenter(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::CENTER, loop);
|
||||
return POV(wpi::POVDirection::CENTER, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::AxisLessThan(int axis, double threshold,
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
|
||||
#include "wpi/commands2/button/RobotModeTriggers.hpp"
|
||||
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/driverstation/RobotState.hpp"
|
||||
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Trigger RobotModeTriggers::Autonomous() {
|
||||
return Trigger{&wpi::DriverStation::IsAutonomousEnabled};
|
||||
return Trigger{&wpi::RobotState::IsAutonomousEnabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Teleop() {
|
||||
return Trigger{&wpi::DriverStation::IsTeleopEnabled};
|
||||
return Trigger{&wpi::RobotState::IsTeleopEnabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Disabled() {
|
||||
return Trigger{&wpi::DriverStation::IsDisabled};
|
||||
return Trigger{&wpi::RobotState::IsDisabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Test() {
|
||||
return Trigger{&wpi::DriverStation::IsTestEnabled};
|
||||
return Trigger{&wpi::RobotState::IsTestEnabled};
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/driverstation/GenericHID.hpp"
|
||||
#include "wpi/driverstation/POVDirection.hpp"
|
||||
#include "wpi/driverstation/internal/DriverStationBackend.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
|
||||
@@ -56,7 +57,7 @@ class CommandGenericHID {
|
||||
* @param angle POV angle.
|
||||
* @return a Trigger instance based around this angle of a POV on the HID.
|
||||
*/
|
||||
Trigger POV(wpi::DriverStation::POVDirection angle,
|
||||
Trigger POV(wpi::POVDirection angle,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
@@ -70,7 +71,7 @@ class CommandGenericHID {
|
||||
* @param angle POV angle.
|
||||
* @return a Trigger instance based around this angle of a POV on the HID.
|
||||
*/
|
||||
Trigger POV(int pov, wpi::DriverStation::POVDirection angle,
|
||||
Trigger POV(int pov, wpi::POVDirection angle,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/driverstation/GenericHID.hpp"
|
||||
#include "wpi/driverstation/POVDirection.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ class POVButton : public Trigger {
|
||||
* @param angle The angle of the POV corresponding to a button press.
|
||||
* @param povNumber The number of the POV on the joystick.
|
||||
*/
|
||||
POVButton(wpi::GenericHID* joystick, wpi::DriverStation::POVDirection angle,
|
||||
POVButton(wpi::GenericHID* joystick, wpi::POVDirection angle,
|
||||
int povNumber = 0)
|
||||
: Trigger([joystick, angle, povNumber] {
|
||||
return joystick->GetPOV(povNumber) == angle;
|
||||
|
||||
Reference in New Issue
Block a user