CTRE_Phoenix 5.20.2
com.ctre.phoenix.led.CANdle Class Reference

Classes

enum  LEDStripType
 
enum  VBatOutputMode
 

Public Member Functions

 CANdle (int deviceId, String canbus)
 
 CANdle (int deviceId)
 
ErrorCode destroyObject ()
 
double getBusVoltage ()
 
double get5VRailVoltage ()
 
double getCurrent ()
 
double getTemperature ()
 
double getVBatModulation ()
 
ErrorCode animate (Animation animation)
 
ErrorCode setLEDs (int r, int g, int b, int w, int startIdx, int count)
 
ErrorCode setLEDs (int r, int g, int b)
 
ErrorCode modulateVBatOutput (double dutyCyclePrcnt)
 
ErrorCode configLOSBehavior (boolean disableWhenLOS, int timeoutMs)
 
ErrorCode configLOSBehavior (boolean disableWhenLOS)
 
ErrorCode configLEDType (LEDStripType type, int timeoutMs)
 
ErrorCode configLEDType (LEDStripType type)
 
ErrorCode configBrightnessScalar (double brightness, int timeoutMs)
 
ErrorCode configBrightnessScalar (double brightness)
 
ErrorCode configStatusLedState (boolean disableWhenRunning, int timeoutMs)
 
ErrorCode configStatusLedState (boolean disableWhenRunning)
 
ErrorCode configVBatOutput (VBatOutputMode mode, int timeoutMs)
 
ErrorCode configVBatOutput (VBatOutputMode mode)
 
double configGetParameter (ParamEnum param, int ordinal, int timeoutMs)
 
double configGetParameter (ParamEnum param, int ordinal)
 
ErrorCode configSetParameter (ParamEnum param, double value, int subValue, int ordinal, int timeoutMs)
 
ErrorCode configSetParameter (ParamEnum param, double value, int subValue, int ordinal)
 
int configGetCustomParam (int paramIndex, int timeoutMs)
 
int configGetCustomParam (int paramIndex)
 
ErrorCode configSetCustomParam (int paramIndex, int value, int timeoutMs)
 
ErrorCode configSetCustomParam (int paramIndex, int value)
 
ErrorCode configFactoryDefault (int timeoutMs)
 
ErrorCode configFactoryDefault ()
 
ErrorCode getFaults (CANdleFaults toFill)
 
ErrorCode getStickyFaults (CANdleStickyFaults toFill)
 
ErrorCode clearStickyFaults (int timeoutMs)
 
ErrorCode clearStickyFaults ()
 
boolean hasResetOccurred ()
 
ErrorCode setStatusFramePeriod (CANdleStatusFrame frame, int periodMs, int timeoutMs)
 
ErrorCode setStatusFramePeriod (CANdleStatusFrame frame, int periodMs)
 
int getStatusFramePeriod (CANdleStatusFrame frame, int timeoutMs)
 
int getStatusFramePeriod (CANdleStatusFrame frame)
 
ErrorCode setControlFramePeriod (CANdleControlFrame frame, int periodMs)
 
ErrorCode configAllSettings (CANdleConfiguration allConfigs, int timeoutMs)
 
ErrorCode configAllSettings (CANdleConfiguration allConfigs)
 
void getAllConfigs (CANdleConfiguration allConfigs, int timeoutMs)
 
void getAllConfigs (CANdleConfiguration allConfigs)
 
ErrorCode getLastError ()
 

Detailed Description

CTRE CANdle

Device for controlling LEDs from the CAN bus.


// Example usage of a CANdle
CANdle candle = new CANdle(0); // creates a new CANdle with ID 0

CANdleConfiguration config = new CANdleConfiguration();
config.stripType = LEDStripType.RGB; // set the strip type to RGB
config.brightnessScalar = 0.5; // dim the LEDs to half brightness
candle.configAllSettings(config);

candle.setLEDs(255, 255, 255); // set the CANdle LEDs to white

// create a rainbow animation:
// - max brightness
// - half speed
// - 64 LEDs
RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 64);
candle.animate(rainbowAnim);

ErrorCode error = candle.getLastError(); // gets the last error generated by the CANdle
CANdleFaults faults = new CANdleFaults();
ErrorCode faultsError = candle.getFaults(faults); // fills faults with the current CANdle faults; returns the last error generated

Constructor & Destructor Documentation

◆ CANdle() [1/2]

com.ctre.phoenix.led.CANdle.CANdle ( int  deviceId,
String  canbus 
)
inline

Constructor for a CANdle Device

Parameters
deviceIdThe Device ID of the CANdle
canbusName of the CANbus; can be a SocketCAN interface (on Linux), or a CANivore device name or serial number

◆ CANdle() [2/2]

com.ctre.phoenix.led.CANdle.CANdle ( int  deviceId)
inline

