Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2008-2017. 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 | |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame^] | 10 | #include <cstdint> |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 11 | #include <memory> |
| 12 | #include <string> |
| 13 | |
| 14 | #include "frc971/wpilib/ahal/DigitalSource.h" |
| 15 | |
| 16 | namespace frc { |
| 17 | |
| 18 | class DigitalGlitchFilter; |
| 19 | |
| 20 | /** |
| 21 | * Class to read a digital input. |
| 22 | * This class will read digital inputs and return the current value on the |
| 23 | * channel. Other devices such as encoders, gear tooth sensors, etc. that are |
| 24 | * implemented elsewhere will automatically allocate digital inputs and outputs |
| 25 | * as required. This class is only for devices like switches etc. that aren't |
| 26 | * implemented anywhere else. |
| 27 | */ |
| 28 | class DigitalInput : public DigitalSource { |
| 29 | public: |
| 30 | explicit DigitalInput(int channel); |
| 31 | virtual ~DigitalInput(); |
| 32 | bool Get() const; |
| 33 | int GetChannel() const override; |
| 34 | |
| 35 | // Digital Source Interface |
| 36 | HAL_Handle GetPortHandleForRouting() const override; |
| 37 | AnalogTriggerType GetAnalogTriggerTypeForRouting() const override; |
| 38 | bool IsAnalogTrigger() const override; |
| 39 | |
| 40 | private: |
| 41 | int m_channel; |
| 42 | HAL_DigitalHandle m_handle; |
| 43 | |
| 44 | friend class DigitalGlitchFilter; |
| 45 | }; |
| 46 | |
| 47 | } // namespace frc |