13 #include <HAL/Counter.h> 14 #include <HAL/Types.h> 16 #include "AnalogTrigger.h" 17 #include "CounterBase.h" 18 #include "LiveWindow/LiveWindowSendable.h" 19 #include "SensorBase.h" 20 #include "networktables/NetworkTableEntry.h" 44 kExternalDirection = 3
46 explicit Counter(Mode mode = kTwoPulse);
49 explicit Counter(std::shared_ptr<DigitalSource> source);
53 Counter(EncodingType encodingType, std::shared_ptr<DigitalSource> upSource,
54 std::shared_ptr<DigitalSource> downSource,
bool inverted);
59 void SetUpSource(std::shared_ptr<AnalogTrigger> analogTrigger,
60 AnalogTriggerType triggerType);
62 void SetUpSource(std::shared_ptr<DigitalSource> source);
69 AnalogTriggerType triggerType);
70 void SetDownSource(std::shared_ptr<AnalogTrigger> analogTrigger,
71 AnalogTriggerType triggerType);
86 int Get()
const override;
87 void Reset()
override;
96 int GetFPGAIndex()
const {
return m_index; }
102 void InitTable(std::shared_ptr<nt::NetworkTable> subTable)
override;
106 std::shared_ptr<DigitalSource> m_upSource;
108 std::shared_ptr<DigitalSource> m_downSource;
110 HAL_CounterHandle m_counter = HAL_kInvalidHandle;
int Get() const override
Read the current counter value.
Definition: Counter.cpp:481
void ClearDownSource()
Disable the down counting source to the counter.
Definition: Counter.cpp:380
void SetDownSourceEdge(bool risingEdge, bool fallingEdge)
Set the edge sensitivity on a down counting source.
Definition: Counter.cpp:365
Counter(Mode mode=kTwoPulse)
Create an instance of a counter where no sources are selected.
Definition: Counter.cpp:31
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
Base class for all sensors.
Definition: SensorBase.h:20
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: Counter.cpp:605
bool GetDirection() const override
The last direction the counter value changed.
Definition: Counter.cpp:582
void InitTable(std::shared_ptr< nt::NetworkTable > subTable) override
Initializes a table for this sendable object.
Definition: Counter.cpp:615
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:28
void Reset() override
Reset the Counter to zero.
Definition: Counter.cpp:495
std::string GetSmartDashboardType() const override
Definition: Counter.cpp:613
Interface for counting the number of ticks on a digital input channel.
Definition: CounterBase.h:20
void SetUpSourceEdge(bool risingEdge, bool fallingEdge)
Set the edge sensitivity on an up counting source.
Definition: Counter.cpp:257
Class for counting the number of ticks on a digital input channel.
Definition: Counter.h:36
void SetExternalDirectionMode()
Set external direction mode on this counter.
Definition: Counter.cpp:406
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: Counter.cpp:611
void SetDownSource(int channel)
Set the down counting source to be a digital input channel.
Definition: Counter.cpp:286
void SetUpdateWhenEmpty(bool enabled)
Select whether you want to continue updating the event timer output when there are no samples capture...
Definition: Counter.cpp:552
DigitalSource Interface.
Definition: DigitalSource.h:26
virtual ~Counter()
Delete the Counter object.
Definition: Counter.cpp:165
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: Counter.cpp:609
void SetPulseLengthMode(double threshold)
Configure the counter to count in up or down based on the length of the input pulse.
Definition: Counter.cpp:434
Definition: AnalogTrigger.h:21
void SetSamplesToAverage(int samplesToAverage)
Set the Samples to Average which specifies the number of samples of the timer to average when calcula...
Definition: Counter.cpp:464
void SetUpDownCounterMode()
Set standard up / down counting mode on this counter.
Definition: Counter.cpp:393
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
double GetPeriod() const override
Get the Period of the most recent count.
Definition: Counter.cpp:510
void SetReverseDirection(bool reverseDirection)
Set the Counter to return reversed sensing on the direction.
Definition: Counter.cpp:598
void SetUpSource(int channel)
Set the upsource for the counter as a digital input channel.
Definition: Counter.cpp:180
bool GetStopped() const override
Determine if the clock is stopped.
Definition: Counter.cpp:569
void SetMaxPeriod(double maxPeriod) override
Set the maximum period where the device is still considered "moving".
Definition: Counter.cpp:528
int GetSamplesToAverage() const
Get the Samples to Average which specifies the number of samples of the timer to average when calcula...
Definition: Counter.cpp:450
void SetSemiPeriodMode(bool highSemiPeriod)
Set Semi-period mode on this counter.
Definition: Counter.cpp:418
void ClearUpSource()
Disable the up counting source to the counter.
Definition: Counter.cpp:272