mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[hal] Notifier: simplify ack API (#8457)
Adding an ack parameter to both set and cancel is cleaner than adding all the set alarm parameters to the ack function. It also provides an ack-and-cancel method.
This commit is contained in:
@@ -71,7 +71,7 @@ PyNotifier::PyNotifier(std::function<void()> handler) {
|
||||
}
|
||||
|
||||
// Ack notifier
|
||||
HAL_AcknowledgeNotifierAlarm(notifier, false, 0, 0, false, &status);
|
||||
HAL_AcknowledgeNotifierAlarm(notifier, &status);
|
||||
WPILIB_CheckErrorStatus(status, "AcknowledgeNotifier");
|
||||
}
|
||||
} catch (...) {
|
||||
@@ -120,6 +120,7 @@ PyNotifier &PyNotifier::operator=(PyNotifier &&rhs) {
|
||||
void PyNotifier::SetName(std::string_view name) {
|
||||
int32_t status = 0;
|
||||
HAL_SetNotifierName(m_notifier, name, &status);
|
||||
WPILIB_CheckErrorStatus(status, "SetNotifierName");
|
||||
}
|
||||
|
||||
void PyNotifier::SetCallback(std::function<void()> handler) {
|
||||
@@ -130,18 +131,21 @@ void PyNotifier::SetCallback(std::function<void()> handler) {
|
||||
void PyNotifier::StartSingle(wpi::units::second_t delay) {
|
||||
int32_t status = 0;
|
||||
HAL_SetNotifierAlarm(m_notifier, static_cast<uint64_t>(delay * 1e6), 0, false,
|
||||
&status);
|
||||
false, &status);
|
||||
WPILIB_CheckErrorStatus(status, "SetNotifierAlarm");
|
||||
}
|
||||
|
||||
void PyNotifier::StartPeriodic(wpi::units::second_t period) {
|
||||
int32_t status = 0;
|
||||
HAL_SetNotifierAlarm(m_notifier, static_cast<uint64_t>(period * 1e6),
|
||||
static_cast<uint64_t>(period * 1e6), false, &status);
|
||||
static_cast<uint64_t>(period * 1e6), false, false,
|
||||
&status);
|
||||
WPILIB_CheckErrorStatus(status, "SetNotifierAlarm");
|
||||
}
|
||||
|
||||
void PyNotifier::Stop() {
|
||||
int32_t status = 0;
|
||||
HAL_CancelNotifierAlarm(m_notifier, &status);
|
||||
HAL_CancelNotifierAlarm(m_notifier, false, &status);
|
||||
WPILIB_CheckErrorStatus(status, "CancelNotifierAlarm");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user