Constructor for a CANdle Device

Parameters
deviceIdThe Device ID of the CANdle

Member Function Documentation

◆ animate()

ErrorCode com.ctre.phoenix.led.CANdle.animate ( Animation  animation)
inline

Animates the CANdle with the passed-in animation If the animation changes after calling this function, it must be passed into animate again for the changes to take effect

Parameters
animationThe animation that CANdle will run
Returns
ErrorCode generated by function. OK indicates no error.

◆ clearStickyFaults() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.clearStickyFaults ( )
inline

Clears the sticky faults.

Returns
Error Code generated by function. 0 indicates no error.

◆ clearStickyFaults() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.clearStickyFaults ( int  timeoutMs)
inline

Clears the sticky faults.

Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configAllSettings() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configAllSettings ( CANdleConfiguration  allConfigs)
inline

Configures all persistent settings.

Parameters
allConfigsObject with all of the persistant settings
Returns
Error Code generated by function. 0 indicates no error.

◆ configAllSettings() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configAllSettings ( CANdleConfiguration  allConfigs,
int  timeoutMs 
)
inline

Configures all persistent settings.

Parameters
allConfigsObject with all of the persistant settings
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configBrightnessScalar() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configBrightnessScalar ( double  brightness)
inline

Configures the brightness scalar to be applied to every LED output. This value is bounded to [0, 1].

Setting this to 1 will allow the LEDs to function at max brightness. Setting this to 0.5 will scale all values to half their applied value. Setting this to 0 will turn off the LEDs.

Forcing the LEDs off this way may be useful in certain testing circumstances but is generally not necessary. Self-test (Tuner) may be used to verify what the effective scalar is in case user forgot to restore the scalar to a non-zero value.

Parameters
brightnessValue from [0, 1] that will scale the LED output.
Returns
Error Code generated by function. 0 indicates no error.

◆ configBrightnessScalar() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configBrightnessScalar ( double  brightness,
int  timeoutMs 
)
inline

Configures the brightness scalar to be applied to every LED output. This value is bounded to [0, 1].

Setting this to 1 will allow the LEDs to function at max brightness. Setting this to 0.5 will scale all values to half their applied value. Setting this to 0 will turn off the LEDs.

Forcing the LEDs off this way may be useful in certain testing circumstances but is generally not necessary. Self-test (Tuner) may be used to verify what the effective scalar is in case user forgot to restore the scalar to a non-zero value.

Parameters
brightnessValue from [0, 1] that will scale the LED output.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configFactoryDefault() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configFactoryDefault ( )
inline

Configures all persistent settings to defaults.

Returns
Error Code generated by function. 0 indicates no error.

◆ configFactoryDefault() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configFactoryDefault ( int  timeoutMs)
inline

Configures all persistent settings to defaults.

Parameters
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configGetCustomParam() [1/2]

int com.ctre.phoenix.led.CANdle.configGetCustomParam ( int  paramIndex)
inline

Gets the value of a custom parameter. This is for arbitrary use.

Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.

Parameters
paramIndexIndex of custom parameter. [0-1]
Returns
Value of the custom param.

◆ configGetCustomParam() [2/2]

int com.ctre.phoenix.led.CANdle.configGetCustomParam ( int  paramIndex,
int  timeoutMs 
)
inline

Gets the value of a custom parameter. This is for arbitrary use.

Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.

Parameters
paramIndexIndex of custom parameter. [0-1]
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Value of the custom param.

◆ configGetParameter() [1/2]

double com.ctre.phoenix.led.CANdle.configGetParameter ( ParamEnum  param,
int  ordinal 
)
inline

Gets a parameter. Generally this is not used. This can be utilized in

  • Using new features without updating API installation.
  • Errata workarounds to circumvent API implementation.
  • Allows for rapid testing / unit testing of firmware.
Parameters
paramParameter enumeration.
ordinalOrdinal of parameter.
Returns
Value of parameter.

◆ configGetParameter() [2/2]

double com.ctre.phoenix.led.CANdle.configGetParameter ( ParamEnum  param,
int  ordinal,
int  timeoutMs 
)
inline

Gets a parameter. Generally this is not used. This can be utilized in

  • Using new features without updating API installation.
  • Errata workarounds to circumvent API implementation.
  • Allows for rapid testing / unit testing of firmware.
Parameters
paramParameter enumeration.
ordinalOrdinal of parameter.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Value of parameter.

◆ configLEDType() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configLEDType ( LEDStripType  type)
inline

Configures the type of LED the CANdle controls

Parameters
typeThe type of the LEDs the CANdle controls
Returns
ErrorCode generated by function. OK indicates no error.

◆ configLEDType() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configLEDType ( LEDStripType  type,
int  timeoutMs 
)
inline

