Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 2 | /* Copyright (c) FIRST 2008-2016. All Rights Reserved. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 6 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 7 | |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 8 | #pragma once |
| 9 | |
| 10 | #include "DigitalSource.h" |
| 11 | #include "LiveWindow/LiveWindowSendable.h" |
| 12 | |
| 13 | #include <memory> |
| 14 | #include <cstdint> |
| 15 | |
| 16 | class 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 | */ |
| 28 | class 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 | }; |