blob: 96a70a08627cdae8428ed2cb860c59b6abd7a0d2 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* Open Source Software - may be modified and shared by FRC teams. The code */
Brian Silverman1a675112016-02-20 20:42:49 -05004/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
Brian Silverman26e4e522015-12-17 01:56:40 -05006/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05007
Brian Silverman26e4e522015-12-17 01:56:40 -05008#pragma once
9
10#include "DigitalSource.h"
11#include "LiveWindow/LiveWindowSendable.h"
12
13#include <memory>
14#include <cstdint>
15
16class DigitalGlitchFilter;
17
18/**
19 * Class to read a digital input.
20 * This class will read digital inputs and return the current value on the
21 * channel. Other devices
22 * such as encoders, gear tooth sensors, etc. that are implemented elsewhere
23 * will automatically
24 * allocate digital inputs and outputs as required. This class is only for
25 * devices like switches
26 * etc. that aren't implemented anywhere else.
27 */
28class DigitalInput : public DigitalSource, public LiveWindowSendable {
29 public:
30 explicit DigitalInput(uint32_t channel);
31 virtual ~DigitalInput();
32 bool Get() const;
33 uint32_t GetChannel() const;
34
35 // Digital Source Interface
36 virtual uint32_t GetChannelForRouting() const;
37 virtual uint32_t GetModuleForRouting() const;
38 virtual bool GetAnalogTriggerForRouting() const;
39
40 void UpdateTable();
41 void StartLiveWindowMode();
42 void StopLiveWindowMode();
43 std::string GetSmartDashboardType() const;
44 void InitTable(std::shared_ptr<ITable> subTable);
45 std::shared_ptr<ITable> GetTable() const;
46
47 private:
48 uint32_t m_channel;
49
50 std::shared_ptr<ITable> m_table;
51 friend class DigitalGlitchFilter;
52};