[hal, wpilib] Remove analog output (#7696)

This commit is contained in:
Thad House
2025-01-16 23:20:44 -08:00
committed by GitHub
parent 5017393b3a
commit ff1b2a205e
45 changed files with 0 additions and 1685 deletions

View File

@@ -1,61 +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.
#include "frc/AnalogOutput.h"
#include <string>
#include <hal/AnalogOutput.h>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/Ports.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
#include "frc/Errors.h"
#include "frc/SensorUtil.h"
using namespace frc;
AnalogOutput::AnalogOutput(int channel) {
if (!SensorUtil::CheckAnalogOutputChannel(channel)) {
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
}
m_channel = channel;
HAL_PortHandle port = HAL_GetPort(m_channel);
int32_t status = 0;
std::string stackTrace = wpi::GetStackTrace(1);
m_port = HAL_InitializeAnalogOutputPort(port, stackTrace.c_str(), &status);
FRC_CheckErrorStatus(status, "Channel {}", channel);
HAL_Report(HALUsageReporting::kResourceType_AnalogOutput, m_channel + 1);
wpi::SendableRegistry::AddLW(this, "AnalogOutput", m_channel);
}
void AnalogOutput::SetVoltage(double voltage) {
int32_t status = 0;
HAL_SetAnalogOutput(m_port, voltage, &status);
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
}
double AnalogOutput::GetVoltage() const {
int32_t status = 0;
double voltage = HAL_GetAnalogOutput(m_port, &status);
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
return voltage;
}
int AnalogOutput::GetChannel() const {
return m_channel;
}
void AnalogOutput::InitSendable(wpi::SendableBuilder& builder) {
builder.SetSmartDashboardType("Analog Output");
builder.AddDoubleProperty(
"Value", [=, this] { return GetVoltage(); },
[=, this](double value) { SetVoltage(value); });
}

View File

@@ -5,7 +5,6 @@
#include "frc/SensorUtil.h"
#include <hal/AnalogInput.h>
#include <hal/AnalogOutput.h>
#include <hal/DIO.h>
#include <hal/PWM.h>
#include <hal/Ports.h>
@@ -32,10 +31,6 @@ bool SensorUtil::CheckAnalogInputChannel(int channel) {
return HAL_CheckAnalogInputChannel(channel);
}
bool SensorUtil::CheckAnalogOutputChannel(int channel) {
return HAL_CheckAnalogOutputChannel(channel);
}
int SensorUtil::GetNumDigitalChannels() {
return HAL_GetNumDigitalChannels();
}
@@ -44,10 +39,6 @@ int SensorUtil::GetNumAnalogInputs() {
return HAL_GetNumAnalogInputs();
}
int SensorUtil::GetNumAnalogOuputs() {
return HAL_GetNumAnalogOutputs();
}
int SensorUtil::GetNumPwmChannels() {
return HAL_GetNumPWMChannels();
}

View File

@@ -1,57 +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.
#include "frc/simulation/AnalogOutputSim.h"
#include <memory>
#include <hal/simulation/AnalogOutData.h>
#include "frc/AnalogOutput.h"
using namespace frc;
using namespace frc::sim;
AnalogOutputSim::AnalogOutputSim(const AnalogOutput& analogOutput)
: m_index{analogOutput.GetChannel()} {}
AnalogOutputSim::AnalogOutputSim(int channel) : m_index{channel} {}
std::unique_ptr<CallbackStore> AnalogOutputSim::RegisterVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogOutVoltageCallback);
store->SetUid(HALSIM_RegisterAnalogOutVoltageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double AnalogOutputSim::GetVoltage() const {
return HALSIM_GetAnalogOutVoltage(m_index);
}
void AnalogOutputSim::SetVoltage(double voltage) {
HALSIM_SetAnalogOutVoltage(m_index, voltage);
}
std::unique_ptr<CallbackStore> AnalogOutputSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogOutInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogOutInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool AnalogOutputSim::GetInitialized() const {
return HALSIM_GetAnalogOutInitialized(m_index);
}
void AnalogOutputSim::SetInitialized(bool initialized) {
HALSIM_SetAnalogOutInitialized(m_index, initialized);
}
void AnalogOutputSim::ResetData() {
HALSIM_ResetAnalogOutData(m_index);
}