|
package org.carlmontrobotics.lib199; |
|
|
|
import com.revrobotics.CANSparkMax; |
|
import com.revrobotics.RelativeEncoder; |
|
import com.revrobotics.SparkMaxPIDController; |
|
|
|
public class CachedSparkMax extends CANSparkMax { |
|
|
|
private RelativeEncoder encoder; |
|
private SparkMaxPIDController pidController; |
|
|
|
public CachedSparkMax(int deviceId, MotorType type) { |
|
super(deviceId, type); |
|
this.encoder = null; |
|
this.pidController = null; |
|
} |
|
|
|
@Override |
|
public RelativeEncoder getEncoder() { |
|
return encoder == null ? (encoder = super.getEncoder()) : encoder; |
|
} |
|
|
|
@Override |
|
public SparkMaxPIDController getPIDController() { |
|
return pidController == null ? (pidController = super.getPIDController()) : pidController; |
|
} |
|
|
|
} |
I've emailed Rev about the REVLib issue for which this is a workaround. This issue is for discussion of any relevant information, and as a reminder to watch the changelog as a supported solution may be released in the future.
lib199/src/main/java/org/carlmontrobotics/lib199/CachedSparkMax.java
Lines 1 to 28 in 432cd16