WPILibC++ 2023.4.3-108-ge5452e3
frc::UpDownCounter Class Reference

Up Down Counter. More...

#include <frc/counter/UpDownCounter.h>

Inheritance diagram for frc::UpDownCounter:
wpi::Sendable wpi::SendableHelper< UpDownCounter >

Public Member Functions

 UpDownCounter (DigitalSource &upSource, DigitalSource &downSource)
 Constructs a new UpDown Counter. More...
 
 UpDownCounter (std::shared_ptr< DigitalSource > upSource, std::shared_ptr< DigitalSource > downSource)
 Constructs a new UpDown Counter. More...
 
 ~UpDownCounter () override
 
 UpDownCounter (UpDownCounter &&)=default
 
UpDownCounteroperator= (UpDownCounter &&)=default
 
int GetCount () const
 Gets the current count. More...
 
void SetReverseDirection (bool reverseDirection)
 Sets to revert the counter direction. More...
 
void Reset ()
 Resets the current count. More...
 
void SetUpEdgeConfiguration (EdgeConfiguration configuration)
 Sets the configuration for the up source. More...
 
void SetDownEdgeConfiguration (EdgeConfiguration configuration)
 Sets the configuration for the down source. More...
 
- Public Member Functions inherited from wpi::Sendable
virtual ~Sendable ()=default
 
virtual void InitSendable (SendableBuilder &builder)=0
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::SendableHelper< UpDownCounter >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 

Protected Member Functions

void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Protected Member Functions inherited from wpi::SendableHelper< UpDownCounter >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

Up Down Counter.

This class can count edges on a single digital input or count up based on an edge from one digital input and down on an edge from another digital input.

Constructor & Destructor Documentation

◆ UpDownCounter() [1/3]

frc::UpDownCounter::UpDownCounter ( DigitalSource upSource,
DigitalSource downSource 
)

Constructs a new UpDown Counter.

Parameters
upSourceThe up count source (can be null).
downSourceThe down count source (can be null).

◆ UpDownCounter() [2/3]

frc::UpDownCounter::UpDownCounter ( std::shared_ptr< DigitalSource upSource,
std::shared_ptr< DigitalSource downSource 
)

Constructs a new UpDown Counter.

Parameters
upSourceThe up count source (can be null).
downSourceThe down count source (can be null).

◆ ~UpDownCounter()

frc::UpDownCounter::~UpDownCounter ( )
override

◆ UpDownCounter() [3/3]

frc::UpDownCounter::UpDownCounter ( UpDownCounter &&  )
default

Member Function Documentation

◆ GetCount()

int frc::UpDownCounter::GetCount ( ) const

Gets the current count.

Returns
The current count.

◆ InitSendable()

void frc::UpDownCounter::InitSendable ( wpi::SendableBuilder builder)
overrideprotectedvirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ operator=()

UpDownCounter & frc::UpDownCounter::operator= ( UpDownCounter &&  )
default

◆ Reset()

void frc::UpDownCounter::Reset ( )

Resets the current count.

◆ SetDownEdgeConfiguration()

void frc::UpDownCounter::SetDownEdgeConfiguration ( EdgeConfiguration  configuration)

Sets the configuration for the down source.

Parameters
configurationThe down source configuration.

◆ SetReverseDirection()

void frc::UpDownCounter::SetReverseDirection ( bool  reverseDirection)

Sets to revert the counter direction.

Parameters
reverseDirectionTrue to reverse counting direction.

◆ SetUpEdgeConfiguration()

void frc::UpDownCounter::SetUpEdgeConfiguration ( EdgeConfiguration  configuration)

Sets the configuration for the up source.

Parameters
configurationThe up source configuration.

The documentation for this class was generated from the following file: