|
| 1 | +package com.revrobotics.spark; |
| 2 | + |
| 3 | +import com.revrobotics.REVLibError; |
| 4 | +import com.revrobotics.jni.CANSparkJNI; |
| 5 | + |
| 6 | +public class SparkBaseExtensions { |
| 7 | + |
| 8 | + /** |
| 9 | + * Checked function for setting controller inverted. |
| 10 | + * |
| 11 | + * <p> |
| 12 | + * This call has no effect if the controller is a follower. |
| 13 | + * |
| 14 | + * @param isInverted true = inverted |
| 15 | + */ |
| 16 | + public static REVLibError setInverted(SparkBase sparkBase, boolean isInverted) { |
| 17 | + return REVLibError.fromInt( |
| 18 | + CANSparkJNI.c_Spark_SetInverted(sparkBase.sparkHandle, isInverted)); |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * Enable or disable center aligned mode for the duty cycle sensor. |
| 23 | + * |
| 24 | + * @param enable true = center aligned enabled |
| 25 | + */ |
| 26 | + public static REVLibError setCenterAlignedMode(SparkBase sparkBase, boolean enable) { |
| 27 | + return REVLibError.fromInt( |
| 28 | + CANSparkJNI.c_Spark_SetParameterBool(sparkBase.sparkHandle, 152, enable)); |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Enable or disable PID voltage output mode. |
| 33 | + * |
| 34 | + * <p> |
| 35 | + * When enabled, PID output is voltage instead of duty cycle. |
| 36 | + * |
| 37 | + * @param enable true = PID voltage output |
| 38 | + */ |
| 39 | + public static REVLibError setPIDVoltageOutput(SparkBase sparkBase, boolean enable) { |
| 40 | + return REVLibError.fromInt( |
| 41 | + CANSparkJNI.c_Spark_SetParameterUint32( |
| 42 | + sparkBase.sparkHandle, 74, enable ? 1 : 0)); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Enable or disable brake mode. |
| 47 | + * |
| 48 | + * <p> |
| 49 | + * true = Brake mode |
| 50 | + * false = Coast mode |
| 51 | + * |
| 52 | + * @param brake true = brake, false = coast |
| 53 | + */ |
| 54 | + public static REVLibError setBrakeMode(SparkBase sparkBase, boolean brake) { |
| 55 | + // 1 = Brake, 0 = Coast |
| 56 | + return REVLibError.fromInt( |
| 57 | + CANSparkJNI.c_Spark_SetParameterUint32( |
| 58 | + sparkBase.sparkHandle, |
| 59 | + 6, |
| 60 | + brake ? 1 : 0)); |
| 61 | + } |
| 62 | +} |
0 commit comments