WPILibC++ 2022.4.1
frc::DigitalInput Class Reference

Class to read a digital input. More...

#include <frc/DigitalInput.h>

Inheritance diagram for frc::DigitalInput:
frc::DigitalSource wpi::Sendable wpi::SendableHelper< DigitalInput >

Public Member Functions

 DigitalInput (int channel)
 Create an instance of a Digital Input class. More...
 
 ~DigitalInput () override
 
 DigitalInput (DigitalInput &&)=default
 
DigitalInputoperator= (DigitalInput &&)=default
 
bool Get () const
 Get the value from a digital input channel. More...
 
HAL_Handle GetPortHandleForRouting () const override
 
AnalogTriggerType GetAnalogTriggerTypeForRouting () const override
 
bool IsAnalogTrigger () const override
 Is source an AnalogTrigger. More...
 
int GetChannel () const override
 
void SetSimDevice (HAL_SimDeviceHandle device)
 Indicates this input is used by a simulated device. More...
 
void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from frc::DigitalSource
 DigitalSource ()=default
 
 DigitalSource (DigitalSource &&)=default
 
DigitalSourceoperator= (DigitalSource &&)=default
 
- Public Member Functions inherited from wpi::Sendable
virtual ~Sendable ()=default
 
- Public Member Functions inherited from wpi::SendableHelper< DigitalInput >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 
std::string GetName () const
 Gets the name of this Sendable object. More...
 
void SetName (std::string_view name)
 Sets the name of this Sendable object. More...
 
void SetName (std::string_view subsystem, std::string_view name)
 Sets both the subsystem name and device name of this Sendable object. More...
 
std::string GetSubsystem () const
 Gets the subsystem name of this Sendable object. More...
 
void SetSubsystem (std::string_view subsystem)
 Sets the subsystem name of this Sendable object. More...
 

Friends

class DigitalGlitchFilter
 

Additional Inherited Members

- Protected Member Functions inherited from wpi::SendableHelper< DigitalInput >
 SendableHelper ()=default
 
void SetName (std::string_view moduleType, int channel)
 Sets the name of the sensor with a channel number. More...
 
void SetName (std::string_view moduleType, int moduleNumber, int channel)
 Sets the name of the sensor with a module and channel number. More...
 
void AddChild (std::shared_ptr< Sendable > child)
 Add a child component. More...
 
void AddChild (void *child)
 Add a child component. More...
 
 ~SendableHelper ()
 

Detailed Description

Class to read a digital input.

This class will read digital inputs and return the current value on the channel. Other devices such as encoders, gear tooth sensors, etc. that are implemented elsewhere will automatically allocate digital inputs and outputs as required. This class is only for devices like switches etc. that aren't implemented anywhere else.

Constructor & Destructor Documentation

◆ DigitalInput() [1/2]

frc::DigitalInput::DigitalInput ( int  channel)
explicit

Create an instance of a Digital Input class.

Creates a digital input given a channel.

Parameters
channelThe DIO channel 0-9 are on-board, 10-25 are on the MXP port

◆ ~DigitalInput()

frc::DigitalInput::~DigitalInput ( )
override

◆ DigitalInput() [2/2]

frc::DigitalInput::DigitalInput ( DigitalInput &&  )
default

Member Function Documentation

◆ Get()

bool frc::DigitalInput::Get ( ) const

Get the value from a digital input channel.

Retrieve the value of a single digital input channel from the FPGA.

◆ GetAnalogTriggerTypeForRouting()

AnalogTriggerType frc::DigitalInput::GetAnalogTriggerTypeForRouting ( ) const
overridevirtual
Returns
The type of analog trigger output to be used. 0 for Digitals

Implements frc::DigitalSource.

◆ GetChannel()

int frc::DigitalInput::GetChannel ( ) const
overridevirtual
Returns
The GPIO channel number that this object represents.

Implements frc::DigitalSource.

◆ GetPortHandleForRouting()

HAL_Handle frc::DigitalInput::GetPortHandleForRouting ( ) const
overridevirtual
Returns
The HAL Handle to the specified source.

Implements frc::DigitalSource.

◆ InitSendable()

void frc::DigitalInput::InitSendable ( wpi::SendableBuilder builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ IsAnalogTrigger()

bool frc::DigitalInput::IsAnalogTrigger ( ) const
overridevirtual

Is source an AnalogTrigger.

Implements frc::DigitalSource.

◆ operator=()

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

◆ SetSimDevice()

void frc::DigitalInput::SetSimDevice ( HAL_SimDeviceHandle  device)

Indicates this input is used by a simulated device.

Parameters
devicesimulated device handle

Friends And Related Function Documentation

◆ DigitalGlitchFilter

friend class DigitalGlitchFilter
friend

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