Initial commit - test serial

This commit is contained in:
Cole A. Deck
2024-03-24 22:20:00 -05:00
commit a4b1c1b7ed
273 changed files with 43716 additions and 0 deletions

View File

@ -0,0 +1,34 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "okapi/impl/util/timeUtilFactory.hpp"
namespace okapi {
/**
* A TimeUtilFactory that supplies the SettledUtil parameters passed in the constructor to every
* new TimeUtil instance.
*/
class ConfigurableTimeUtilFactory : public TimeUtilFactory {
public:
ConfigurableTimeUtilFactory(double iatTargetError = 50,
double iatTargetDerivative = 5,
const QTime &iatTargetTime = 250_ms);
/**
* Creates a TimeUtil with the SettledUtil parameters specified in the constructor by
* delegating to TimeUtilFactory::withSettledUtilParams.
*
* @return A TimeUtil with the SettledUtil parameters specified in the constructor.
*/
TimeUtil create() override;
private:
double atTargetError;
double atTargetDerivative;
QTime atTargetTime;
};
} // namespace okapi

View File

@ -0,0 +1,42 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "okapi/api/util/abstractRate.hpp"
namespace okapi {
class Rate : public AbstractRate {
public:
Rate();
/**
* Delay the current task such that it runs at the given frequency. The first delay will run for
* 1000/(ihz). Subsequent delays will adjust according to the previous runtime of the task.
*
* @param ihz the frequency
*/
void delay(QFrequency ihz) override;
/**
* Delay the current task until itime has passed. This method can be used by periodic tasks to
* ensure a consistent execution frequency.
*
* @param itime the time period
*/
void delayUntil(QTime itime) override;
/**
* Delay the current task until ims milliseconds have passed. This method can be used by
* periodic tasks to ensure a consistent execution frequency.
*
* @param ims the time period
*/
void delayUntil(uint32_t ims) override;
protected:
std::uint32_t lastTime{0};
};
} // namespace okapi

View File

@ -0,0 +1,32 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "okapi/api/util/timeUtil.hpp"
namespace okapi {
class TimeUtilFactory {
public:
virtual ~TimeUtilFactory() = default;
/**
* Creates a default TimeUtil.
*/
virtual TimeUtil create();
/**
* Creates a default TimeUtil.
*/
static TimeUtil createDefault();
/**
* Creates a TimeUtil with custom SettledUtil params. See SettledUtil docs.
*/
static TimeUtil withSettledUtilParams(double iatTargetError = 50,
double iatTargetDerivative = 5,
const QTime &iatTargetTime = 250_ms);
};
} // namespace okapi

View File

@ -0,0 +1,22 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "okapi/api/util/abstractTimer.hpp"
namespace okapi {
class Timer : public AbstractTimer {
public:
Timer();
/**
* Returns the current time in units of QTime.
*
* @return the current time
*/
QTime millis() const override;
};
} // namespace okapi