WPILibC++ 2024.1.1-beta-4
frc::DutyCycle Class Reference

Class to read a duty cycle PWM input. More...

#include <frc/DutyCycle.h>

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

Public Member Functions

 DutyCycle (DigitalSource &source)
 Constructs a DutyCycle input from a DigitalSource input. More...
 
 DutyCycle (DigitalSource *source)
 Constructs a DutyCycle input from a DigitalSource input. More...
 
 DutyCycle (std::shared_ptr< DigitalSource > source)
 Constructs a DutyCycle input from a DigitalSource input. More...
 
 ~DutyCycle () override
 Close the DutyCycle and free all resources. More...
 
 DutyCycle (DutyCycle &&)=default
 
DutyCycleoperator= (DutyCycle &&)=default
 
int GetFrequency () const
 Get the frequency of the duty cycle signal. More...
 
double GetOutput () const
 Get the output ratio of the duty cycle signal. More...
 
units::second_t GetHighTime () const
 Get the raw high time of the duty cycle signal. More...
 
unsigned int GetOutputScaleFactor () const
 Get the scale factor of the output. More...
 
int GetFPGAIndex () const
 Get the FPGA index for the DutyCycle. More...
 
int GetSourceChannel () const
 Get the channel of the 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< DutyCycle >
 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< DutyCycle >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Friends

class AnalogTrigger
 
class DMA
 
class DMASample
 

Detailed Description

Class to read a duty cycle PWM input.

PWM input signals are specified with a frequency and a ratio of high to low in that frequency. There are 8 of these in the roboRIO, and they can be attached to any DigitalSource.

These can be combined as the input of an AnalogTrigger to a Counter in order to implement rollover checking.

Constructor & Destructor Documentation

◆ DutyCycle() [1/4]

frc::DutyCycle::DutyCycle ( DigitalSource source)
explicit

Constructs a DutyCycle input from a DigitalSource input.

This class does not own the inputted source.

Parameters
sourceThe DigitalSource to use.

◆ DutyCycle() [2/4]

frc::DutyCycle::DutyCycle ( DigitalSource source)
explicit

Constructs a DutyCycle input from a DigitalSource input.

This class does not own the inputted source.

Parameters
sourceThe DigitalSource to use.

◆ DutyCycle() [3/4]

frc::DutyCycle::DutyCycle ( std::shared_ptr< DigitalSource source)
explicit

Constructs a DutyCycle input from a DigitalSource input.

This class does not own the inputted source.

Parameters
sourceThe DigitalSource to use.

◆ ~DutyCycle()

frc::DutyCycle::~DutyCycle ( )
override

Close the DutyCycle and free all resources.

◆ DutyCycle() [4/4]

frc::DutyCycle::DutyCycle ( DutyCycle &&  )
default

Member Function Documentation

◆ GetFPGAIndex()

int frc::DutyCycle::GetFPGAIndex ( ) const

Get the FPGA index for the DutyCycle.

Returns
the FPGA index

◆ GetFrequency()

int frc::DutyCycle::GetFrequency ( ) const

Get the frequency of the duty cycle signal.

Returns
frequency in Hertz

◆ GetHighTime()

units::second_t frc::DutyCycle::GetHighTime ( ) const

Get the raw high time of the duty cycle signal.

Returns
high time of last pulse

◆ GetOutput()

double frc::DutyCycle::GetOutput ( ) const

Get the output ratio of the duty cycle signal.

0 means always low, 1 means always high.

Returns
output ratio between 0 and 1

◆ GetOutputScaleFactor()

unsigned int frc::DutyCycle::GetOutputScaleFactor ( ) const

Get the scale factor of the output.

An output equal to this value is always high, and then linearly scales down to 0. Divide a raw result by this in order to get the percentage between 0 and 1. Used by DMA.

Returns
the output scale factor

◆ GetSourceChannel()

int frc::DutyCycle::GetSourceChannel ( ) const

Get the channel of the source.

Returns
the source channel

◆ InitSendable()

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

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ operator=()

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

Friends And Related Function Documentation

◆ AnalogTrigger

friend class AnalogTrigger
friend

◆ DMA

friend class DMA
friend

◆ DMASample

friend class DMASample
friend

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