13 #include "AnalogTrigger.h"
14 #include "CounterBase.h"
15 #include "HAL/Counter.h"
16 #include "HAL/Types.h"
17 #include "LiveWindow/LiveWindowSendable.h"
18 #include "SensorBase.h"
41 kExternalDirection = 3
43 explicit Counter(Mode mode = kTwoPulse);
46 explicit Counter(std::shared_ptr<DigitalSource> source);
47 WPI_DEPRECATED(
"Use pass-by-reference instead.")
52 Counter(EncodingType encodingType, std::shared_ptr<DigitalSource> upSource,
53 std::shared_ptr<DigitalSource> downSource,
bool inverted);
58 void SetUpSource(std::shared_ptr<AnalogTrigger> analogTrigger,
59 AnalogTriggerType triggerType);
61 void SetUpSource(std::shared_ptr<DigitalSource> source);
68 AnalogTriggerType triggerType);
69 void SetDownSource(std::shared_ptr<AnalogTrigger> analogTrigger,
70 AnalogTriggerType triggerType);
85 int Get()
const override;
86 void Reset()
override;
95 int GetFPGAIndex()
const {
return m_index; }
101 void InitTable(std::shared_ptr<ITable> subTable)
override;
102 std::shared_ptr<ITable>
GetTable()
const override;
106 std::shared_ptr<DigitalSource> m_upSource;
108 std::shared_ptr<DigitalSource> m_downSource;
110 HAL_CounterHandle m_counter = HAL_kInvalidHandle;
115 std::shared_ptr<ITable> m_table;
int Get() const override
Read the current counter value.
Definition: Counter.cpp:496
void ClearDownSource()
Disable the down counting source to the counter.
Definition: Counter.cpp:395
void SetDownSourceEdge(bool risingEdge, bool fallingEdge)
Set the edge sensitivity on a down counting source.
Definition: Counter.cpp:380
Counter(Mode mode=kTwoPulse)
Create an instance of a counter where no sources are selected.
Definition: Counter.cpp:30
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:22
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: Counter.cpp:620
bool GetDirection() const override
The last direction the counter value changed.
Definition: Counter.cpp:597
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:26
void Reset() override
Reset the Counter to zero.
Definition: Counter.cpp:510
std::string GetSmartDashboardType() const override
Definition: Counter.cpp:630
Interface for counting the number of ticks on a digital input channel.
Definition: CounterBase.h:22
void SetUpSourceEdge(bool risingEdge, bool fallingEdge)
Set the edge sensitivity on an up counting source.
Definition: Counter.cpp:272
Class for counting the number of ticks on a digital input channel.
Definition: Counter.h:33
void SetExternalDirectionMode()
Set external direction mode on this counter.
Definition: Counter.cpp:421
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: Counter.cpp:628
void SetDownSource(int channel)
Set the down counting source to be a digital input channel.
Definition: Counter.cpp:301
void SetUpdateWhenEmpty(bool enabled)
Select whether you want to continue updating the event timer output when there are no samples capture...
Definition: Counter.cpp:567
DigitalSource Interface.
Definition: DigitalSource.h:25
virtual ~Counter()
Delete the Counter object.
Definition: Counter.cpp:180
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: Counter.cpp:626
void SetPulseLengthMode(double threshold)
Configure the counter to count in up or down based on the length of the input pulse.
Definition: Counter.cpp:449
Definition: AnalogTrigger.h:20
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:479
void SetUpDownCounterMode()
Set standard up / down counting mode on this counter.
Definition: Counter.cpp:408
std::shared_ptr< ITable > GetTable() const override
Definition: Counter.cpp:637
double GetPeriod() const override
Get the Period of the most recent count.
Definition: Counter.cpp:525
void SetReverseDirection(bool reverseDirection)
Set the Counter to return reversed sensing on the direction.
Definition: Counter.cpp:613
void InitTable(std::shared_ptr< ITable > subTable) override
Initializes a table for this sendable object.
Definition: Counter.cpp:632
void SetUpSource(int channel)
Set the upsource for the counter as a digital input channel.
Definition: Counter.cpp:195
bool GetStopped() const override
Determine if the clock is stopped.
Definition: Counter.cpp:584
void SetMaxPeriod(double maxPeriod) override
Set the maximum period where the device is still considered "moving".
Definition: Counter.cpp:543
int GetSamplesToAverage() const
Get the Samples to Average which specifies the number of samples of the timer to average when calcula...
Definition: Counter.cpp:465
void SetSemiPeriodMode(bool highSemiPeriod)
Set Semi-period mode on this counter.
Definition: Counter.cpp:433
void ClearUpSource()
Disable the up counting source to the counter.
Definition: Counter.cpp:287