2014-06-12 18:07:45 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-08-25 18:42:00 -07:00
|
|
|
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
2014-06-12 18:07:45 -04:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2018-10-29 12:49:17 -07:00
|
|
|
#include <hal/Types.h>
|
2017-08-27 00:11:52 -07:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/ErrorBase.h"
|
2019-09-14 15:22:54 -05:00
|
|
|
#include "frc/smartdashboard/Sendable.h"
|
|
|
|
|
#include "frc/smartdashboard/SendableHelper.h"
|
2014-06-12 18:07:45 -04:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
class SendableBuilder;
|
|
|
|
|
|
2014-06-12 18:07:45 -04:00
|
|
|
/**
|
|
|
|
|
* MXP analog output class.
|
|
|
|
|
*/
|
2019-09-14 15:22:54 -05:00
|
|
|
class AnalogOutput : public ErrorBase,
|
|
|
|
|
public Sendable,
|
|
|
|
|
public 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.
|
|
|
|
|
*/
|
2016-12-23 11:20:13 -08:00
|
|
|
int GetChannel();
|
2014-06-12 18:07:45 -04:00
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
void InitSendable(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
|