[commands] Remove deprecated classes and functions (#5409)

Removes:
- PerpetualCommand
- Command.perpetually()
- CommandGroupBase
- Command.IsGrouped() (C++ only)
- Command.SetGrouped() (C++ only)
- Command.withInterrupt()
- ProxyScheduleCommand
- Button
- InternalButton, JoystickButton, NetworkButton and POVButton now subclass Trigger
- Old style Trigger functions:
    - Trigger.whenActive
    - Trigger.whileActiveOnce
    - Trigger.whileActiveContinuous
    - Trigger.whenInactive
    - Trigger.toggleWhenActive
    - Trigger.cancelWhenActive
- CommandScheduler.clearButtons()
- CommandScheduler.addButtons() (Java only)
- Command supplier constructor of SelectCommand
This commit is contained in:
Ryan Blue
2023-07-10 12:56:18 -04:00
committed by GitHub
parent b250a03944
commit 7a099cb02a
49 changed files with 82 additions and 2031 deletions

View File

@@ -5,7 +5,6 @@
#include "frc2/command/button/Trigger.h"
#include <frc/filter/Debouncer.h>
#include <wpi/deprecated.h>
#include "frc2/command/InstantCommand.h"
@@ -206,124 +205,6 @@ Trigger Trigger::ToggleOnFalse(CommandPtr&& command) {
return *this;
}
WPI_IGNORE_DEPRECATED
Trigger Trigger::WhenActive(Command* command) {
return OnTrue(command);
}
Trigger Trigger::WhenActive(std::function<void()> toRun,
std::initializer_list<Subsystem*> requirements) {
return WhenActive(std::move(toRun),
{requirements.begin(), requirements.end()});
}
Trigger Trigger::WhenActive(std::function<void()> toRun,
std::span<Subsystem* const> requirements) {
return WhenActive(InstantCommand(std::move(toRun), requirements));
}
Trigger Trigger::WhileActiveContinous(Command* command) {
m_loop->Bind([condition = m_condition, previous = m_condition(),
command = std::move(command)]() mutable {
bool current = condition();
if (current) {
command->Schedule();
} else if (previous && !current) {
command->Cancel();
}
previous = current;
});
return *this;
}
Trigger Trigger::WhileActiveContinous(
std::function<void()> toRun,
std::initializer_list<Subsystem*> requirements) {
return WhileActiveContinous(std::move(toRun),
{requirements.begin(), requirements.end()});
}
Trigger Trigger::WhileActiveContinous(
std::function<void()> toRun, std::span<Subsystem* const> requirements) {
return WhileActiveContinous(InstantCommand(std::move(toRun), requirements));
}
Trigger Trigger::WhileActiveOnce(Command* command) {
m_loop->Bind(
[condition = m_condition, previous = m_condition(), command]() mutable {
bool current = condition();
if (!previous && current) {
command->Schedule();
} else if (previous && !current) {
command->Cancel();
}
previous = current;
});
return *this;
}
Trigger Trigger::WhenInactive(Command* command) {
m_loop->Bind(
[condition = m_condition, previous = m_condition(), command]() mutable {
bool current = condition();
if (previous && !current) {
command->Schedule();
}
previous = current;
});
return *this;
}
Trigger Trigger::WhenInactive(std::function<void()> toRun,
std::initializer_list<Subsystem*> requirements) {
return WhenInactive(std::move(toRun),
{requirements.begin(), requirements.end()});
}
Trigger Trigger::WhenInactive(std::function<void()> toRun,
std::span<Subsystem* const> requirements) {
return WhenInactive(InstantCommand(std::move(toRun), requirements));
}
Trigger Trigger::ToggleWhenActive(Command* command) {
m_loop->Bind([condition = m_condition, previous = m_condition(),
command = command]() mutable {
bool current = condition();
if (!previous && current) {
if (command->IsScheduled()) {
command->Cancel();
} else {
command->Schedule();
}
}
previous = current;
});
return *this;
}
Trigger Trigger::CancelWhenActive(Command* command) {
m_loop->Bind([condition = m_condition, previous = m_condition(),
command = std::move(command)]() mutable {
bool current = condition();
if (!previous && current) {
command->Cancel();
}
previous = current;
});
return *this;
}
WPI_UNIGNORE_DEPRECATED
Trigger Trigger::Debounce(units::second_t debounceTime,
frc::Debouncer::DebounceType type) {
return Trigger(m_loop, [debouncer = frc::Debouncer(debounceTime, type),