blob: cd26773c2a81217951ee4327e6dc5722e6c1e29c [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -08001/*----------------------------------------------------------------------------*/
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 Chatowbf0609c2021-07-31 16:13:27 -070010#include <cstdint>
Parker Schuhd3b7a8872018-02-19 16:42:27 -080011#include <memory>
12#include <string>
13
14#include "frc971/wpilib/ahal/DigitalSource.h"
15
16namespace frc {
17
18class 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 */
28class 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