1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <hal/AnalogOutput.h>
#include <hal/Types.h>
#include <wpi/sendable/Sendable.h>
#include <wpi/sendable/SendableHelper.h>
namespace frc {
/**
* MXP analog output class.
*/
class AnalogOutput : public wpi::Sendable,
public wpi::SendableHelper<AnalogOutput> {
public:
/**
* Construct an analog output on the given channel.
*
* All analog outputs are located on the MXP port.
*
* @param channel The channel number on the roboRIO to represent.
*/
explicit AnalogOutput(int channel);
AnalogOutput(AnalogOutput&&) = default;
AnalogOutput& operator=(AnalogOutput&&) = default;
~AnalogOutput() override = default;
/**
* Set the value of the analog output.
*
* @param voltage The output value in Volts, from 0.0 to +5.0.
*/
void SetVoltage(double voltage);
/**
* Get the voltage of the analog output.
*
* @return The value in Volts, from 0.0 to +5.0.
*/
double GetVoltage() const;
/**
* Get the channel of this AnalogOutput.
*/
int GetChannel() const;
void InitSendable(wpi::SendableBuilder& builder) override;
protected:
int m_channel;
hal::Handle<HAL_AnalogOutputHandle, HAL_FreeAnalogOutputPort> m_port;
};
} // namespace frc