#include <SparkMaxAnalogSensor.h>
Inherits rev::AnalogInput, and rev::CANAnalog.
Inherited by rev::SparkAnalogSensor.
◆ Mode
◆ SparkMaxAnalogSensor() [1/2]
◆ SparkMaxAnalogSensor() [2/2]
◆ ~SparkMaxAnalogSensor()
rev::SparkMaxAnalogSensor::~SparkMaxAnalogSensor |
( |
| ) |
|
|
overridedefault |
◆ operator=()
◆ GetVoltage()
double SparkMaxAnalogSensor::GetVoltage |
( |
| ) |
const |
|
overridevirtual |
Get the voltage of the analog sensor.
- Returns
- Voltage of the sensor
Implements rev::AnalogInput.
◆ GetPosition()
double SparkMaxAnalogSensor::GetPosition |
( |
| ) |
const |
|
overridevirtual |
Get the position of the sensor. Returns value in the native unit of 'volt' by default, and can be changed by a scale factor using setPositionConversionFactor().
- Returns
- Position of the sensor in volts
Implements rev::AnalogInput.
◆ GetVelocity()
double SparkMaxAnalogSensor::GetVelocity |
( |
| ) |
const |
|
overridevirtual |
Get the velocity of the sensor. Returns value in the native units of 'volts per second' by default, and can be changed by a scale factor using setVelocityConversionFactor().
- Returns
- Velocity of the sensor in volts per second
Implements rev::CANAnalog.
◆ SetPositionConversionFactor()
REVLibError SparkMaxAnalogSensor::SetPositionConversionFactor |
( |
double |
factor | ) |
|
|
overridevirtual |
Set the conversion factor for the position of the analog sensor. By default, revolutions per volt is 1. Changing the position conversion factor will also change the position units.
- Parameters
-
factor | The conversion factor which will be multiplied by volts |
- Returns
- REVLibError::kOk if successful
Implements rev::AnalogInput.
◆ GetPositionConversionFactor()
double SparkMaxAnalogSensor::GetPositionConversionFactor |
( |
| ) |
const |
|
overridevirtual |
Get the current conversion factor for the position of the analog sensor.
- Returns
- Analog position conversion factor
Implements rev::AnalogInput.
◆ SetVelocityConversionFactor()
REVLibError SparkMaxAnalogSensor::SetVelocityConversionFactor |
( |
double |
factor | ) |
|
|
overridevirtual |
Set the conversion factor for the velocity of the analog sensor. By default, revolutions per volt second is 1. Changing the velocity conversion factor will also change the velocity units.
- Parameters
-
factor | The conversion factor which will be multipled by volts per second |
- Returns
- REVLibError::kOk is successful
Implements rev::CANAnalog.
◆ GetVelocityConversionFactor()
double SparkMaxAnalogSensor::GetVelocityConversionFactor |
( |
| ) |
const |
|
overridevirtual |
Get the current conversion factor for the velocity of the analog sensor.
- Returns
- Analog velocity conversion factor
Implements rev::CANAnalog.
◆ SetAverageDepth()
REVLibError SparkMaxAnalogSensor::SetAverageDepth |
( |
uint32_t |
depth | ) |
|
|
overridevirtual |
Set the number of samples in the average for velocity readings. This can be any value from 1 to 64.
When the SparkMax controller is in Brushless mode, this will not change any behavior.
- Parameters
-
depth | The average sampling depth between 1 and 64 (default) |
- Returns
- REVLibError::kOk if successful
Implements rev::CANAnalog.
◆ SetMeasurementPeriod()
REVLibError SparkMaxAnalogSensor::SetMeasurementPeriod |
( |
uint32_t |
period_ms | ) |
|
|
overridevirtual |
Set the measurement period for velocity readings.
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::CANAnalog.
◆ GetAverageDepth()
uint32_t SparkMaxAnalogSensor::GetAverageDepth |
( |
| ) |
const |
|
overridevirtual |
Get the number of samples included in the average for velocity readings.
- Returns
- The average sampling depth
Implements rev::CANAnalog.
◆ GetMeasurementPeriod()
uint32_t SparkMaxAnalogSensor::GetMeasurementPeriod |
( |
| ) |
const |
|
overridevirtual |
Get the measurement period used for velocity readings.
- Returns
- Measurement period in microseconds
Implements rev::CANAnalog.
◆ SetInverted()
REVLibError SparkMaxAnalogSensor::SetInverted |
( |
bool |
inverted | ) |
|
|
overridevirtual |
Set the phase of the MotorFeedbackSensor so that it is set to be in phase with the motor itself. This only works for quadrature encoders. This will throw an error if the user tries to set inverted while the SparkMax is Brushless and using the hall effect sensor.
- Parameters
-
inverted | The phase of the encoder |
- Returns
- REVLibError::kOk if successful
Implements rev::CANAnalog.
◆ GetInverted()
bool SparkMaxAnalogSensor::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::CANAnalog.
◆ CANSparkBase
◆ SparkAnalogSensor
The documentation for this class was generated from the following files: