diff --git a/wpilibc/wpilibC++Devices/include/CANTalon.h b/wpilibc/wpilibC++Devices/include/CANTalon.h index 85552f8e83..c720ea0cc7 100644 --- a/wpilibc/wpilibC++Devices/include/CANTalon.h +++ b/wpilibc/wpilibC++Devices/include/CANTalon.h @@ -100,6 +100,28 @@ public: virtual void ConfigLimitMode(LimitMode mode) override; virtual void ConfigForwardLimit(double forwardLimitPosition) override; virtual void ConfigReverseLimit(double reverseLimitPosition) override; + /** + * Change the fwd limit switch setting to normally open or closed. + * Talon will disable momentarilly if the Talon's current setting + * is dissimilar to the caller's requested setting. + * + * Since Talon saves setting to flash this should only affect + * a given Talon initially during robot install. + * + * @param normallyOpen true for normally open. false for normally closed. + */ + void ConfigFwdLimitSwitchNormallyOpen(bool normallyOpen); + /** + * Change the rev limit switch setting to normally open or closed. + * Talon will disable momentarilly if the Talon's current setting + * is dissimilar to the caller's requested setting. + * + * Since Talon saves setting to flash this should only affect + * a given Talon initially during robot install. + * + * @param normallyOpen true for normally open. false for normally closed. + */ + void ConfigRevLimitSwitchNormallyOpen(bool normallyOpen); virtual void ConfigMaxOutputVoltage(double voltage) override; virtual void ConfigFaultTime(float faultTime) override; virtual void SetControlMode(ControlMode mode); diff --git a/wpilibc/wpilibC++Devices/src/CANTalon.cpp b/wpilibc/wpilibC++Devices/src/CANTalon.cpp index 907587eba4..8ff1123e0d 100644 --- a/wpilibc/wpilibC++Devices/src/CANTalon.cpp +++ b/wpilibc/wpilibC++Devices/src/CANTalon.cpp @@ -1068,7 +1068,40 @@ void CANTalon::ConfigForwardLimit(double forwardLimitPosition) wpi_setErrorWithContext(status, getHALErrorMessage(status)); } } - +/** + * Change the fwd limit switch setting to normally open or closed. + * Talon will disable momentarilly if the Talon's current setting + * is dissimilar to the caller's requested setting. + * + * Since Talon saves setting to flash this should only affect + * a given Talon initially during robot install. + * + * @param normallyOpen true for normally open. false for normally closed. + */ +void CANTalon::ConfigFwdLimitSwitchNormallyOpen(bool normallyOpen) +{ + CTR_Code status = m_impl->SetParam(CanTalonSRX::eOnBoot_LimitSwitch_Forward_NormallyClosed, normallyOpen ? 0 : 1); + if(status != CTR_OKAY) { + wpi_setErrorWithContext(status, getHALErrorMessage(status)); + } +} +/** + * Change the rev limit switch setting to normally open or closed. + * Talon will disable momentarilly if the Talon's current setting + * is dissimilar to the caller's requested setting. + * + * Since Talon saves setting to flash this should only affect + * a given Talon initially during robot install. + * + * @param normallyOpen true for normally open. false for normally closed. + */ +void CANTalon::ConfigRevLimitSwitchNormallyOpen(bool normallyOpen) +{ + CTR_Code status = m_impl->SetParam(CanTalonSRX::eOnBoot_LimitSwitch_Reverse_NormallyClosed, normallyOpen ? 0 : 1); + if(status != CTR_OKAY) { + wpi_setErrorWithContext(status, getHALErrorMessage(status)); + } +} /** * TODO documentation (see CANJaguar.cpp) */ diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANTalon.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANTalon.java index 5b74a8d85f..055350acc0 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANTalon.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANTalon.java @@ -810,6 +810,34 @@ public class CANTalon implements MotorSafety, PIDOutput, SpeedController { int mask = 4 + (forward ? 1 : 0) * 2 + (reverse ? 1 : 0); m_impl.SetOverrideLimitSwitchEn(mask); } + /** + * Configure the fwd limit switch to be normally open or normally closed. + * Talon will disable momentarilly if the Talon's current setting + * is dissimilar to the caller's requested setting. + * + * Since Talon saves setting to flash this should only affect + * a given Talon initially during robot install. + * + * @param normallyOpen true for normally open. false for normally closed. + */ + public void ConfigFwdLimitSwitchNormallyOpen(boolean normallyOpen) + { + SWIGTYPE_p_CTR_Code status = m_impl.SetParam(CanTalonSRX.param_t.eOnBoot_LimitSwitch_Forward_NormallyClosed,normallyOpen ? 0 : 1); + } + /** + * Configure the rev limit switch to be normally open or normally closed. + * Talon will disable momentarilly if the Talon's current setting + * is dissimilar to the caller's requested setting. + * + * Since Talon saves setting to flash this should only affect + * a given Talon initially during robot install. + * + * @param normallyOpen true for normally open. false for normally closed. + */ + public void ConfigRevLimitSwitchNormallyOpen(boolean normallyOpen) + { + SWIGTYPE_p_CTR_Code status = m_impl.SetParam(CanTalonSRX.param_t.eOnBoot_LimitSwitch_Reverse_NormallyClosed,normallyOpen ? 0 : 1); + } public void enableBrakeMode(boolean brake) { m_impl.SetOverrideBrakeType(brake ? 2 : 1);