WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
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 (int source)
 Constructs a DutyCycle input from a smartio channel.
 
 DutyCycle (DutyCycle &&)=default
 
DutyCycleoperator= (DutyCycle &&)=default
 
 ~DutyCycle () override=default
 Close the DutyCycle and free all resources.
 
units::hertz_t GetFrequency () const
 Get the frequency of the duty cycle signal.
 
double GetOutput () const
 Get the output ratio of the duty cycle signal.
 
units::second_t GetHighTime () const
 Get the raw high time of the duty cycle signal.
 
int GetSourceChannel () const
 Get the channel of the source.
 
- Public Member Functions inherited from wpi::Sendable
virtual constexpr ~Sendable ()=default
 
- Public Member Functions inherited from wpi::SendableHelper< DutyCycle >
constexpr SendableHelper (const SendableHelper &rhs)=default
 
constexpr SendableHelper (SendableHelper &&rhs)
 
constexpr SendableHelperoperator= (const SendableHelper &rhs)=default
 
constexpr SendableHelperoperator= (SendableHelper &&rhs)
 

Protected Member Functions

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

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. These can be attached to any SmartIO.

Constructor & Destructor Documentation

◆ DutyCycle() [1/2]

frc::DutyCycle::DutyCycle ( int source)
explicit

Constructs a DutyCycle input from a smartio channel.

Parameters
sourceThe channel to use.

◆ DutyCycle() [2/2]

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

◆ ~DutyCycle()

frc::DutyCycle::~DutyCycle ( )
overridedefault

Close the DutyCycle and free all resources.

Member Function Documentation

◆ GetFrequency()

units::hertz_t frc::DutyCycle::GetFrequency ( ) const

Get the frequency of the duty cycle signal.

Returns
frequency

◆ 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

◆ 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

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