[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:
Thad House
2026-04-17 19:38:25 -07:00
committed by GitHub
parent fdb454a6b1
commit 6cb6903780
73 changed files with 69 additions and 1834 deletions

View File

@@ -56,22 +56,7 @@ public class AnalogInput implements Sendable, AutoCloseable {
}
/**
* 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 this channel. Use getAverageVoltage() to get the analog value in calibrated
* units.
*
* @return A sample from the oversample and average engine for this channel.
*/
public int getAverageValue() {
return AnalogInputJNI.getAnalogAverageValue(m_port);
}
/**
* 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().
* Get a scaled sample straight from this channel. The value is scaled to units of Volts.
*
* @return A scaled sample straight from this channel.
*/
@@ -79,43 +64,6 @@ public class AnalogInput implements Sendable, AutoCloseable {
return AnalogInputJNI.getAnalogVoltage(m_port);
}
/**
* 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.
*/
public double getAverageVoltage() {
return AnalogInputJNI.getAnalogAverageVoltage(m_port);
}
/**
* Get the factory scaling the least significant bit weight constant. The least significant bit
* weight constant for the channel that was calibrated in manufacturing and stored in an eeprom.
*
* <p>Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
*
* @return Least significant bit weight.
*/
public long getLSBWeight() {
return AnalogInputJNI.getAnalogLSBWeight(m_port);
}
/**
* Get the factory scaling offset constant. The offset constant for the channel that was
* calibrated in manufacturing and stored in an eeprom.
*
* <p>Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
*
* @return Offset constant.
*/
public int getOffset() {
return AnalogInputJNI.getAnalogOffset(m_port);
}
/**
* Get the channel number.
*
@@ -125,70 +73,6 @@ public class AnalogInput implements Sendable, AutoCloseable {
return m_channel;
}
/**
* Set the number of averaging bits. This sets the number of averaging bits. The actual number of
* averaged samples is 2^bits. The averaging is done automatically in the FPGA.
*
* @param bits The number of averaging bits.
*/
public void setAverageBits(final int bits) {
AnalogInputJNI.setAnalogAverageBits(m_port, bits);
}
/**
* Get the number of averaging bits. 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 The number of averaging bits.
*/
public int getAverageBits() {
return AnalogInputJNI.getAnalogAverageBits(m_port);
}
/**
* Set the number of oversample bits. This sets the number of oversample bits. The actual number
* of oversampled values is 2^bits. The oversampling is done automatically in the FPGA.
*
* @param bits The number of oversample bits.
*/
public void setOversampleBits(final int bits) {
AnalogInputJNI.setAnalogOversampleBits(m_port, bits);
}
/**
* Get the number of oversample bits. 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 The number of oversample bits.
*/
public int getOversampleBits() {
return AnalogInputJNI.getAnalogOversampleBits(m_port);
}
/**
* Set the sample rate per channel.
*
* <p>This is a global setting for all channels. The maximum rate is 500kS/s divided by the number
* of channels in use. This is 62500 samples/s per channel if all 8 channels are used.
*
* @param samplesPerSecond The number of samples per second.
*/
public static void setGlobalSampleRate(final double samplesPerSecond) {
AnalogInputJNI.setAnalogSampleRate(samplesPerSecond);
}
/**
* Get the current sample rate.
*
* <p>This assumes one entry in the scan list. This is a global setting for all channels.
*
* @return Sample rate.
*/
public static double getGlobalSampleRate() {
return AnalogInputJNI.getAnalogSampleRate();
}
/**
* Indicates this input is used by a simulated device.
*
@@ -201,6 +85,6 @@ public class AnalogInput implements Sendable, AutoCloseable {
@Override
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Analog Input");
builder.addDoubleProperty("Value", this::getAverageVoltage, null);
builder.addDoubleProperty("Value", this::getVoltage, null);
}
}

View File

@@ -7,7 +7,6 @@ package org.wpilib.hardware.discrete;
import org.wpilib.hardware.hal.DIOJNI;
import org.wpilib.hardware.hal.HAL;
import org.wpilib.hardware.hal.SimDevice;
import org.wpilib.system.SensorUtil;
import org.wpilib.util.sendable.Sendable;
import org.wpilib.util.sendable.SendableBuilder;
import org.wpilib.util.sendable.SendableRegistry;
@@ -29,7 +28,6 @@ public class DigitalInput implements AutoCloseable, Sendable {
*/
@SuppressWarnings("this-escape")
public DigitalInput(int channel) {
SensorUtil.checkDigitalChannel(channel);
m_channel = channel;
m_handle = DIOJNI.initializeDIOPort(channel, true);

View File

@@ -7,7 +7,6 @@ package org.wpilib.hardware.discrete;
import org.wpilib.hardware.hal.DIOJNI;
import org.wpilib.hardware.hal.HAL;
import org.wpilib.hardware.hal.SimDevice;
import org.wpilib.system.SensorUtil;
import org.wpilib.util.sendable.Sendable;
import org.wpilib.util.sendable.SendableBuilder;
import org.wpilib.util.sendable.SendableRegistry;
@@ -30,7 +29,6 @@ public class DigitalOutput implements AutoCloseable, Sendable {
*/
@SuppressWarnings("this-escape")
public DigitalOutput(int channel) {
SensorUtil.checkDigitalChannel(channel);
m_channel = channel;
m_handle = DIOJNI.initializeDIOPort(channel, false);
@@ -161,8 +159,6 @@ public class DigitalOutput implements AutoCloseable, Sendable {
if (m_pwmGenerator == invalidPwmGenerator) {
return;
}
// Disable the output by routing to a dead bit.
DIOJNI.setDigitalPWMOutputChannel(m_pwmGenerator, SensorUtil.NUM_DIGITAL_CHANNELS);
DIOJNI.freeDigitalPWM(m_pwmGenerator);
m_pwmGenerator = invalidPwmGenerator;
}

View File

@@ -7,7 +7,6 @@ package org.wpilib.hardware.discrete;
import org.wpilib.hardware.hal.HAL;
import org.wpilib.hardware.hal.PWMJNI;
import org.wpilib.hardware.hal.SimDevice;
import org.wpilib.system.SensorUtil;
import org.wpilib.util.sendable.Sendable;
import org.wpilib.util.sendable.SendableBuilder;
import org.wpilib.util.sendable.SendableRegistry;
@@ -46,7 +45,6 @@ public class PWM implements Sendable, AutoCloseable {
*/
@SuppressWarnings("this-escape")
public PWM(final int channel, final boolean registerSendable) {
SensorUtil.checkPWMChannel(channel);
m_channel = channel;
m_handle = PWMJNI.initializePWMPort(channel);