blob: fdc12decc7acab8578735649f4d160c810a910b7 [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
James Kuszmaul41fa78a2019-12-14 20:53:14 -080010#include <hal/Types.h>
11
Philipp Schrader790cb542023-07-05 21:06:52 -070012#include <memory>
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);
Philipp Schrader790cb542023-07-05 21:06:52 -070027 explicit AnalogTrigger(AnalogInput *channel);
28 explicit AnalogTrigger(DutyCycle *dutyCycle);
James Kuszmaul41fa78a2019-12-14 20:53:14 -080029
Parker Schuhd3b7a8872018-02-19 16:42:27 -080030 virtual ~AnalogTrigger();
31
Philipp Schrader790cb542023-07-05 21:06:52 -070032 AnalogTrigger(AnalogTrigger &&rhs);
33 AnalogTrigger &operator=(AnalogTrigger &&rhs);
James Kuszmaul41fa78a2019-12-14 20:53:14 -080034
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;
Philipp Schrader790cb542023-07-05 21:06:52 -070058 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