WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::DutyCycle Class Reference

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

#include <wpi/hardware/rotation/DutyCycle.hpp>

Inheritance diagram for wpi::DutyCycle:
wpi::util::Sendable wpi::util::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.
wpi::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.
wpi::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::util::Sendable
virtual constexpr ~Sendable ()=default
Public Member Functions inherited from wpi::util::SendableHelper< DutyCycle >
constexpr SendableHelper (const SendableHelper &rhs)=default
constexpr SendableHelperoperator= (const SendableHelper &rhs)=default

Protected Member Functions

void InitSendable (wpi::util::SendableBuilder &builder) override
 Initializes this Sendable object.
Protected Member Functions inherited from wpi::util::SendableHelper< DutyCycle >
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]

wpi::DutyCycle::DutyCycle ( int source)
explicit

Constructs a DutyCycle input from a smartio channel.

Parameters
sourceThe channel to use.

◆ DutyCycle() [2/2]

wpi::DutyCycle::DutyCycle ( DutyCycle && )
default

◆ ~DutyCycle()

wpi::DutyCycle::~DutyCycle ( )
overridedefault

Close the DutyCycle and free all resources.

Member Function Documentation

◆ GetFrequency()

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

Get the frequency of the duty cycle signal.

Returns
frequency

◆ GetHighTime()

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

Get the raw high time of the duty cycle signal.

Returns
high time of last pulse

◆ GetOutput()

double wpi::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 wpi::DutyCycle::GetSourceChannel ( ) const

Get the channel of the source.

Returns
the source channel

◆ InitSendable()

void wpi::DutyCycle::InitSendable ( wpi::util::SendableBuilder & builder)
overrideprotectedvirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::util::Sendable.

◆ operator=()

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

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