Configures the type of LED the CANdle controls

Parameters
typeThe type of the LEDs the CANdle controls
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
ErrorCode generated by function. OK indicates no error.

◆ configLOSBehavior() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configLOSBehavior ( boolean  disableWhenLOS)
inline

Configures what the CANdle should do if it loses communications to the Controller

Parameters
disableWhenLOSSet to true to disable the LEDs on Loss of Signal.
Returns
ErrorCode generated by function. OK indicates no error.

◆ configLOSBehavior() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configLOSBehavior ( boolean  disableWhenLOS,
int  timeoutMs 
)
inline

Configures what the CANdle should do if it loses communications to the Controller

Parameters
disableWhenLOSSet to true to disable the LEDs on Loss of Signal.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
ErrorCode generated by function. OK indicates no error.

◆ configSetCustomParam() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configSetCustomParam ( int  paramIndex,
int  value 
)
inline

Sets the value of a custom parameter. This is for arbitrary use.

Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.

Parameters
paramIndexIndex of custom parameter. [0-1]
valueValue for custom parameter.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSetCustomParam() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configSetCustomParam ( int  paramIndex,
int  value,
int  timeoutMs 
)
inline

Sets the value of a custom parameter. This is for arbitrary use.

Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.

Parameters
paramIndexIndex of custom parameter. [0-1]
valueValue for custom parameter.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSetParameter() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configSetParameter ( ParamEnum  param,
double  value,
int  subValue,
int  ordinal 
)
inline

Sets a parameter. Generally this is not used. This can be utilized in

  • Using new features without updating API installation.
  • Errata workarounds to circumvent API implementation.
  • Allows for rapid testing / unit testing of firmware.
Parameters
paramParameter enumeration.
valueValue of parameter.
subValueSubvalue for parameter. Maximum value of 255.
ordinalOrdinal of parameter.
Returns
Error Code generated by function. 0 indicates no error.

◆ configSetParameter() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configSetParameter ( ParamEnum  param,
double  value,
int  subValue,
int  ordinal,
int  timeoutMs 
)
inline

Sets a parameter. Generally this is not used. This can be utilized in

  • Using new features without updating API installation.
  • Errata workarounds to circumvent API implementation.
  • Allows for rapid testing / unit testing of firmware.
Parameters
paramParameter enumeration.
valueValue of parameter.
subValueSubvalue for parameter. Maximum value of 255.
ordinalOrdinal of parameter.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configStatusLedState() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configStatusLedState ( boolean  disableWhenRunning)
inline

Configures how the status led will behave when the CANdle is actively controlling LEDs If the CANdle is LOS or not actively commanded a value, it will always turn on its status LED.

Parameters
disableWhenRunningDisables the status LED when the CANdle is running
Returns
Error Code generated by function. 0 indicates no error.

◆ configStatusLedState() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configStatusLedState ( boolean  disableWhenRunning,
int  timeoutMs 
)
inline

Configures how the status led will behave when the CANdle is actively controlling LEDs If the CANdle is LOS or not actively commanded a value, it will always turn on its status LED.

Parameters
disableWhenRunningDisables the status LED when the CANdle is running
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ configVBatOutput() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.configVBatOutput ( VBatOutputMode  mode)
inline

Configures how the VBat Output will behave

Parameters
modeVBat Output Behavior
Returns
Error Code generated by function. 0 indicates no error.

◆ configVBatOutput() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.configVBatOutput ( VBatOutputMode  mode,
int  timeoutMs 
)
inline

Configures how the VBat Output will behave

Parameters
modeVBat Output Behavior
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

◆ get5VRailVoltage()

double com.ctre.phoenix.led.CANdle.get5VRailVoltage ( )
inline

Gets the Voltage of the 5V line as measured by CANdle

Returns
Voltage of the 5V line

◆ getAllConfigs() [1/2]

void com.ctre.phoenix.led.CANdle.getAllConfigs ( CANdleConfiguration  allConfigs)
inline

Gets all persistant settings.

Parameters
allConfigsObject with all of the persistant settings

◆ getAllConfigs() [2/2]

void com.ctre.phoenix.led.CANdle.getAllConfigs ( CANdleConfiguration  allConfigs,
int  timeoutMs 
)
inline

Gets all persistant settings.

Parameters
allConfigsObject with all of the persistant settings
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.

◆ getBusVoltage()

double com.ctre.phoenix.led.CANdle.getBusVoltage ( )
inline

Gets the Voltage of VBat as measured by CANdle

Returns
Voltage of VBat

◆ getCurrent()

double com.ctre.phoenix.led.CANdle.getCurrent ( )
inline

Gets the low-side current as measured by CANdle

Returns
Current in Amps

◆ getFaults()

ErrorCode com.ctre.phoenix.led.CANdle.getFaults ( CANdleFaults  toFill)
inline

