mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal,wpilib] Remove a ton of things related to the FPGA (#7846)
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
This commit is contained in:
@@ -17,10 +17,6 @@
|
||||
using namespace wpi;
|
||||
|
||||
AnalogInput::AnalogInput(int channel) {
|
||||
if (!SensorUtil::CheckAnalogInputChannel(channel)) {
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
|
||||
m_channel = channel;
|
||||
int32_t status = 0;
|
||||
std::string stackTrace = wpi::util::GetStackTrace(1);
|
||||
@@ -39,13 +35,6 @@ int AnalogInput::GetValue() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
int AnalogInput::GetAverageValue() const {
|
||||
int32_t status = 0;
|
||||
int value = HAL_GetAnalogAverageValue(m_port, &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return value;
|
||||
}
|
||||
|
||||
double AnalogInput::GetVoltage() const {
|
||||
int32_t status = 0;
|
||||
double voltage = HAL_GetAnalogVoltage(m_port, &status);
|
||||
@@ -53,70 +42,10 @@ double AnalogInput::GetVoltage() const {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
double AnalogInput::GetAverageVoltage() const {
|
||||
int32_t status = 0;
|
||||
double voltage = HAL_GetAnalogAverageVoltage(m_port, &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return voltage;
|
||||
}
|
||||
|
||||
int AnalogInput::GetChannel() const {
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
void AnalogInput::SetAverageBits(int bits) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogAverageBits(m_port, bits, &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
int AnalogInput::GetAverageBits() const {
|
||||
int32_t status = 0;
|
||||
int averageBits = HAL_GetAnalogAverageBits(m_port, &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return averageBits;
|
||||
}
|
||||
|
||||
void AnalogInput::SetOversampleBits(int bits) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogOversampleBits(m_port, bits, &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
int AnalogInput::GetOversampleBits() const {
|
||||
int32_t status = 0;
|
||||
int oversampleBits = HAL_GetAnalogOversampleBits(m_port, &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return oversampleBits;
|
||||
}
|
||||
|
||||
int AnalogInput::GetLSBWeight() const {
|
||||
int32_t status = 0;
|
||||
int lsbWeight = HAL_GetAnalogLSBWeight(m_port, &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return lsbWeight;
|
||||
}
|
||||
|
||||
int AnalogInput::GetOffset() const {
|
||||
int32_t status = 0;
|
||||
int offset = HAL_GetAnalogOffset(m_port, &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return offset;
|
||||
}
|
||||
|
||||
void AnalogInput::SetSampleRate(double samplesPerSecond) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogSampleRate(samplesPerSecond, &status);
|
||||
WPILIB_CheckErrorStatus(status, "SetSampleRate");
|
||||
}
|
||||
|
||||
double AnalogInput::GetSampleRate() {
|
||||
int32_t status = 0;
|
||||
double sampleRate = HAL_GetAnalogSampleRate(&status);
|
||||
WPILIB_CheckErrorStatus(status, "GetSampleRate");
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
HAL_SetAnalogInputSimDevice(m_port, device);
|
||||
}
|
||||
@@ -124,5 +53,5 @@ void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
void AnalogInput::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Input");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=, this] { return GetAverageVoltage(); }, nullptr);
|
||||
"Value", [=, this] { return GetVoltage(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
using namespace wpi;
|
||||
|
||||
DigitalInput::DigitalInput(int channel) {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
@@ -18,9 +18,6 @@ using namespace wpi;
|
||||
|
||||
DigitalOutput::DigitalOutput(int channel) {
|
||||
m_pwmGenerator = HAL_INVALID_HANDLE;
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
@@ -120,9 +117,6 @@ void DigitalOutput::DisablePWM() {
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
// Disable the output by routing to a dead bit.
|
||||
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator,
|
||||
SensorUtil::GetNumDigitalChannels(), &status);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
HAL_FreeDigitalPWM(m_pwmGenerator);
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
using namespace wpi;
|
||||
|
||||
PWM::PWM(int channel, bool registerSendable) {
|
||||
if (!SensorUtil::CheckPWMChannel(channel)) {
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
|
||||
auto stack = wpi::util::GetStackTrace(1);
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializePWMPort(channel, stack.c_str(), &status);
|
||||
|
||||
@@ -9,16 +9,11 @@
|
||||
#include "wpi/hal/AddressableLED.h"
|
||||
#include "wpi/hal/UsageReporting.hpp"
|
||||
#include "wpi/system/Errors.hpp"
|
||||
#include "wpi/util/SensorUtil.hpp"
|
||||
#include "wpi/util/StackTrace.hpp"
|
||||
|
||||
using namespace wpi;
|
||||
|
||||
AddressableLED::AddressableLED(int channel) : m_channel{channel} {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::util::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeAddressableLED(channel, stack.c_str(), &status);
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
using namespace wpi;
|
||||
|
||||
DutyCycle::DutyCycle(int channel) : m_channel{channel} {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
InitDutyCycle();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,40 +34,6 @@ void AnalogInputSim::SetInitialized(bool initialized) {
|
||||
HALSIM_SetAnalogInInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterAverageBitsCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAverageBitsCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAverageBitsCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int AnalogInputSim::GetAverageBits() const {
|
||||
return HALSIM_GetAnalogInAverageBits(m_index);
|
||||
}
|
||||
|
||||
void AnalogInputSim::SetAverageBits(int averageBits) {
|
||||
HALSIM_SetAnalogInAverageBits(m_index, averageBits);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterOversampleBitsCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInOversampleBitsCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInOversampleBitsCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int AnalogInputSim::GetOversampleBits() const {
|
||||
return HALSIM_GetAnalogInOversampleBits(m_index);
|
||||
}
|
||||
|
||||
void AnalogInputSim::SetOversampleBits(int oversampleBits) {
|
||||
HALSIM_SetAnalogInOversampleBits(m_index, oversampleBits);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
#include "wpi/util/SensorUtil.hpp"
|
||||
|
||||
#include "wpi/hal/AnalogInput.h"
|
||||
#include "wpi/hal/DIO.h"
|
||||
#include "wpi/hal/PWM.h"
|
||||
#include "wpi/hal/Ports.h"
|
||||
|
||||
using namespace wpi;
|
||||
@@ -19,26 +16,6 @@ int SensorUtil::GetDefaultREVPHModule() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool SensorUtil::CheckDigitalChannel(int channel) {
|
||||
return HAL_CheckDIOChannel(channel);
|
||||
}
|
||||
|
||||
bool SensorUtil::CheckPWMChannel(int channel) {
|
||||
return HAL_CheckPWMChannel(channel);
|
||||
}
|
||||
|
||||
bool SensorUtil::CheckAnalogInputChannel(int channel) {
|
||||
return HAL_CheckAnalogInputChannel(channel);
|
||||
}
|
||||
|
||||
int SensorUtil::GetNumDigitalChannels() {
|
||||
return HAL_GetNumDigitalChannels();
|
||||
}
|
||||
|
||||
int SensorUtil::GetNumAnalogInputs() {
|
||||
return HAL_GetNumAnalogInputs();
|
||||
}
|
||||
|
||||
int SensorUtil::GetNumPwmChannels() {
|
||||
return HAL_GetNumPWMChannels();
|
||||
int SensorUtil::GetNumSmartIoPorts() {
|
||||
return HAL_GetNumSmartIo();
|
||||
}
|
||||
|
||||
@@ -28,14 +28,10 @@
|
||||
#include "wpi/util/print.hpp"
|
||||
#include "wpi/util/timestamp.hpp"
|
||||
|
||||
static_assert(wpi::RuntimeType::ROBORIO ==
|
||||
static_cast<wpi::RuntimeType>(HAL_RUNTIME_ROBORIO));
|
||||
static_assert(wpi::RuntimeType::ROBORIO_2 ==
|
||||
static_cast<wpi::RuntimeType>(HAL_RUNTIME_ROBORIO_2));
|
||||
static_assert(wpi::RuntimeType::SIMULATION ==
|
||||
static_cast<wpi::RuntimeType>(HAL_RUNTIME_SIMULATION));
|
||||
static_assert(wpi::RuntimeType::SYSTEMCORE ==
|
||||
static_cast<wpi::RuntimeType>(HAL_RUNTIME_SYSTEMCORE));
|
||||
static_assert(wpi::RuntimeType::SIMULATION ==
|
||||
static_cast<wpi::RuntimeType>(HAL_RUNTIME_SIMULATION));
|
||||
|
||||
using SetCameraServerSharedFP = void (*)(wpi::CameraServerShared*);
|
||||
|
||||
|
||||
@@ -51,52 +51,15 @@ class AnalogInput : public wpi::util::Sendable,
|
||||
*/
|
||||
int GetValue() const;
|
||||
|
||||
/**
|
||||
* Get a sample from the output of the oversample and average engine for this
|
||||
* channel.
|
||||
*
|
||||
* The sample is 12-bit + the bits configured in SetOversampleBits().
|
||||
* The value configured in SetAverageBits() will cause this value to be
|
||||
* averaged 2**bits number of samples.
|
||||
*
|
||||
* This is not a sliding window. The sample will not change until
|
||||
* 2**(OversampleBits + AverageBits) samples have been acquired from the
|
||||
* module on this channel.
|
||||
*
|
||||
* Use GetAverageVoltage() to get the analog value in calibrated units.
|
||||
*
|
||||
* @return A sample from the oversample and average engine for this channel.
|
||||
*/
|
||||
int GetAverageValue() const;
|
||||
|
||||
/**
|
||||
* Get a scaled sample straight from this channel.
|
||||
*
|
||||
* The value is scaled to units of Volts using the calibrated scaling data
|
||||
* from GetLSBWeight() and GetOffset().
|
||||
* The value is scaled to units of Volts.
|
||||
*
|
||||
* @return A scaled sample straight from this channel.
|
||||
*/
|
||||
double GetVoltage() const;
|
||||
|
||||
/**
|
||||
* Get a scaled sample from the output of the oversample and average engine
|
||||
* for this channel.
|
||||
*
|
||||
* The value is scaled to units of Volts using the calibrated scaling data
|
||||
* from GetLSBWeight() and GetOffset().
|
||||
*
|
||||
* Using oversampling will cause this value to be higher resolution, but it
|
||||
* will update more slowly.
|
||||
*
|
||||
* Using averaging will cause this value to be more stable, but it will update
|
||||
* more slowly.
|
||||
*
|
||||
* @return A scaled sample from the output of the oversample and average
|
||||
* engine for this channel.
|
||||
*/
|
||||
double GetAverageVoltage() const;
|
||||
|
||||
/**
|
||||
* Get the channel number.
|
||||
*
|
||||
@@ -104,88 +67,6 @@ class AnalogInput : public wpi::util::Sendable,
|
||||
*/
|
||||
int GetChannel() const;
|
||||
|
||||
/**
|
||||
* Set the number of averaging bits.
|
||||
*
|
||||
* This sets the number of averaging bits. The actual number of averaged
|
||||
* samples is 2^bits.
|
||||
*
|
||||
* Use averaging to improve the stability of your measurement at the expense
|
||||
* of sampling rate. The averaging is done automatically in the FPGA.
|
||||
*
|
||||
* @param bits Number of bits of averaging.
|
||||
*/
|
||||
void SetAverageBits(int bits);
|
||||
|
||||
/**
|
||||
* Get the number of averaging bits previously configured.
|
||||
*
|
||||
* This gets the number of averaging bits from the FPGA. The actual number of
|
||||
* averaged samples is 2^bits. The averaging is done automatically in the
|
||||
* FPGA.
|
||||
*
|
||||
* @return Number of bits of averaging previously configured.
|
||||
*/
|
||||
int GetAverageBits() const;
|
||||
|
||||
/**
|
||||
* Set the number of oversample bits.
|
||||
*
|
||||
* This sets the number of oversample bits. The actual number of oversampled
|
||||
* values is 2^bits. Use oversampling to improve the resolution of your
|
||||
* measurements at the expense of sampling rate. The oversampling is done
|
||||
* automatically in the FPGA.
|
||||
*
|
||||
* @param bits Number of bits of oversampling.
|
||||
*/
|
||||
void SetOversampleBits(int bits);
|
||||
|
||||
/**
|
||||
* Get the number of oversample bits previously configured.
|
||||
*
|
||||
* This gets the number of oversample bits from the FPGA. The actual number of
|
||||
* oversampled values is 2^bits. The oversampling is done automatically in the
|
||||
* FPGA.
|
||||
*
|
||||
* @return Number of bits of oversampling previously configured.
|
||||
*/
|
||||
int GetOversampleBits() const;
|
||||
|
||||
/**
|
||||
* Get the factory scaling least significant bit weight constant.
|
||||
*
|
||||
* Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
|
||||
*
|
||||
* @return Least significant bit weight.
|
||||
*/
|
||||
int GetLSBWeight() const;
|
||||
|
||||
/**
|
||||
* Get the factory scaling offset constant.
|
||||
*
|
||||
* Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
|
||||
*
|
||||
* @return Offset constant.
|
||||
*/
|
||||
int GetOffset() const;
|
||||
|
||||
/**
|
||||
* Set the sample rate per channel for all analog channels.
|
||||
*
|
||||
* The maximum rate is 500kS/s divided by the number of channels in use.
|
||||
* This is 62500 samples/s per channel.
|
||||
*
|
||||
* @param samplesPerSecond The number of samples per second.
|
||||
*/
|
||||
static void SetSampleRate(double samplesPerSecond);
|
||||
|
||||
/**
|
||||
* Get the current sample rate for all channels
|
||||
*
|
||||
* @return Sample rate.
|
||||
*/
|
||||
static double GetSampleRate();
|
||||
|
||||
/**
|
||||
* Indicates this input is used by a simulated device.
|
||||
*
|
||||
|
||||
@@ -16,12 +16,7 @@ namespace wpi {
|
||||
class AddressableLED;
|
||||
|
||||
/**
|
||||
* Class implements the PWM generation in the FPGA.
|
||||
*
|
||||
* The values supplied as arguments for PWM outputs range from -1.0 to 1.0. They
|
||||
* are mapped to the microseconds to keep the pulse high, with a range of 0
|
||||
* (off) to 4096. Changes are immediately sent to the FPGA, and the update
|
||||
* occurs at the next FPGA cycle (5.05ms). There is no delay.
|
||||
* Class for sending pulse-width modulation (PWM) signals.
|
||||
*/
|
||||
class PWM : public wpi::util::Sendable, public wpi::util::SendableHelper<PWM> {
|
||||
public:
|
||||
|
||||
@@ -59,58 +59,6 @@ class AnalogInputSim {
|
||||
*/
|
||||
void SetInitialized(bool initialized);
|
||||
|
||||
/**
|
||||
* Register a callback on the number of average bits.
|
||||
*
|
||||
* @param callback the callback that will be called whenever the number of
|
||||
* average bits is changed
|
||||
* @param initialNotify if true, the callback will be run on the initial value
|
||||
* @return the CallbackStore object associated with this callback
|
||||
*/
|
||||
[[nodiscard]]
|
||||
std::unique_ptr<CallbackStore> RegisterAverageBitsCallback(
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
/**
|
||||
* Get the number of average bits.
|
||||
*
|
||||
* @return the number of average bits
|
||||
*/
|
||||
int GetAverageBits() const;
|
||||
|
||||
/**
|
||||
* Change the number of average bits.
|
||||
*
|
||||
* @param averageBits the new value
|
||||
*/
|
||||
void SetAverageBits(int averageBits);
|
||||
|
||||
/**
|
||||
* Register a callback on the amount of oversampling bits.
|
||||
*
|
||||
* @param callback the callback that will be called whenever the oversampling
|
||||
* bits are changed
|
||||
* @param initialNotify if true, the callback will be run on the initial value
|
||||
* @return the CallbackStore object associated with this callback
|
||||
*/
|
||||
[[nodiscard]]
|
||||
std::unique_ptr<CallbackStore> RegisterOversampleBitsCallback(
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
/**
|
||||
* Get the amount of oversampling bits.
|
||||
*
|
||||
* @return the amount of oversampling bits
|
||||
*/
|
||||
int GetOversampleBits() const;
|
||||
|
||||
/**
|
||||
* Change the amount of oversampling bits.
|
||||
*
|
||||
* @param oversampleBits the new value
|
||||
*/
|
||||
void SetOversampleBits(int oversampleBits);
|
||||
|
||||
/**
|
||||
* Register a callback on the voltage.
|
||||
*
|
||||
|
||||
@@ -9,12 +9,9 @@ namespace wpi {
|
||||
* Runtime type.
|
||||
*/
|
||||
enum class RuntimeType {
|
||||
/// roboRIO 1.0.
|
||||
ROBORIO,
|
||||
/// roboRIO 2.0.
|
||||
ROBORIO_2,
|
||||
/// Systemcore runtime.
|
||||
SYSTEMCORE,
|
||||
/// Simulation runtime.
|
||||
SIMULATION,
|
||||
SYSTEMCORE
|
||||
SIMULATION
|
||||
};
|
||||
} // namespace wpi
|
||||
|
||||
@@ -28,39 +28,7 @@ class SensorUtil final {
|
||||
*/
|
||||
static int GetDefaultREVPHModule();
|
||||
|
||||
/**
|
||||
* Check that the digital channel number is valid.
|
||||
*
|
||||
* Verify that the channel number is one of the legal channel numbers. Channel
|
||||
* numbers are 0-based.
|
||||
*
|
||||
* @return Digital channel is valid
|
||||
*/
|
||||
static bool CheckDigitalChannel(int channel);
|
||||
|
||||
/**
|
||||
* Check that the PWM channel number is valid.
|
||||
*
|
||||
* Verify that the channel number is one of the legal channel numbers. Channel
|
||||
* numbers are 0-based.
|
||||
*
|
||||
* @return PWM channel is valid
|
||||
*/
|
||||
static bool CheckPWMChannel(int channel);
|
||||
|
||||
/**
|
||||
* Check that the analog input number is value.
|
||||
*
|
||||
* Verify that the analog input number is one of the legal channel numbers.
|
||||
* Channel numbers are 0-based.
|
||||
*
|
||||
* @return Analog channel is valid
|
||||
*/
|
||||
static bool CheckAnalogInputChannel(int channel);
|
||||
|
||||
static int GetNumDigitalChannels();
|
||||
static int GetNumAnalogInputs();
|
||||
static int GetNumPwmChannels();
|
||||
static int GetNumSmartIoPorts();
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
|
||||
@@ -8,18 +8,8 @@ classes:
|
||||
methods:
|
||||
AnalogInput:
|
||||
GetValue:
|
||||
GetAverageValue:
|
||||
GetVoltage:
|
||||
GetAverageVoltage:
|
||||
GetChannel:
|
||||
SetAverageBits:
|
||||
GetAverageBits:
|
||||
SetOversampleBits:
|
||||
GetOversampleBits:
|
||||
GetLSBWeight:
|
||||
GetOffset:
|
||||
SetSampleRate:
|
||||
GetSampleRate:
|
||||
SetSimDevice:
|
||||
InitSendable:
|
||||
|
||||
|
||||
@@ -2,11 +2,6 @@ classes:
|
||||
wpi::SensorUtil:
|
||||
nodelete: true
|
||||
methods:
|
||||
CheckDigitalChannel:
|
||||
CheckPWMChannel:
|
||||
CheckAnalogInputChannel:
|
||||
GetDefaultCTREPCMModule:
|
||||
GetDefaultREVPHModule:
|
||||
GetNumDigitalChannels:
|
||||
GetNumAnalogInputs:
|
||||
GetNumPwmChannels:
|
||||
GetNumSmartIoPorts:
|
||||
|
||||
@@ -13,12 +13,6 @@ classes:
|
||||
RegisterInitializedCallback:
|
||||
GetInitialized:
|
||||
SetInitialized:
|
||||
RegisterAverageBitsCallback:
|
||||
GetAverageBits:
|
||||
SetAverageBits:
|
||||
RegisterOversampleBitsCallback:
|
||||
GetOversampleBits:
|
||||
SetOversampleBits:
|
||||
RegisterVoltageCallback:
|
||||
GetVoltage:
|
||||
SetVoltage:
|
||||
|
||||
@@ -62,34 +62,4 @@ TEST(AnalogInputSimTest, SetVoltage) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AnalogInputSimTest, SetOverSampleBits) {
|
||||
HAL_Initialize(500, 0);
|
||||
AnalogInput input{5};
|
||||
AnalogInputSim sim(input);
|
||||
|
||||
IntCallback callback;
|
||||
auto cb = sim.RegisterOversampleBitsCallback(callback.GetCallback(), false);
|
||||
|
||||
input.SetOversampleBits(3504);
|
||||
EXPECT_EQ(3504, sim.GetOversampleBits());
|
||||
EXPECT_EQ(3504, input.GetOversampleBits());
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
EXPECT_EQ(3504, callback.GetLastValue());
|
||||
}
|
||||
|
||||
TEST(AnalogInputSimTest, SetAverageBits) {
|
||||
HAL_Initialize(500, 0);
|
||||
AnalogInput input{5};
|
||||
AnalogInputSim sim(input);
|
||||
|
||||
IntCallback callback;
|
||||
auto cb = sim.RegisterAverageBitsCallback(callback.GetCallback(), false);
|
||||
|
||||
input.SetAverageBits(3504);
|
||||
EXPECT_EQ(3504, sim.GetAverageBits());
|
||||
EXPECT_EQ(3504, input.GetAverageBits());
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
EXPECT_EQ(3504, callback.GetLastValue());
|
||||
}
|
||||
|
||||
} // namespace wpi::sim
|
||||
|
||||
Reference in New Issue
Block a user