Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 2 | /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 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 | |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 12 | #include <hal/Types.h> |
| 13 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 14 | #include "frc971/wpilib/ahal/AnalogTriggerOutput.h" |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 15 | |
| 16 | namespace frc { |
| 17 | |
| 18 | class AnalogInput; |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 19 | class DutyCycle; |
| 20 | class SendableBuilder; |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 21 | |
| 22 | class AnalogTrigger { |
| 23 | friend class AnalogTriggerOutput; |
| 24 | |
| 25 | public: |
| 26 | explicit AnalogTrigger(int channel); |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 27 | explicit AnalogTrigger(AnalogInput* channel); |
| 28 | explicit AnalogTrigger(DutyCycle* dutyCycle); |
| 29 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 30 | virtual ~AnalogTrigger(); |
| 31 | |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 32 | AnalogTrigger(AnalogTrigger&& rhs); |
| 33 | AnalogTrigger& operator=(AnalogTrigger&& rhs); |
| 34 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 35 | void SetLimitsVoltage(double lower, double upper); |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 36 | |
| 37 | void SetLimitsDutyCycle(double lower, double upper); |
| 38 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 39 | void SetLimitsRaw(int lower, int upper); |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 40 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 41 | void SetAveraged(bool useAveragedValue); |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 42 | |
| 43 | void SetDutyCycle(bool useDutyCycle); |
| 44 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 45 | void SetFiltered(bool useFilteredValue); |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 46 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 47 | int GetIndex() const; |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 48 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 49 | bool GetInWindow(); |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 50 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 51 | bool GetTriggerState(); |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 52 | |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 53 | std::shared_ptr<AnalogTriggerOutput> CreateOutput( |
| 54 | AnalogTriggerType type) const; |
| 55 | |
| 56 | private: |
James Kuszmaul | 41fa78a | 2019-12-14 20:53:14 -0800 | [diff] [blame^] | 57 | hal::Handle<HAL_AnalogTriggerHandle> m_trigger; |
| 58 | AnalogInput* m_analogInput = nullptr; |
| 59 | DutyCycle* m_dutyCycle = nullptr; |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 60 | bool m_ownsAnalog = false; |
| 61 | }; |
| 62 | |
| 63 | } // namespace frc |