16namespace ctre {
namespace phoenix {
64 std::string
toString(std::string prependString) {
68 retstr += prependString +
".clearPositionOnLimitF = " + std::to_string(
clearPositionOnLimitF) +
";\n";
69 retstr += prependString +
".clearPositionOnLimitR = " + std::to_string(
clearPositionOnLimitR) +
";\n";
333 [[deprecated(
"Use the overload with SensorVelocityMeasPeriod instead")]]
469 uint8_t subValue,
int ordinal,
int timeoutMs = 0);
506 int32_t & valueReceived, uint8_t & subValue, int32_t ordinal,
521 uint8_t periodMs,
int timeoutMs = 0);
Simple address holder.
Definition CANBusAddressable.h:9
CTRE CANifier.
Definition CANifier.h:108
ErrorCode ConfigVelocityMeasurementPeriod(CANifierVelocityMeasPeriod period, int timeoutMs=0)
ErrorCode ConfigFactoryDefault(int timeoutMs=50)
Configures all persistent settings to defaults (overloaded so timeoutMs is 50 ms).
GeneralPin
General IO Pins on the CANifier.
Definition CANifier.h:158
@ SPI_MOSI_PWM1P
SPI_MOSI_PWM1 pin.
Definition CANifier.h:198
@ LIMR
Reverse limit pin.
Definition CANifier.h:174
@ QUAD_A
Quadrature A pin.
Definition CANifier.h:170
@ LIMF
Forward limit pin.
Definition CANifier.h:178
@ SPI_CLK_PWM0P
SPI_CLK_PWM0 pin.
Definition CANifier.h:202
@ SPI_MISO_PWM2P
SPI_MISO_PWM2 pin.
Definition CANifier.h:194
@ SCL
SCL pin.
Definition CANifier.h:186
@ SDA
SDA pin.
Definition CANifier.h:182
@ SPI_CS
SPI_CS pin.
Definition CANifier.h:190
@ QUAD_B
Quadrature B pin.
Definition CANifier.h:166
@ QUAD_IDX
Quadrature Idx pin.
Definition CANifier.h:162
bool GetGeneralInput(GeneralPin inputPin)
Gets the state of the specified pin.
bool HasResetOccurred()
Returns true if the device has reset since last call.
ErrorCode ConfigVelocityMeasurementWindow(int windowSize, int timeoutMs=0)
Sets the number of velocity samples used in the rolling average velocity measurement.
int GetStatusFramePeriod(CANifierStatusFrame frame, int timeoutMs=0)
Gets the period of the given status frame.
ErrorCode GetFaults(CANifierFaults &toFill)
Gets the CANifier fault status.
PWMChannel
Enum for the PWM Input Channels.
Definition CANifier.h:131
@ PWMChannel0
PWM Channel 0.
Definition CANifier.h:135
@ PWMChannel3
PWM Channel 3.
Definition CANifier.h:147
@ PWMChannel1
PWM Channel 1.
Definition CANifier.h:139
@ PWMChannel2
PWM Channel 2.
Definition CANifier.h:143
ctre::phoenix::ErrorCode ConfigAllSettings(const CANifierConfiguration &allConfigs, int timeoutMs=50)
Configures all persistent settings.
ErrorCode ClearStickyFaults(int timeoutMs=0)
Clears the Sticky Faults.
ErrorCode ConfigClearPositionOnQuadIdx(bool clearPositionOnQuadIdx, int timeoutMs=0)
Enables clearing the position of the feedback sensor when the quadrature index signal is detected.
ErrorCode ConfigSetParameter(ParamEnum param, double value, uint8_t subValue, int ordinal, int timeoutMs=0)
Sets a parameter.
ErrorCode ConfigSetCustomParam(int newValue, int paramIndex, int timeoutMs=0)
Sets the value of a custom parameter.
CANifier(int deviceNumber)
Constructor.
ErrorCode ConfigClearPositionOnLimitR(bool clearPositionOnLimitR, int timeoutMs=0)
Enables clearing the position of the feedback sensor when the reverse limit switch is triggered.
ErrorCode SetStatusFramePeriod(CANifierStatusFrame statusFrame, uint8_t periodMs, int timeoutMs=0)
Sets the period of the given status frame.
double ConfigGetParameter(ParamEnum param, int ordinal, int timeoutMs=0)
Gets a parameter.
LEDChannel
Enum for the LED Output Channels.
Definition CANifier.h:113
@ LEDChannelC
LED Channel C.
Definition CANifier.h:125
@ LEDChannelA
LED Channel A.
Definition CANifier.h:117
@ LEDChannelB
LED Channel B.
Definition CANifier.h:121
ErrorCode GetGeneralInputs(PinValues &allPins)
Gets the state of all General Pins.
ErrorCode SetLEDOutput(double percentOutput, LEDChannel ledChannel)
Sets the LED Output.
const int PWMChannelCount
Number of PWM channels available to CANifier.
Definition CANifier.h:153
ErrorCode SetPWMOutput(int pwmChannel, double dutyCycle)
Sets the PWM Output Currently supports PWM 0, PWM 1, and PWM 2.
ErrorCode SetGeneralOutput(GeneralPin outputPin, bool outputValue, bool outputEnable)
Sets the output of a General Pin.
static void DestroyAllCANifiers()
Destructs all CANifier objects.
ErrorCode ConfigClearPositionOnLimitF(bool clearPositionOnLimitF, int timeoutMs=0)
Enables clearing the position of the feedback sensor when the forward limit switch is triggered.
ErrorCode SetQuadraturePosition(int newPosition, int timeoutMs=0)
Sets the quadrature encoder's position.
int ConfigGetCustomParam(int paramIndex, int timeoutMs=0)
Gets the value of a custom parameter.
ErrorCode GetLastError()
Call GetLastError() generated by this object.
ErrorCode SetGeneralOutputs(int outputBits, int isOutputBits)
Sets the output of all General Pins.
double GetBusVoltage()
Gets the bus voltage seen by the device.
int GetQuadraturePosition()
Gets the quadrature encoder's position.
ErrorCode ConfigGetParameter(ParamEnum param, int32_t valueToSend, int32_t &valueReceived, uint8_t &subValue, int32_t ordinal, int32_t timeoutMs)
Gets a parameter by passing an int by reference.
ErrorCode ConfigVelocityMeasurementPeriod(ctre::phoenix::sensors::SensorVelocityMeasPeriod period, int timeoutMs=0)
Configures the period of each velocity sample.
ErrorCode GetStickyFaults(CANifierStickyFaults &toFill)
Gets the CANifier sticky fault status.
ErrorCode GetPWMInput(PWMChannel pwmChannel, double pulseWidthAndPeriod[])
Gets the PWM Input.
void GetAllConfigs(CANifierConfiguration &allConfigs, int timeoutMs=50)
Gets all persistant settings.
ErrorCode SetControlFramePeriod(CANifierControlFrame frame, int periodMs)
Sets the period of the given control frame.
int GetQuadratureVelocity()
Gets the quadrature encoder's velocity.
ErrorCode EnablePWMOutput(int pwmChannel, bool bEnable)
Enables PWM Outputs Currently supports PWM 0, PWM 1, and PWM 2.
int GetFirmwareVersion()
Gets the firmware version of the device.
static std::string toString(SensorVelocityMeasPeriod value)
String representation of specified CANCoderVelocityMeasPeriod.
Definition SensorVelocityMeasPeriod.h:58
SensorVelocityMeasPeriod
Enumerate filter periods for any sensor that measures velocity.
Definition SensorVelocityMeasPeriod.h:13
CANifierStatusFrame
Enumerated type for status frame types.
Definition CANifierStatusFrame.h:8
ParamEnum
Signal enumeration for generic signal access.
Definition paramEnum.h:13
ErrorCode
Definition ErrorCode.h:13
CANifierVelocityMeasPeriod
Enum for velocity periods used for CANifier.
Definition CANifierVelocityMeasPeriod.h:12
@ Period_100Ms
100ms velocity measurement period
Definition CANifierVelocityMeasPeriod.h:44
CANifierControlFrame
Enumerated type for status frame types.
Definition CANifierControlFrame.h:8
WPI Compliant CANcoder class.
Definition CANCoderStatusFrame.h:4
Structure to hold the pin values.
Definition CANifier.h:208
bool SPI_MOSI_PWM1
SPI_MOSI_PWM1 pin.
Definition CANifier.h:248
bool LIMR
Reverse limit pin.
Definition CANifier.h:224
bool SPI_CS_PWM3
SPI_CS_PWM3 pin.
Definition CANifier.h:240
bool QUAD_IDX
Quadrature Idx pin.
Definition CANifier.h:212
bool SPI_MISO_PWM2
SPI_MISO_PWM2 pin.
Definition CANifier.h:244
bool QUAD_B
Quadrature B pin.
Definition CANifier.h:216
bool SCL
SCL pin.
Definition CANifier.h:236
bool SPI_CLK_PWM0
SPI_CLK_PWM0 pin.
Definition CANifier.h:252
bool QUAD_A
Quadrature A pin.
Definition CANifier.h:220
bool LIMF
Forward limit pin.
Definition CANifier.h:228
bool SDA
SDA pin.
Definition CANifier.h:232
Util class to help with configuring CANifier.
Definition CANifier.h:82
static bool ClearPositionOnLimitFDifferent(const CANifierConfiguration &settings)
Definition CANifier.h:94
static bool ClearPositionOnLimitRDifferent(const CANifierConfiguration &settings)
Definition CANifier.h:95
static bool VelocityMeasurementWindowDifferent(const CANifierConfiguration &settings)
Definition CANifier.h:93
static bool VelocityMeasurementPeriodDifferent(const CANifierConfiguration &settings)
Determine if specified value is different from default.
Definition CANifier.h:92
static bool CustomParam0Different(const CANifierConfiguration &settings)
Definition CANifier.h:97
static bool ClearPositionOnQuadIdxDifferent(const CANifierConfiguration &settings)
Definition CANifier.h:96
static bool CustomParam1Different(const CANifierConfiguration &settings)
Definition CANifier.h:98
Configurables available to CANifier.
Definition CANifier.h:21
bool clearPositionOnLimitF
Whether to clear sensor position on forward limit.
Definition CANifier.h:33
bool clearPositionOnLimitR
Whether to clear sensor position on reverse limit.
Definition CANifier.h:37
bool clearPositionOnQuadIdx
Whether to clear sensor position on index.
Definition CANifier.h:41
ctre::phoenix::sensors::SensorVelocityMeasPeriod velocityMeasurementPeriod
Velocity measurement period to use.
Definition CANifier.h:25
int velocityMeasurementWindow
Velocity measurement window to use.
Definition CANifier.h:29
CANifierConfiguration()
Definition CANifier.h:43
std::string toString()
Definition CANifier.h:55
std::string toString(std::string prependString)
Definition CANifier.h:64
Faults available to CANifier (Currently has none)
Definition CANifierFaults.h:10
Sticky Faults for CANifier (Currently has none)
Definition CANifierStickyFaults.h:10
Configurables for any custom param configs.
Definition CustomParamConfiguration.h:11
int customParam1
Custom Param 1.
Definition CustomParamConfiguration.h:19
bool enableOptimizations
Enable optimizations for ConfigAll (defaults true)
Definition CustomParamConfiguration.h:23
int customParam0
Custom Param 0.
Definition CustomParamConfiguration.h:15
std::string toString()
Definition CustomParamConfiguration.h:34