mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Make DigitalOutput a DigitalSource (#2054)
It's perfectly safe to use as a DigitalSource, and can enable some cool tricks.
This commit is contained in:
committed by
Peter Johnson
parent
5ccad2e8a4
commit
ff39a96cee
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user