diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp index a4c62ff32a..a2885c0a48 100644 --- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp @@ -70,6 +70,14 @@ bool DigitalOutput::Get() const { return val; } +HAL_Handle DigitalOutput::GetPortHandleForRouting() const { return m_handle; } + +AnalogTriggerType DigitalOutput::GetAnalogTriggerTypeForRouting() const { + return (AnalogTriggerType)0; +} + +bool DigitalOutput::IsAnalogTrigger() const { return false; } + int DigitalOutput::GetChannel() const { return m_channel; } void DigitalOutput::Pulse(double length) { diff --git a/wpilibc/src/main/native/include/frc/DigitalOutput.h b/wpilibc/src/main/native/include/frc/DigitalOutput.h index 45727a4d51..1d1d1523f4 100644 --- a/wpilibc/src/main/native/include/frc/DigitalOutput.h +++ b/wpilibc/src/main/native/include/frc/DigitalOutput.h @@ -9,7 +9,7 @@ #include -#include "frc/ErrorBase.h" +#include "frc/DigitalSource.h" #include "frc/smartdashboard/Sendable.h" #include "frc/smartdashboard/SendableHelper.h" @@ -24,7 +24,7 @@ class SendableBuilder; * elsewhere will allocate channels automatically so for those devices it * shouldn't be done here. */ -class DigitalOutput : public ErrorBase, +class DigitalOutput : public DigitalSource, public Sendable, public SendableHelper { public: @@ -59,10 +59,26 @@ class DigitalOutput : public ErrorBase, */ bool Get() const; + // Digital Source Interface + /** + * @return The HAL Handle to the specified source. + */ + HAL_Handle GetPortHandleForRouting() const override; + + /** + * @return The type of analog trigger output to be used. 0 for Digitals + */ + AnalogTriggerType GetAnalogTriggerTypeForRouting() const override; + + /** + * Is source an AnalogTrigger + */ + bool IsAnalogTrigger() const override; + /** * @return The GPIO channel number that this object represents. */ - int GetChannel() const; + int GetChannel() const override; /** * Output a single pulse on the digital output line. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java index d66603ff70..b42a566e75 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java @@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; * Class to write digital outputs. This class will write digital outputs. Other devices that are * implemented elsewhere will automatically allocate digital inputs and outputs as required. */ -public class DigitalOutput implements Sendable, AutoCloseable { +public class DigitalOutput extends DigitalSource implements Sendable, AutoCloseable { private static final int invalidPwmGenerator = 0; private int m_pwmGenerator = invalidPwmGenerator; @@ -76,6 +76,7 @@ public class DigitalOutput implements Sendable, AutoCloseable { * * @return The GPIO channel number. */ + @Override public int getChannel() { return m_channel; } @@ -177,4 +178,34 @@ public class DigitalOutput implements Sendable, AutoCloseable { builder.setSmartDashboardType("Digital Output"); builder.addBooleanProperty("Value", this::get, this::set); } + + /** + * Is this an analog trigger. + * + * @return true if this is an analog trigger + */ + @Override + public boolean isAnalogTrigger() { + return false; + } + + /** + * Get the analog trigger type. + * + * @return false + */ + @Override + public int getAnalogTriggerTypeForRouting() { + return 0; + } + + /** + * Get the HAL Port Handle. + * + * @return The HAL Handle to the specified source. + */ + @Override + public int getPortHandleForRouting() { + return m_handle; + } }