Brian Silverman | f7f267a | 2017-02-04 16:16:08 -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 | |
| 10 | #include <memory> |
| 11 | |
| 12 | #include "AnalogTriggerOutput.h" |
| 13 | #include "HAL/Types.h" |
| 14 | #include "SensorBase.h" |
| 15 | |
| 16 | namespace frc { |
| 17 | |
| 18 | class AnalogInput; |
| 19 | |
| 20 | class AnalogTrigger : public SensorBase { |
| 21 | friend class AnalogTriggerOutput; |
| 22 | |
| 23 | public: |
| 24 | explicit AnalogTrigger(int channel); |
| 25 | explicit AnalogTrigger(AnalogInput* channel); |
| 26 | virtual ~AnalogTrigger(); |
| 27 | |
| 28 | void SetLimitsVoltage(double lower, double upper); |
| 29 | void SetLimitsRaw(int lower, int upper); |
| 30 | void SetAveraged(bool useAveragedValue); |
| 31 | void SetFiltered(bool useFilteredValue); |
| 32 | int GetIndex() const; |
| 33 | bool GetInWindow(); |
| 34 | bool GetTriggerState(); |
| 35 | std::shared_ptr<AnalogTriggerOutput> CreateOutput( |
| 36 | AnalogTriggerType type) const; |
| 37 | |
| 38 | private: |
| 39 | int m_index; |
| 40 | HAL_AnalogTriggerHandle m_trigger; |
| 41 | AnalogInput* m_analogInput = nullptr; |
| 42 | bool m_ownsAnalog = false; |
| 43 | }; |
| 44 | |
| 45 | } // namespace frc |