WPILibC++  2020.3.2-60-g3011ebe
DigitalInput.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "frc/DigitalSource.h"
11 #include "frc/smartdashboard/Sendable.h"
12 #include "frc/smartdashboard/SendableHelper.h"
13 
14 namespace frc {
15 
16 class DigitalGlitchFilter;
17 class SendableBuilder;
18 
28 class DigitalInput : public DigitalSource,
29  public Sendable,
30  public SendableHelper<DigitalInput> {
31  public:
39  explicit DigitalInput(int channel);
40 
41  ~DigitalInput() override;
42 
43  DigitalInput(DigitalInput&&) = default;
44  DigitalInput& operator=(DigitalInput&&) = default;
45 
51  bool Get() const;
52 
53  // Digital Source Interface
57  HAL_Handle GetPortHandleForRouting() const override;
58 
62  AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
63 
67  bool IsAnalogTrigger() const override;
68 
72  int GetChannel() const override;
73 
79  void SetSimDevice(HAL_SimDeviceHandle device);
80 
81  void InitSendable(SendableBuilder& builder) override;
82 
83  private:
84  int m_channel;
85  hal::Handle<HAL_DigitalHandle> m_handle;
86 
87  friend class DigitalGlitchFilter;
88 };
89 
90 } // namespace frc
frc::DigitalInput::SetSimDevice
void SetSimDevice(HAL_SimDeviceHandle device)
Indicates this input is used by a simulated device.
frc::DigitalInput
Class to read a digital input.
Definition: DigitalInput.h:28
frc::DigitalInput::GetAnalogTriggerTypeForRouting
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override
frc::DigitalInput::GetPortHandleForRouting
HAL_Handle GetPortHandleForRouting() const override
frc::DigitalInput::Get
bool Get() const
Get the value from a digital input channel.
frc::DigitalInput::DigitalInput
DigitalInput(int channel)
Create an instance of a Digital Input class.
frc::DigitalInput::GetChannel
int GetChannel() const override
frc::DigitalGlitchFilter
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:33
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc::DigitalInput::IsAnalogTrigger
bool IsAnalogTrigger() const override
Is source an AnalogTrigger.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: PDPSim.h:16
frc::DigitalSource
DigitalSource Interface.
Definition: DigitalSource.h:25
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23
frc::DigitalInput::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.