#include <SparkFlexExternalEncoder.h>
Inherits rev::RelativeEncoder.
◆ Type
The type of encoder wired as an External Encoder on a SPARK Flex
◆ SparkFlexExternalEncoder() [1/2]
◆ SparkFlexExternalEncoder() [2/2]
◆ ~SparkFlexExternalEncoder()
rev::SparkFlexExternalEncoder::~SparkFlexExternalEncoder |
( |
| ) |
|
|
overridedefault |
◆ operator=()
◆ GetPosition()
double SparkFlexExternalEncoder::GetPosition |
( |
| ) |
const |
|
overridevirtual |
Get the position of the motor. This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor().
- Returns
- Number of rotations of the motor
Implements rev::RelativeEncoder.
◆ GetVelocity()
double SparkFlexExternalEncoder::GetVelocity |
( |
| ) |
const |
|
overridevirtual |
Get the velocity of the motor. This returns the native units of 'RPM' by default, and can be changed by a scale factor using setVelocityConversionFactor().
- Returns
- Number the RPM of the motor
Implements rev::RelativeEncoder.
◆ SetPosition()
REVLibError SparkFlexExternalEncoder::SetPosition |
( |
double |
position | ) |
|
|
overridevirtual |
◆ SetPositionConversionFactor()
REVLibError SparkFlexExternalEncoder::SetPositionConversionFactor |
( |
double |
factor | ) |
|
|
overridevirtual |
Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position
- Parameters
-
factor | The conversion factor to multiply the native units by |
- Returns
- REVLibError::kOk if successful
Implements rev::RelativeEncoder.
◆ SetVelocityConversionFactor()
REVLibError SparkFlexExternalEncoder::SetVelocityConversionFactor |
( |
double |
factor | ) |
|
|
overridevirtual |
Set the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity
- Parameters
-
factor | The conversion factor to multiply the native units by |
- Returns
- REVLibError::kOk if successful
Implements rev::RelativeEncoder.
◆ GetPositionConversionFactor()
double SparkFlexExternalEncoder::GetPositionConversionFactor |
( |
| ) |
const |
|
overridevirtual |
Get the conversion factor for position of the encoder. Multiplied by the native output units to give you position
- Returns
- The conversion factor for position
Implements rev::RelativeEncoder.
◆ GetVelocityConversionFactor()
double SparkFlexExternalEncoder::GetVelocityConversionFactor |
( |
| ) |
const |
|
overridevirtual |
Get the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity
- Returns
- The conversion factor for velocity
Implements rev::RelativeEncoder.
◆ SetAverageDepth()
REVLibError SparkFlexExternalEncoder::SetAverageDepth |
( |
uint32_t |
depth | ) |
|
|
overridevirtual |
Set the average sampling depth for a quadrature encoder. This value sets the number of samples in the average for velocity readings. This can be any value from 1 to 64.
- Parameters
-
depth | The average sampling depth between 1 and 64 (default) |
- Returns
- REVLibError::kOk if successful
Implements rev::RelativeEncoder.
◆ SetMeasurementPeriod()
REVLibError SparkFlexExternalEncoder::SetMeasurementPeriod |
( |
uint32_t |
period_ms | ) |
|
|
overridevirtual |
Set the measurement period for velocity measurements of a quadrature encoder.
The basic formula to calculate velocity is change in position / change in time. This parameter sets the change in time for measurement.
- Parameters
-
period_ms | Measurement period in milliseconds. This number may be between 1 and 100 (default). |
- Returns
- REVLibError::kOk if successful
Implements rev::RelativeEncoder.
◆ GetAverageDepth()
uint32_t SparkFlexExternalEncoder::GetAverageDepth |
( |
| ) |
const |
|
overridevirtual |
Get the average sampling depth for a quadrature encoder.
- Returns
- The average sampling depth
Implements rev::RelativeEncoder.
◆ GetMeasurementPeriod()
uint32_t SparkFlexExternalEncoder::GetMeasurementPeriod |
( |
| ) |
const |
|
overridevirtual |
Get the number of samples for reading from a quadrature encoder. This value sets the number of samples in the average for velocity readings.
- Returns
- Measurement period in microseconds
Implements rev::RelativeEncoder.
◆ GetCountsPerRevolution()
uint32_t SparkFlexExternalEncoder::GetCountsPerRevolution |
( |
| ) |
const |
|
overridevirtual |
◆ SetInverted()
REVLibError SparkFlexExternalEncoder::SetInverted |
( |
bool |
inverted | ) |
|
|
overridevirtual |
◆ GetInverted()
bool SparkFlexExternalEncoder::GetInverted |
( |
| ) |
const |
|
overridevirtual |
Get the phase of the MotorFeedbackSensor. This will just return false if the user tries to get inverted while the SparkMax is Brushless and using the hall effect sensor.
- Returns
- The phase of the encoder
Implements rev::RelativeEncoder.
◆ CANSparkFlex
The documentation for this class was generated from the following files: