12 #include <hal/Types.h>
14 #include "frc/AnalogTrigger.h"
15 #include "frc/CounterBase.h"
16 #include "frc/ErrorBase.h"
17 #include "frc/smartdashboard/Sendable.h"
18 #include "frc/smartdashboard/SendableHelper.h"
22 class DigitalGlitchFilter;
23 class SendableBuilder;
49 kExternalDirection = 3
65 explicit Counter(Mode mode = kTwoPulse);
106 explicit Counter(std::shared_ptr<DigitalSource> source);
147 Counter(EncodingType encodingType, std::shared_ptr<DigitalSource> upSource,
148 std::shared_ptr<DigitalSource> downSource,
bool inverted);
181 void SetUpSource(std::shared_ptr<AnalogTrigger> analogTrigger,
182 AnalogTriggerType triggerType);
193 void SetUpSource(std::shared_ptr<DigitalSource> source);
236 AnalogTriggerType triggerType);
246 void SetDownSource(std::shared_ptr<AnalogTrigger> analogTrigger,
247 AnalogTriggerType triggerType);
349 int GetFPGAIndex()
const;
358 int Get()
const override;
366 void Reset()
override;
432 std::shared_ptr<DigitalSource> m_upSource;
435 std::shared_ptr<DigitalSource> m_downSource;
438 hal::Handle<HAL_CounterHandle> m_counter;
double GetPeriod() const override
Get the Period of the most recent count.
bool GetStopped() const override
Determine if the clock is stopped.
void ClearUpSource()
Disable the up counting source to the counter.
Definition: DMASample.h:23
void SetSemiPeriodMode(bool highSemiPeriod)
Set Semi-period mode on this counter.
void SetExternalDirectionMode()
Set external direction mode on this counter.
void SetReverseDirection(bool reverseDirection)
Set the Counter to return reversed sensing on the direction.
Interface for counting the number of ticks on a digital input channel.
Definition: CounterBase.h:21
void SetDownSource(int channel)
Set the down counting source to be a digital input channel.
Definition: AnalogTrigger.h:25
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
void ClearDownSource()
Disable the down counting source to the counter.
Counter(Mode mode=kTwoPulse)
Create an instance of a counter where no sources are selected.
void SetUpSource(int channel)
Set the upsource for the counter as a digital input channel.
Base class for most objects.
Definition: ErrorBase.h:104
void Reset() override
Reset the Counter to zero.
void SetSamplesToAverage(int samplesToAverage)
Set the Samples to Average which specifies the number of samples of the timer to average when calcula...
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:33
void SetUpdateWhenEmpty(bool enabled)
Select whether you want to continue updating the event timer output when there are no samples capture...
void SetUpDownCounterMode()
Set standard up / down counting mode on this counter.
int Get() const override
Read the current counter value.
Interface for Sendable objects.
Definition: Sendable.h:17
void SetUpSourceEdge(bool risingEdge, bool fallingEdge)
Set the edge sensitivity on an up counting source.
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
Class for counting the number of ticks on a digital input channel.
Definition: Counter.h:37
int GetSamplesToAverage() const
Get the Samples to Average which specifies the number of samples of the timer to average when calcula...
void SetPulseLengthMode(double threshold)
Configure the counter to count in up or down based on the length of the input pulse.
void SetDownSourceEdge(bool risingEdge, bool fallingEdge)
Set the edge sensitivity on a down counting source.
DigitalSource Interface.
Definition: DigitalSource.h:25
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
Definition: SendableBuilder.h:23
bool GetDirection() const override
The last direction the counter value changed.
void SetMaxPeriod(double maxPeriod) override
Set the maximum period where the device is still considered "moving".