2020-12-26 14:12:05 -08:00
|
|
|
// 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.
|
2014-06-12 18:07:45 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2018-10-29 12:49:17 -07:00
|
|
|
#include <hal/Types.h>
|
2021-06-13 16:38:05 -07:00
|
|
|
#include <wpi/sendable/Sendable.h>
|
|
|
|
|
#include <wpi/sendable/SendableHelper.h>
|
2014-06-12 18:07:45 -04:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2014-06-12 18:07:45 -04:00
|
|
|
/**
|
|
|
|
|
* MXP analog output class.
|
|
|
|
|
*/
|
2021-06-13 16:38:05 -07:00
|
|
|
class AnalogOutput : public wpi::Sendable,
|
|
|
|
|
public wpi::SendableHelper<AnalogOutput> {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
explicit AnalogOutput(int channel);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
~AnalogOutput() override;
|
2014-06-12 18:07:45 -04:00
|
|
|
|
2019-08-25 18:42:00 -07:00
|
|
|
AnalogOutput(AnalogOutput&&) = default;
|
|
|
|
|
AnalogOutput& operator=(AnalogOutput&&) = default;
|
2018-09-24 00:08:25 -07:00
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Set the value of the analog output.
|
|
|
|
|
*
|
|
|
|
|
* @param voltage The output value in Volts, from 0.0 to +5.0
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
void SetVoltage(double voltage);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the voltage of the analog output
|
|
|
|
|
*
|
|
|
|
|
* @return The value in Volts, from 0.0 to +5.0
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double GetVoltage() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the channel of this AnalogOutput.
|
|
|
|
|
*/
|
2020-07-04 10:10:43 -07:00
|
|
|
int GetChannel() const;
|
2014-06-12 18:07:45 -04:00
|
|
|
|
2021-06-13 16:38:05 -07:00
|
|
|
void InitSendable(wpi::SendableBuilder& builder) override;
|
2014-06-12 18:07:45 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
protected:
|
2016-09-06 00:01:45 -07:00
|
|
|
int m_channel;
|
2019-08-25 18:42:00 -07:00
|
|
|
hal::Handle<HAL_AnalogOutputHandle> m_port;
|
2014-06-12 18:07:45 -04:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|