mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpilib, hal] High Level REV PH changes (#3792)
More functionality was implemented at the HAL level, so expose that to the wpilib level. This also does units changes for all the PH related functionality.
This commit is contained in:
@@ -117,6 +117,15 @@ public class Compressor implements Sendable, AutoCloseable {
|
||||
return m_module.getCompressorCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the analog input voltage (on channel 0) (if supported).
|
||||
*
|
||||
* @return The analog input voltage, in volts
|
||||
*/
|
||||
public double getAnalogVoltage() {
|
||||
return m_module.getAnalogVoltage(0);
|
||||
}
|
||||
|
||||
/** Disable the compressor. */
|
||||
public void disable() {
|
||||
m_module.disableCompressor();
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.hal.PortsJNI;
|
||||
import edu.wpi.first.hal.REVPHFaults;
|
||||
import edu.wpi.first.hal.REVPHJNI;
|
||||
import edu.wpi.first.hal.REVPHStickyFaults;
|
||||
import edu.wpi.first.hal.REVPHVersion;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -16,6 +20,7 @@ public class PneumaticHub implements PneumaticsBase {
|
||||
private int m_refCount;
|
||||
private int m_reservedMask;
|
||||
private boolean m_compressorReserved;
|
||||
public int[] m_oneShotDurMs = new int[PortsJNI.getNumREVPHChannels()];
|
||||
private final Object m_reserveLock = new Object();
|
||||
|
||||
DataStore(int module) {
|
||||
@@ -123,14 +128,12 @@ public class PneumaticHub implements PneumaticsBase {
|
||||
|
||||
@Override
|
||||
public void fireOneShot(int index) {
|
||||
// TODO Combine APIs
|
||||
// REVPHJNI.fireOneShot(m_handle, index, durMs);
|
||||
REVPHJNI.fireOneShot(m_handle, index, m_dataStore.m_oneShotDurMs[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOneShotDuration(int index, int durMs) {
|
||||
// TODO Combine APIs
|
||||
// REVPHJNI.setOneShotDuration(m_handle, index, durMs);
|
||||
m_dataStore.m_oneShotDurMs[index] = durMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,8 +195,8 @@ public class PneumaticHub implements PneumaticsBase {
|
||||
|
||||
@Override
|
||||
public int getSolenoidDisabledList() {
|
||||
// TODO Get this working
|
||||
return 0;
|
||||
int raw = REVPHJNI.getStickyFaultsNative(m_handle);
|
||||
return raw & 0xFFFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,4 +218,41 @@ public class PneumaticHub implements PneumaticsBase {
|
||||
public void enableCompressorHybrid(double minAnalogVoltage, double maxAnalogVoltage) {
|
||||
REVPHJNI.setClosedLoopControlHybrid(m_handle, minAnalogVoltage, maxAnalogVoltage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAnalogVoltage(int channel) {
|
||||
return REVPHJNI.getAnalogVoltage(m_handle, channel);
|
||||
}
|
||||
|
||||
void clearStickyFaults() {
|
||||
REVPHJNI.clearStickyFaults(m_handle);
|
||||
}
|
||||
|
||||
REVPHVersion getVersion() {
|
||||
return REVPHJNI.getVersion(m_handle);
|
||||
}
|
||||
|
||||
REVPHFaults getFaults() {
|
||||
return REVPHJNI.getFaults(m_handle);
|
||||
}
|
||||
|
||||
REVPHStickyFaults getStickyFaults() {
|
||||
return REVPHJNI.getStickyFaults(m_handle);
|
||||
}
|
||||
|
||||
double getInputVoltage() {
|
||||
return REVPHJNI.getInputVoltage(m_handle);
|
||||
}
|
||||
|
||||
double get5VRegulatedVoltage() {
|
||||
return REVPHJNI.get5VVoltage(m_handle);
|
||||
}
|
||||
|
||||
double getSolenoidsTotalCurrent() {
|
||||
return REVPHJNI.getSolenoidCurrent(m_handle);
|
||||
}
|
||||
|
||||
double getSolenoidsVoltage() {
|
||||
return REVPHJNI.getSolenoidVoltage(m_handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,8 @@ public interface PneumaticsBase extends AutoCloseable {
|
||||
|
||||
void enableCompressorHybrid(double minAnalogVoltage, double maxAnalogVoltage);
|
||||
|
||||
double getAnalogVoltage(int channel);
|
||||
|
||||
CompressorConfigType getCompressorConfigType();
|
||||
|
||||
/**
|
||||
|
||||
@@ -250,4 +250,9 @@ public class PneumaticsControlModule implements PneumaticsBase {
|
||||
? CompressorConfigType.Digital
|
||||
: CompressorConfigType.Disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAnalogVoltage(int channel) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user