mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[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:
@@ -1,101 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc2/command/button/Button.h"
|
||||
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
Button::Button(std::function<bool()> isPressed) : Trigger(isPressed) {}
|
||||
|
||||
Button Button::WhenPressed(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenActive(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenPressed(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenActive(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenPressed(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenActive(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhileHeld(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhileActiveContinous(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhileHeld(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhileActiveContinous(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhileHeld(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhileActiveContinous(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenHeld(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhileActiveOnce(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenReleased(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenInactive(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenReleased(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenInactive(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenReleased(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenInactive(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::ToggleWhenPressed(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
ToggleWhenActive(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::CancelWhenPressed(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
CancelWhenActive(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
@@ -4,19 +4,15 @@
|
||||
|
||||
#include "frc2/command/button/NetworkButton.h"
|
||||
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
NetworkButton::NetworkButton(nt::BooleanTopic topic)
|
||||
: NetworkButton(topic.Subscribe(false)) {}
|
||||
|
||||
NetworkButton::NetworkButton(nt::BooleanSubscriber sub)
|
||||
: Button([sub = std::make_shared<nt::BooleanSubscriber>(std::move(sub))] {
|
||||
: Trigger([sub = std::make_shared<nt::BooleanSubscriber>(std::move(sub))] {
|
||||
return sub->GetTopic().GetInstance().IsConnected() && sub->Get();
|
||||
}) {}
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
NetworkButton::NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
std::string_view field)
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user