[wpilib] Compressor: Add more Sendable data (#6687)

This commit is contained in:
Wispy
2024-06-03 09:47:17 -05:00
committed by GitHub
parent bdc42532ed
commit 5f8c842223
3 changed files with 22 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ import edu.wpi.first.util.sendable.SendableRegistry;
*/
public class Compressor implements Sendable, AutoCloseable {
private PneumaticsBase m_module;
private PneumaticsModuleType m_moduleType;
/**
* Constructs a compressor for a specified module and type.
@@ -34,6 +35,7 @@ public class Compressor implements Sendable, AutoCloseable {
@SuppressWarnings("this-escape")
public Compressor(int module, PneumaticsModuleType moduleType) {
m_module = PneumaticsBase.getForType(module, moduleType);
m_moduleType = moduleType;
if (!m_module.reserveCompressor()) {
m_module.close();
@@ -194,5 +196,10 @@ public class Compressor implements Sendable, AutoCloseable {
builder.setSmartDashboardType("Compressor");
builder.addBooleanProperty("Enabled", this::isEnabled, null);
builder.addBooleanProperty("Pressure switch", this::getPressureSwitchValue, null);
builder.addDoubleProperty("Current (A)", this::getCurrent, null);
if (m_moduleType == PneumaticsModuleType.REVPH) { // These are not supported by the CTRE PCM
builder.addDoubleProperty("Analog Voltage", this::getAnalogVoltage, null);
builder.addDoubleProperty("Pressure (PSI)", this::getPressure, null);
}
}
}