mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[hal, wpilib] Remove analog output (#7696)
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
// 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
|
||||
@@ -58,19 +58,8 @@ class SensorUtil final {
|
||||
*/
|
||||
static bool CheckAnalogInputChannel(int channel);
|
||||
|
||||
/**
|
||||
* Check that the analog output number is valid.
|
||||
*
|
||||
* Verify that the analog output number is one of the legal channel numbers.
|
||||
* Channel numbers are 0-based.
|
||||
*
|
||||
* @return Analog channel is valid
|
||||
*/
|
||||
static bool CheckAnalogOutputChannel(int channel);
|
||||
|
||||
static int GetNumDigitalChannels();
|
||||
static int GetNumAnalogInputs();
|
||||
static int GetNumAnalogOuputs();
|
||||
static int GetNumPwmChannels();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
// 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 <memory>
|
||||
|
||||
#include "frc/simulation/CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class AnalogOutput;
|
||||
|
||||
namespace sim {
|
||||
|
||||
/**
|
||||
* Class to control a simulated analog output.
|
||||
*/
|
||||
class AnalogOutputSim {
|
||||
public:
|
||||
/**
|
||||
* Constructs from an AnalogOutput object.
|
||||
*
|
||||
* @param analogOutput AnalogOutput to simulate
|
||||
*/
|
||||
explicit AnalogOutputSim(const AnalogOutput& analogOutput);
|
||||
|
||||
/**
|
||||
* Constructs from an analog output channel number.
|
||||
*
|
||||
* @param channel Channel number
|
||||
*/
|
||||
explicit AnalogOutputSim(int channel);
|
||||
|
||||
/**
|
||||
* Register a callback to be run whenever the voltage changes.
|
||||
*
|
||||
* @param callback the callback
|
||||
* @param initialNotify whether to call the callback with the initial state
|
||||
* @return the CallbackStore object associated with this callback
|
||||
*/
|
||||
[[nodiscard]]
|
||||
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
/**
|
||||
* Read the analog output voltage.
|
||||
*
|
||||
* @return the voltage on this analog output
|
||||
*/
|
||||
double GetVoltage() const;
|
||||
|
||||
/**
|
||||
* Set the analog output voltage.
|
||||
*
|
||||
* @param voltage the new voltage on this analog output
|
||||
*/
|
||||
void SetVoltage(double voltage);
|
||||
|
||||
/**
|
||||
* Register a callback to be run when this analog output is initialized.
|
||||
*
|
||||
* @param callback the callback
|
||||
* @param initialNotify whether to run the callback with the initial state
|
||||
* @return the CallbackStore object associated with this callback
|
||||
*/
|
||||
[[nodiscard]]
|
||||
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
/**
|
||||
* Check whether this analog output has been initialized.
|
||||
*
|
||||
* @return true if initialized
|
||||
*/
|
||||
bool GetInitialized() const;
|
||||
|
||||
/**
|
||||
* Define whether this analog output has been initialized.
|
||||
*
|
||||
* @param initialized whether this object is initialized
|
||||
*/
|
||||
void SetInitialized(bool initialized);
|
||||
|
||||
/**
|
||||
* Reset all simulation data on this object.
|
||||
*/
|
||||
void ResetData();
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user