blob: 9fad5db9ac739ab217543a67a557cef7490c4a1e [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -08001/*----------------------------------------------------------------------------*/
James Kuszmaul41fa78a2019-12-14 20:53:14 -08002/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
Parker Schuhd3b7a8872018-02-19 16:42:27 -08003/* 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 Kuszmaul41fa78a2019-12-14 20:53:14 -080012#include <hal/Types.h>
13
Parker Schuhd3b7a8872018-02-19 16:42:27 -080014#include "frc971/wpilib/ahal/AnalogTriggerOutput.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080015
16namespace frc {
17
18class AnalogInput;
James Kuszmaul41fa78a2019-12-14 20:53:14 -080019class DutyCycle;
20class SendableBuilder;
Parker Schuhd3b7a8872018-02-19 16:42:27 -080021
22class AnalogTrigger {
23 friend class AnalogTriggerOutput;
24
25 public:
26 explicit AnalogTrigger(int channel);
James Kuszmaul41fa78a2019-12-14 20:53:14 -080027 explicit AnalogTrigger(AnalogInput* channel);
28 explicit AnalogTrigger(DutyCycle* dutyCycle);
29
Parker Schuhd3b7a8872018-02-19 16:42:27 -080030 virtual ~AnalogTrigger();
31
James Kuszmaul41fa78a2019-12-14 20:53:14 -080032 AnalogTrigger(AnalogTrigger&& rhs);
33 AnalogTrigger& operator=(AnalogTrigger&& rhs);
34
Parker Schuhd3b7a8872018-02-19 16:42:27 -080035 void SetLimitsVoltage(double lower, double upper);
James Kuszmaul41fa78a2019-12-14 20:53:14 -080036
37 void SetLimitsDutyCycle(double lower, double upper);
38
Parker Schuhd3b7a8872018-02-19 16:42:27 -080039 void SetLimitsRaw(int lower, int upper);
James Kuszmaul41fa78a2019-12-14 20:53:14 -080040
Parker Schuhd3b7a8872018-02-19 16:42:27 -080041 void SetAveraged(bool useAveragedValue);
James Kuszmaul41fa78a2019-12-14 20:53:14 -080042
43 void SetDutyCycle(bool useDutyCycle);
44
Parker Schuhd3b7a8872018-02-19 16:42:27 -080045 void SetFiltered(bool useFilteredValue);
James Kuszmaul41fa78a2019-12-14 20:53:14 -080046
Parker Schuhd3b7a8872018-02-19 16:42:27 -080047 int GetIndex() const;
James Kuszmaul41fa78a2019-12-14 20:53:14 -080048
Parker Schuhd3b7a8872018-02-19 16:42:27 -080049 bool GetInWindow();
James Kuszmaul41fa78a2019-12-14 20:53:14 -080050
Parker Schuhd3b7a8872018-02-19 16:42:27 -080051 bool GetTriggerState();
James Kuszmaul41fa78a2019-12-14 20:53:14 -080052
Parker Schuhd3b7a8872018-02-19 16:42:27 -080053 std::shared_ptr<AnalogTriggerOutput> CreateOutput(
54 AnalogTriggerType type) const;
55
56 private:
James Kuszmaul41fa78a2019-12-14 20:53:14 -080057 hal::Handle<HAL_AnalogTriggerHandle> m_trigger;
58 AnalogInput* m_analogInput = nullptr;
59 DutyCycle* m_dutyCycle = nullptr;
Parker Schuhd3b7a8872018-02-19 16:42:27 -080060 bool m_ownsAnalog = false;
61};
62
63} // namespace frc