Merge branch 'main' into 2027

This commit is contained in:
Peter Johnson
2025-11-01 09:39:08 -07:00
61 changed files with 455 additions and 941 deletions

View File

@@ -181,6 +181,10 @@ void Notifier::StartPeriodic(units::second_t period) {
UpdateAlarm();
}
void Notifier::StartPeriodic(units::hertz_t frequency) {
StartPeriodic(1 / frequency);
}
void Notifier::Stop() {
std::scoped_lock lock(m_processMutex);
m_periodic = false;

View File

@@ -88,6 +88,8 @@ TimedRobot::TimedRobot(units::second_t period) : IterativeRobotBase(period) {
HAL_ReportUsage("Framework", "TimedRobot");
}
TimedRobot::TimedRobot(units::hertz_t frequency) : TimedRobot{1 / frequency} {}
TimedRobot::~TimedRobot() {
if (m_notifier != HAL_kInvalidHandle) {
int32_t status = 0;

View File

@@ -14,6 +14,7 @@
#include <utility>
#include <hal/Types.h>
#include <units/frequency.h>
#include <units/time.h>
#include <wpi/mutex.h>
@@ -107,6 +108,17 @@ class Notifier {
*/
void StartPeriodic(units::second_t period);
/**
* Run the callback periodically with the given frequency.
*
* The user-provided callback should be written so that it completes before
* the next time it's scheduled to run.
*
* @param frequency Frequency after which to call the callback starting one
* period after the call to this method.
*/
void StartPeriodic(units::hertz_t frequency);
/**
* Stop further callback invocations.
*

View File

@@ -11,6 +11,7 @@
#include <hal/Notifier.h>
#include <hal/Types.h>
#include <units/frequency.h>
#include <units/math.h>
#include <units/time.h>
#include <wpi/priority_queue.h>
@@ -47,10 +48,17 @@ class TimedRobot : public IterativeRobotBase {
/**
* Constructor for TimedRobot.
*
* @param period Period.
* @param period The period of the robot loop function.
*/
explicit TimedRobot(units::second_t period = kDefaultPeriod);
/**
* Constructor for TimedRobot.
*
* @param frequency The frequency of the robot loop function.
*/
explicit TimedRobot(units::hertz_t frequency);
TimedRobot(TimedRobot&&) = default;
TimedRobot& operator=(TimedRobot&&) = default;