/**
* Configure a Talon with stored parameters.
*
* @param talon the Talon to registerWith
*/
public void configure(@NotNull CANTalon talon) {
talon.setSafetyEnabled(false);
talon.setProfile(0);
talon.setExpiration(MotorSafety.DEFAULT_SAFETY_EXPIRATION);
Encoder enc = encoder != null ? encoder : Encoder.DEFAULT;
enc.configure(talon);
talon.enableBrakeMode(brakeInNeutral != null ? brakeInNeutral : true);
talon.reverSEOutput(outputReversed != null ? outputReversed : false);
if (veLocityMeasurementPeriod != null) {
talon.SetVeLocityMeasurementPeriod(veLocityMeasurementPeriod);
} else {
talon.SetVeLocityMeasurementPeriod(VeLocityMeasurementPeriod.Period_100Ms);
}
if (veLocityMeasurementwindow != null) {
talon.SetVeLocityMeasurementwindow(veLocityMeasurementwindow);
} else {
talon.SetVeLocityMeasurementwindow(64);
}
LimitSwitch fls = forwardLimitSwitch != null ? forwardLimitSwitch : LimitSwitch.DEFAULT;
LimitSwitch rls = reverseLimitSwitch != null ? reverseLimitSwitch : LimitSwitch.DEFAULT;
talon.enableLimitSwitch(fls.isEnabled(),rls.isEnabled());
if (fls.isEnabled()) {
talon.ConfigFwdLimitSwitchnormallyOpen(fls.isnormallyopen());
}
if (rls.isEnabled()) {
talon.ConfigRevLimitSwitchnormallyOpen(rls.isnormallyopen());
}
SoftLimit sl = forwardSoftLimit != null ? forwardSoftLimit : SoftLimit.DEFAULT;
talon.enableForwardSoftLimit(sl.isEnabled());
if (sl.isEnabled()) {
talon.setForwardSoftLimit(sl.getPosition());
}
sl = reverseSoftLimit != null ? reverseSoftLimit : SoftLimit.DEFAULT;
talon.enableReverseSoftLimit(sl.isEnabled());
if (sl.isEnabled()) {
talon.setReverseSoftLimit(sl.getPosition());
}
if (currentLimit != null && currentLimit > 0) {
talon.setCurrentLimit(currentLimit);
talon.EnableCurrentLimit(true);
} else {
talon.EnableCurrentLimit(false);
}
talon.setVoltageRampRate(voltageRampRate != null ? voltageRampRate : 0);
addTalonId(talon.getdeviceid());
}