[hal, wpilib] Incorporate pneumatic control type into wpilibc/j (#3728)

This commit is contained in:
Thad House
2021-11-23 20:32:02 -08:00
committed by GitHub
parent 9aba2b7583
commit b156db400d
35 changed files with 693 additions and 216 deletions

View File

@@ -19,7 +19,7 @@ Compressor::Compressor(int module, PneumaticsModuleType moduleType)
throw FRC_MakeError(err::ResourceAlreadyAllocated, "{}", module);
}
SetClosedLoopControl(true);
m_module->EnableCompressorDigital();
HAL_Report(HALUsageReporting::kResourceType_Compressor, module + 1);
wpi::SendableRegistry::AddLW(this, "Compressor", module);
@@ -33,11 +33,11 @@ Compressor::~Compressor() {
}
void Compressor::Start() {
SetClosedLoopControl(true);
EnableDigital();
}
void Compressor::Stop() {
SetClosedLoopControl(false);
Disable();
}
bool Compressor::Enabled() const {
@@ -48,23 +48,34 @@ bool Compressor::GetPressureSwitchValue() const {
return m_module->GetPressureSwitch();
}
double Compressor::GetCompressorCurrent() const {
double Compressor::GetCurrent() const {
return m_module->GetCompressorCurrent();
}
void Compressor::SetClosedLoopControl(bool on) {
m_module->SetClosedLoopControl(on);
void Compressor::Disable() {
m_module->DisableCompressor();
}
bool Compressor::GetClosedLoopControl() const {
return m_module->GetClosedLoopControl();
void Compressor::EnableDigital() {
m_module->EnableCompressorDigital();
}
void Compressor::EnableAnalog(double minAnalogVoltage,
double maxAnalogVoltage) {
m_module->EnableCompressorAnalog(minAnalogVoltage, maxAnalogVoltage);
}
void Compressor::EnableHybrid(double minAnalogVoltage,
double maxAnalogVoltage) {
m_module->EnableCompressorHybrid(minAnalogVoltage, maxAnalogVoltage);
}
CompressorConfigType Compressor::GetConfigType() const {
return m_module->GetCompressorConfigType();
}
void Compressor::InitSendable(wpi::SendableBuilder& builder) {
builder.SetSmartDashboardType("Compressor");
builder.AddBooleanProperty(
"Closed Loop Control", [=]() { return GetClosedLoopControl(); },
[=](bool value) { SetClosedLoopControl(value); });
builder.AddBooleanProperty(
"Enabled", [=] { return Enabled(); }, nullptr);
builder.AddBooleanProperty(