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