mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Moved C++ comments from source files to headers (#1111)
Also sorted functions in C++ sources to match order in related headers.
This commit is contained in:
committed by
Peter Johnson
parent
d9971a705a
commit
8c680a26f8
@@ -16,19 +16,6 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
/**
|
||||
* Create an instance of a counter where no sources are selected.
|
||||
*
|
||||
* They all must be selected by calling functions to specify the upsource and
|
||||
* the downsource independently.
|
||||
*
|
||||
* This creates a ChipObject counter and initializes status variables
|
||||
* appropriately.
|
||||
*
|
||||
* The counter will start counting immediately.
|
||||
*
|
||||
* @param mode The counter mode
|
||||
*/
|
||||
Counter::Counter(Mode mode) {
|
||||
int32_t status = 0;
|
||||
m_counter = HAL_InitializeCounter((HAL_Counter_Mode)mode, &m_index, &status);
|
||||
@@ -40,82 +27,26 @@ Counter::Counter(Mode mode) {
|
||||
SetName("Counter", m_index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a counter from a Digital Source (such as a Digital
|
||||
* Input).
|
||||
*
|
||||
* This is used if an existing digital input is to be shared by multiple other
|
||||
* objects such as encoders or if the Digital Source is not a Digital Input
|
||||
* channel (such as an Analog Trigger).
|
||||
*
|
||||
* The counter will start counting immediately.
|
||||
* @param source A pointer to the existing DigitalSource object. It will be set
|
||||
* as the Up Source.
|
||||
*/
|
||||
Counter::Counter(DigitalSource* source) : Counter(kTwoPulse) {
|
||||
SetUpSource(source);
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a counter from a Digital Source (such as a Digital
|
||||
* Input).
|
||||
*
|
||||
* This is used if an existing digital input is to be shared by multiple other
|
||||
* objects such as encoders or if the Digital Source is not a Digital Input
|
||||
* channel (such as an Analog Trigger).
|
||||
*
|
||||
* The counter will start counting immediately.
|
||||
*
|
||||
* @param source A pointer to the existing DigitalSource object. It will be
|
||||
* set as the Up Source.
|
||||
*/
|
||||
Counter::Counter(std::shared_ptr<DigitalSource> source) : Counter(kTwoPulse) {
|
||||
SetUpSource(source);
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a Counter object.
|
||||
*
|
||||
* Create an up-Counter instance given a channel.
|
||||
*
|
||||
* The counter will start counting immediately.
|
||||
*
|
||||
* @param channel The DIO channel to use as the up source. 0-9 are on-board,
|
||||
* 10-25 are on the MXP
|
||||
*/
|
||||
Counter::Counter(int channel) : Counter(kTwoPulse) {
|
||||
SetUpSource(channel);
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a Counter object.
|
||||
*
|
||||
* Create an instance of a simple up-Counter given an analog trigger.
|
||||
* Use the trigger state output from the analog trigger.
|
||||
*
|
||||
* The counter will start counting immediately.
|
||||
*
|
||||
* @param trigger The reference to the existing AnalogTrigger object.
|
||||
*/
|
||||
Counter::Counter(DigitalSource* source) : Counter(kTwoPulse) {
|
||||
SetUpSource(source);
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
Counter::Counter(std::shared_ptr<DigitalSource> source) : Counter(kTwoPulse) {
|
||||
SetUpSource(source);
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
Counter::Counter(const AnalogTrigger& trigger) : Counter(kTwoPulse) {
|
||||
SetUpSource(trigger.CreateOutput(AnalogTriggerType::kState));
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a Counter object.
|
||||
*
|
||||
* Creates a full up-down counter given two Digital Sources.
|
||||
*
|
||||
* @param encodingType The quadrature decoding mode (1x or 2x)
|
||||
* @param upSource The pointer to the DigitalSource to set as the up source
|
||||
* @param downSource The pointer to the DigitalSource to set as the down
|
||||
* source
|
||||
* @param inverted True to invert the output (reverse the direction)
|
||||
*/
|
||||
Counter::Counter(EncodingType encodingType, DigitalSource* upSource,
|
||||
DigitalSource* downSource, bool inverted)
|
||||
: Counter(encodingType,
|
||||
@@ -125,17 +56,6 @@ Counter::Counter(EncodingType encodingType, DigitalSource* upSource,
|
||||
NullDeleter<DigitalSource>()),
|
||||
inverted) {}
|
||||
|
||||
/**
|
||||
* Create an instance of a Counter object.
|
||||
*
|
||||
* Creates a full up-down counter given two Digital Sources.
|
||||
*
|
||||
* @param encodingType The quadrature decoding mode (1x or 2x)
|
||||
* @param upSource The pointer to the DigitalSource to set as the up source
|
||||
* @param downSource The pointer to the DigitalSource to set as the down
|
||||
* source
|
||||
* @param inverted True to invert the output (reverse the direction)
|
||||
*/
|
||||
Counter::Counter(EncodingType encodingType,
|
||||
std::shared_ptr<DigitalSource> upSource,
|
||||
std::shared_ptr<DigitalSource> downSource, bool inverted)
|
||||
@@ -162,9 +82,6 @@ Counter::Counter(EncodingType encodingType,
|
||||
SetDownSourceEdge(inverted, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the Counter object.
|
||||
*/
|
||||
Counter::~Counter() {
|
||||
SetUpdateWhenEmpty(true);
|
||||
|
||||
@@ -174,24 +91,12 @@ Counter::~Counter() {
|
||||
m_counter = HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the upsource for the counter as a digital input channel.
|
||||
*
|
||||
* @param channel The DIO channel to use as the up source. 0-9 are on-board,
|
||||
* 10-25 are on the MXP
|
||||
*/
|
||||
void Counter::SetUpSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetUpSource(std::make_shared<DigitalInput>(channel));
|
||||
AddChild(m_upSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the up counting source to be an analog trigger.
|
||||
*
|
||||
* @param analogTrigger The analog trigger object that is used for the Up Source
|
||||
* @param triggerType The analog trigger output that will trigger the counter.
|
||||
*/
|
||||
void Counter::SetUpSource(AnalogTrigger* analogTrigger,
|
||||
AnalogTriggerType triggerType) {
|
||||
SetUpSource(std::shared_ptr<AnalogTrigger>(analogTrigger,
|
||||
@@ -199,25 +104,17 @@ void Counter::SetUpSource(AnalogTrigger* analogTrigger,
|
||||
triggerType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the up counting source to be an analog trigger.
|
||||
*
|
||||
* @param analogTrigger The analog trigger object that is used for the Up Source
|
||||
* @param triggerType The analog trigger output that will trigger the counter.
|
||||
*/
|
||||
void Counter::SetUpSource(std::shared_ptr<AnalogTrigger> analogTrigger,
|
||||
AnalogTriggerType triggerType) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetUpSource(analogTrigger->CreateOutput(triggerType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source object that causes the counter to count up.
|
||||
*
|
||||
* Set the up counting DigitalSource.
|
||||
*
|
||||
* @param source Pointer to the DigitalSource object to set as the up source
|
||||
*/
|
||||
void Counter::SetUpSource(DigitalSource* source) {
|
||||
SetUpSource(
|
||||
std::shared_ptr<DigitalSource>(source, NullDeleter<DigitalSource>()));
|
||||
}
|
||||
|
||||
void Counter::SetUpSource(std::shared_ptr<DigitalSource> source) {
|
||||
if (StatusIsFatal()) return;
|
||||
m_upSource = source;
|
||||
@@ -233,31 +130,11 @@ void Counter::SetUpSource(std::shared_ptr<DigitalSource> source) {
|
||||
}
|
||||
}
|
||||
|
||||
void Counter::SetUpSource(DigitalSource* source) {
|
||||
SetUpSource(
|
||||
std::shared_ptr<DigitalSource>(source, NullDeleter<DigitalSource>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source object that causes the counter to count up.
|
||||
*
|
||||
* Set the up counting DigitalSource.
|
||||
*
|
||||
* @param source Reference to the DigitalSource object to set as the up source
|
||||
*/
|
||||
void Counter::SetUpSource(DigitalSource& source) {
|
||||
SetUpSource(
|
||||
std::shared_ptr<DigitalSource>(&source, NullDeleter<DigitalSource>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the edge sensitivity on an up counting source.
|
||||
*
|
||||
* Set the up source to either detect rising edges or falling edges or both.
|
||||
*
|
||||
* @param risingEdge True to trigger on rising edges
|
||||
* @param fallingEdge True to trigger on falling edges
|
||||
*/
|
||||
void Counter::SetUpSourceEdge(bool risingEdge, bool fallingEdge) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (m_upSource == nullptr) {
|
||||
@@ -270,9 +147,6 @@ void Counter::SetUpSourceEdge(bool risingEdge, bool fallingEdge) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the up counting source to the counter.
|
||||
*/
|
||||
void Counter::ClearUpSource() {
|
||||
if (StatusIsFatal()) return;
|
||||
m_upSource.reset();
|
||||
@@ -281,25 +155,12 @@ void Counter::ClearUpSource() {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the down counting source to be a digital input channel.
|
||||
*
|
||||
* @param channel The DIO channel to use as the up source. 0-9 are on-board,
|
||||
* 10-25 are on the MXP
|
||||
*/
|
||||
void Counter::SetDownSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetDownSource(std::make_shared<DigitalInput>(channel));
|
||||
AddChild(m_downSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the down counting source to be an analog trigger.
|
||||
*
|
||||
* @param analogTrigger The analog trigger object that is used for the Down
|
||||
* Source
|
||||
* @param triggerType The analog trigger output that will trigger the counter.
|
||||
*/
|
||||
void Counter::SetDownSource(AnalogTrigger* analogTrigger,
|
||||
AnalogTriggerType triggerType) {
|
||||
SetDownSource(std::shared_ptr<AnalogTrigger>(analogTrigger,
|
||||
@@ -307,26 +168,22 @@ void Counter::SetDownSource(AnalogTrigger* analogTrigger,
|
||||
triggerType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the down counting source to be an analog trigger.
|
||||
*
|
||||
* @param analogTrigger The analog trigger object that is used for the Down
|
||||
* Source
|
||||
* @param triggerType The analog trigger output that will trigger the counter.
|
||||
*/
|
||||
void Counter::SetDownSource(std::shared_ptr<AnalogTrigger> analogTrigger,
|
||||
AnalogTriggerType triggerType) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetDownSource(analogTrigger->CreateOutput(triggerType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source object that causes the counter to count down.
|
||||
*
|
||||
* Set the down counting DigitalSource.
|
||||
*
|
||||
* @param source Pointer to the DigitalSource object to set as the down source
|
||||
*/
|
||||
void Counter::SetDownSource(DigitalSource* source) {
|
||||
SetDownSource(
|
||||
std::shared_ptr<DigitalSource>(source, NullDeleter<DigitalSource>()));
|
||||
}
|
||||
|
||||
void Counter::SetDownSource(DigitalSource& source) {
|
||||
SetDownSource(
|
||||
std::shared_ptr<DigitalSource>(&source, NullDeleter<DigitalSource>()));
|
||||
}
|
||||
|
||||
void Counter::SetDownSource(std::shared_ptr<DigitalSource> source) {
|
||||
if (StatusIsFatal()) return;
|
||||
m_downSource = source;
|
||||
@@ -342,31 +199,6 @@ void Counter::SetDownSource(std::shared_ptr<DigitalSource> source) {
|
||||
}
|
||||
}
|
||||
|
||||
void Counter::SetDownSource(DigitalSource* source) {
|
||||
SetDownSource(
|
||||
std::shared_ptr<DigitalSource>(source, NullDeleter<DigitalSource>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source object that causes the counter to count down.
|
||||
*
|
||||
* Set the down counting DigitalSource.
|
||||
*
|
||||
* @param source Reference to the DigitalSource object to set as the down source
|
||||
*/
|
||||
void Counter::SetDownSource(DigitalSource& source) {
|
||||
SetDownSource(
|
||||
std::shared_ptr<DigitalSource>(&source, NullDeleter<DigitalSource>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the edge sensitivity on a down counting source.
|
||||
*
|
||||
* Set the down source to either detect rising edges or falling edges.
|
||||
*
|
||||
* @param risingEdge True to trigger on rising edges
|
||||
* @param fallingEdge True to trigger on falling edges
|
||||
*/
|
||||
void Counter::SetDownSourceEdge(bool risingEdge, bool fallingEdge) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (m_downSource == nullptr) {
|
||||
@@ -379,9 +211,6 @@ void Counter::SetDownSourceEdge(bool risingEdge, bool fallingEdge) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the down counting source to the counter.
|
||||
*/
|
||||
void Counter::ClearDownSource() {
|
||||
if (StatusIsFatal()) return;
|
||||
m_downSource.reset();
|
||||
@@ -390,11 +219,6 @@ void Counter::ClearDownSource() {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set standard up / down counting mode on this counter.
|
||||
*
|
||||
* Up and down counts are sourced independently from two inputs.
|
||||
*/
|
||||
void Counter::SetUpDownCounterMode() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
@@ -402,12 +226,6 @@ void Counter::SetUpDownCounterMode() {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set external direction mode on this counter.
|
||||
*
|
||||
* Counts are sourced on the Up counter input.
|
||||
* The Down counter input represents the direction to count.
|
||||
*/
|
||||
void Counter::SetExternalDirectionMode() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
@@ -415,11 +233,6 @@ void Counter::SetExternalDirectionMode() {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Semi-period mode on this counter.
|
||||
*
|
||||
* Counts up on both rising and falling edges.
|
||||
*/
|
||||
void Counter::SetSemiPeriodMode(bool highSemiPeriod) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
@@ -427,15 +240,6 @@ void Counter::SetSemiPeriodMode(bool highSemiPeriod) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the counter to count in up or down based on the length of the input
|
||||
* pulse.
|
||||
*
|
||||
* This mode is most useful for direction sensitive gear tooth sensors.
|
||||
*
|
||||
* @param threshold The pulse length beyond which the counter counts the
|
||||
* opposite direction. Units are seconds.
|
||||
*/
|
||||
void Counter::SetPulseLengthMode(double threshold) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
@@ -443,29 +247,13 @@ void Counter::SetPulseLengthMode(double threshold) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Samples to Average which specifies the number of samples of the timer
|
||||
* to average when calculating the period.
|
||||
*
|
||||
* Perform averaging to account for mechanical imperfections or as oversampling
|
||||
* to increase resolution.
|
||||
*
|
||||
* @return The number of samples being averaged (from 1 to 127)
|
||||
*/
|
||||
int Counter::GetSamplesToAverage() const {
|
||||
void Counter::SetReverseDirection(bool reverseDirection) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
int samples = HAL_GetCounterSamplesToAverage(m_counter, &status);
|
||||
HAL_SetCounterReverseDirection(m_counter, reverseDirection, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return samples;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Samples to Average which specifies the number of samples of the timer
|
||||
* to average when calculating the period. Perform averaging to account for
|
||||
* mechanical imperfections or as oversampling to increase resolution.
|
||||
*
|
||||
* @param samplesToAverage The number of samples to average from 1 to 127.
|
||||
*/
|
||||
void Counter::SetSamplesToAverage(int samplesToAverage) {
|
||||
if (samplesToAverage < 1 || samplesToAverage > 127) {
|
||||
wpi_setWPIErrorWithContext(
|
||||
@@ -477,12 +265,15 @@ void Counter::SetSamplesToAverage(int samplesToAverage) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the current counter value.
|
||||
*
|
||||
* Read the value at this instant. It may still be running, so it reflects the
|
||||
* current value. Next time it is read, it might have a different value.
|
||||
*/
|
||||
int Counter::GetSamplesToAverage() const {
|
||||
int32_t status = 0;
|
||||
int samples = HAL_GetCounterSamplesToAverage(m_counter, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return samples;
|
||||
}
|
||||
|
||||
int Counter::GetFPGAIndex() const { return m_index; }
|
||||
|
||||
int Counter::Get() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
@@ -491,12 +282,6 @@ int Counter::Get() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the Counter to zero.
|
||||
*
|
||||
* Set the counter value to zero. This doesn't effect the running state of the
|
||||
* counter, just sets the current value to zero.
|
||||
*/
|
||||
void Counter::Reset() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
@@ -504,14 +289,6 @@ void Counter::Reset() {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Period of the most recent count.
|
||||
*
|
||||
* Returns the time interval of the most recent count. This can be used for
|
||||
* velocity calculations to determine shaft speed.
|
||||
*
|
||||
* @returns The period between the last two pulses in units of seconds.
|
||||
*/
|
||||
double Counter::GetPeriod() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
@@ -520,16 +297,6 @@ double Counter::GetPeriod() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum period where the device is still considered "moving".
|
||||
*
|
||||
* Sets the maximum period where the device is considered moving. This value is
|
||||
* used to determine the "stopped" state of the counter using the GetStopped
|
||||
* method.
|
||||
*
|
||||
* @param maxPeriod The maximum period where the counted device is considered
|
||||
* moving in seconds.
|
||||
*/
|
||||
void Counter::SetMaxPeriod(double maxPeriod) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
@@ -537,23 +304,6 @@ void Counter::SetMaxPeriod(double maxPeriod) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Select whether you want to continue updating the event timer output when
|
||||
* there are no samples captured.
|
||||
*
|
||||
* The output of the event timer has a buffer of periods that are averaged and
|
||||
* posted to a register on the FPGA. When the timer detects that the event
|
||||
* source has stopped (based on the MaxPeriod) the buffer of samples to be
|
||||
* averaged is emptied. If you enable the update when empty, you will be
|
||||
* notified of the stopped source and the event time will report 0 samples.
|
||||
* If you disable update when empty, the most recent average will remain on
|
||||
* the output until a new sample is acquired. You will never see 0 samples
|
||||
* output (except when there have been no events since an FPGA reset) and you
|
||||
* will likely not see the stopped bit become true (since it is updated at the
|
||||
* end of an average and there are no samples to average).
|
||||
*
|
||||
* @param enabled True to enable update when empty
|
||||
*/
|
||||
void Counter::SetUpdateWhenEmpty(bool enabled) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
@@ -561,16 +311,6 @@ void Counter::SetUpdateWhenEmpty(bool enabled) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the clock is stopped.
|
||||
*
|
||||
* Determine if the clocked input is stopped based on the MaxPeriod value set
|
||||
* using the SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the
|
||||
* device (and counter) are assumed to be stopped and it returns true.
|
||||
*
|
||||
* @return Returns true if the most recent counter period exceeds the MaxPeriod
|
||||
* value set by SetMaxPeriod.
|
||||
*/
|
||||
bool Counter::GetStopped() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
@@ -579,11 +319,6 @@ bool Counter::GetStopped() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The last direction the counter value changed.
|
||||
*
|
||||
* @return The last direction the counter value changed.
|
||||
*/
|
||||
bool Counter::GetDirection() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
int32_t status = 0;
|
||||
@@ -592,21 +327,6 @@ bool Counter::GetDirection() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Counter to return reversed sensing on the direction.
|
||||
*
|
||||
* This allows counters to change the direction they are counting in the case of
|
||||
* 1X and 2X quadrature encoding only. Any other counter mode isn't supported.
|
||||
*
|
||||
* @param reverseDirection true if the value counted should be negated.
|
||||
*/
|
||||
void Counter::SetReverseDirection(bool reverseDirection) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetCounterReverseDirection(m_counter, reverseDirection, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void Counter::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Counter");
|
||||
builder.AddDoubleProperty("Value", [=]() { return Get(); }, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user