Gets the CANdle fault status

Parameters
toFillContainer for fault statuses.
Returns
Error Code generated by function. OK indicates no error.

◆ getLastError()

ErrorCode com.ctre.phoenix.led.CANdle.getLastError ( )
inline

Call GetLastError() generated by this object. Not all functions return an error code but can potentially report errors.

This function can be used to retrieve those error codes.

Returns
The last ErrorCode generated.

◆ getStatusFramePeriod() [1/2]

int com.ctre.phoenix.led.CANdle.getStatusFramePeriod ( CANdleStatusFrame  frame)
inline

Gets the period of the given status frame.

Parameters
frameFrame to get the period of.
Returns
Period of the given status frame.

◆ getStatusFramePeriod() [2/2]

int com.ctre.phoenix.led.CANdle.getStatusFramePeriod ( CANdleStatusFrame  frame,
int  timeoutMs 
)
inline

Gets the period of the given status frame.

Parameters
frameFrame to get the period of.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Period of the given status frame.

◆ getStickyFaults()

ErrorCode com.ctre.phoenix.led.CANdle.getStickyFaults ( CANdleStickyFaults  toFill)
inline

Gets the CANdle sticky fault status

Parameters
toFillContainer for sticky fault statuses.
Returns
Error Code generated by function. OK indicates no error.

◆ getTemperature()

double com.ctre.phoenix.led.CANdle.getTemperature ( )
inline

Gets the temperature of the CANdle in Celcius

Returns
Temperature in Celcius

◆ getVBatModulation()

double com.ctre.phoenix.led.CANdle.getVBatModulation ( )
inline

Gets the applied vbat modulation in percent. If the CANdle is configured to always enable VBat, this returns 1 If the CANdle is confgigured to always disable VBat, this returns 0 Otherwise it returns the last set Modulation as a value [0, 1]

Returns
VBat Output Modulation

◆ hasResetOccurred()

boolean com.ctre.phoenix.led.CANdle.hasResetOccurred ( )
inline

Returns true if the device has reset since last call.

Returns
Has a Device Reset Occurred?

◆ modulateVBatOutput()

ErrorCode com.ctre.phoenix.led.CANdle.modulateVBatOutput ( double  dutyCyclePrcnt)
inline

Modulates the VBat output to the specified duty cycle percentage This function will only do something if the CANdle's VBatOutput is configured to Modulated

Parameters
dutyCyclePrcntThe duty cycle of the output modulation [0, 1]
Returns
ErrorCode generated by function. OK indicates no error.

◆ setControlFramePeriod()

ErrorCode com.ctre.phoenix.led.CANdle.setControlFramePeriod ( CANdleControlFrame  frame,
int  periodMs 
)
inline

Sets the period of the given control frame.

Parameters
frameFrame whose period is to be changed.
periodMsPeriod in ms for the given frame.
Returns
Error Code generated by function. 0 indicates no error.

◆ setLEDs() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.setLEDs ( int  r,
int  g,
int  b 
)
inline

Sets a block of LEDs to the specified color. This will apply to the first 255 LEDs.

Parameters
rThe amount of Red to set, range is [0, 255]
gThe amount of Green to set, range is [0, 255]
bThe amount of Blue to set, range is [0, 255]
Returns
ErrorCode generated by function. OK indicates no error.

◆ setLEDs() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.setLEDs ( int  r,
int  g,
int  b,
int  w,
int  startIdx,
int  count 
)
inline

Sets a block of LEDs to the specified color

Parameters
rThe amount of Red to set, range is [0, 255]
gThe amount of Green to set, range is [0, 255]
bThe amount of Blue to set, range is [0, 255]
wThe amount of White to set, range is [0, 255]. This only applies for LED strips with white in them.
startIdxWhere to start setting the LEDs
countThe number of LEDs to apply this to
Returns
ErrorCode generated by function. OK indicates no error.

◆ setStatusFramePeriod() [1/2]

ErrorCode com.ctre.phoenix.led.CANdle.setStatusFramePeriod ( CANdleStatusFrame  frame,
int  periodMs 
)
inline

Sets the period of the given status frame.

Parameters
frameFrame whose period is to be changed.
periodMsPeriod in ms for the given frame.
Returns
Error Code generated by function. 0 indicates no error.

◆ setStatusFramePeriod() [2/2]

ErrorCode com.ctre.phoenix.led.CANdle.setStatusFramePeriod ( CANdleStatusFrame  frame,
int  periodMs,
int  timeoutMs 
)
inline

Sets the period of the given status frame.

Parameters
frameFrame whose period is to be changed.
periodMsPeriod in ms for the given frame.
timeoutMsTimeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
Returns
Error Code generated by function. 0 indicates no error.

The documentation for this class was generated from the following file: