Valor 6800 1.0
Loading...
Searching...
No Matches
valor::CANdleSensor Class Reference

Sensor for controlling the CANdle and associated LEDs. More...

#include <CANdleSensor.h>

Inheritance diagram for valor::CANdleSensor:
valor::BaseSensor< int > valor::Loggable

Public Types

enum  Priority { LOW , MEDIUM , HIGH }
 

Public Member Functions

 CANdleSensor (frc::TimedRobot &robot, int ledCount, int segments, int canID, std::string canbus="baseCAN")
 Construct a new CANdleSensor object.
 
void setBrightness (double brightness, bool saveImmediately=true)
 
void setStripType (ctre::phoenix6::signals::StripTypeValue stripType, bool saveImmediately=true)
 
void setLED (int led, frc::Color8Bit color)
 Set the color of a specific LED.
 
void setColor (int segment, frc::Color8Bit color, Priority priority=LOW)
 Set the color of a specific segment.
 
void setColor (frc::Color8Bit color, Priority priority=LOW)
 Set the color for all segments.
 
template<typename T >
void setAnimation (int segment, frc::Color8Bit color, Priority priority=LOW)
 Set an animation for a specific segment.
 
template<typename T >
void setAnimation (frc::Color8Bit color, Priority priority=LOW)
 Set an animation for all segments.
 
void clearAnimation (int segment)
 Clears any active animation for a specific segment.
 
void reset () override
 Resets the CANdle device.
 
- Public Member Functions inherited from valor::BaseSensor< int >
void setGetter (std::function< int()> _lambda)
 Set the lambda function to fetch sensor data.
 
void applyPostProcessing (std::function< int(int)> func)
 Set a post-processing function for sensor data.
 
int get ()
 Get the current sensor state.
 
- Public Member Functions inherited from valor::Loggable
void LogChild (std::string_view name, Loggable *child)
 Register a child Loggable under a named subtree.
 
void LogChild (std::string_view name, wpi::Sendable *child)
 Register a child Sendable under a named subtree.
 
void setLoggingPeriod (units::millisecond_t period)
 Set the minimum period between LoggablePeriodic() invocations.
 
template<>
decltype(Loggable::subscribers) ::iterator addSubscriber (std::string_view field, const std::vector< bool > &defaultValue)
 
template<>
void WriteLogImpl (nt::Publisher *pub, const std::vector< bool > &data)
 
template<>
std::vector< boolReadLogImpl (nt::Subscriber *sub)
 

Static Public Member Functions

static frc::Color8Bit cancoderMagnetHealthGetter (ctre::phoenix6::hardware::CANcoder *cancoder)
 Get the health status of a CANcoder magnet.
 
- Static Public Member Functions inherited from valor::Loggable
static units::millisecond_t GetLoggingTime ()
 

Static Public Attributes

static constexpr frc::Color8Bit VALOR_GOLD {0xEE, 0xA8, 0x00}
 
static constexpr frc::Color8Bit VALOR_PURPLE {0xFF, 0x00, 0xFF}
 
static constexpr frc::Color8Bit RED {0xFF, 0x00, 0x00}
 
static constexpr frc::Color8Bit ORANGE {0xFF, 0x30, 0x00}
 
static constexpr frc::Color8Bit GREEN {0x00, 0xFF, 0x00}
 
static constexpr frc::Color8Bit BLUE {0x00, 0x00, 0xFF}
 
static constexpr frc::Color8Bit LIGHT_BLUE {0xFF, 0x00, 0xF9}
 
static constexpr frc::Color8Bit WHITE {0xFF, 0xFF, 0xFF}
 
static constexpr frc::Color8Bit OFF {0x00, 0x00, 0x00}
 

Additional Inherited Members

- Protected Member Functions inherited from valor::BaseSensor< int >
 BaseSensor (frc::TimedRobot &robot)
 Construct a new BaseSensor object.
 
virtual void refresh ()
 Refresh the sensor state.
 
- Protected Member Functions inherited from valor::Loggable
 Loggable (std::string_view name)
 Construct a Loggable that registers a top-level table name.
 
 Loggable ()
 Default construct an uninitialized Loggable.
 
virtual ~Loggable ()=default
 Virtual destructor.
 
virtual void OnLoggingStart ()
 Hook invoked when logging is started for this object.
 
virtual void LoggablePeriodic ()
 Periodic callback for logging updates.
 
template<typename T >
T WriteLog (std::string_view field, const T &data)
 Publish a value to NetworkTables under the given field.
 
template<typename T >
ReadLog (std::string_view field, const T &defaultValue={})
 Read a value from NetworkTables for the given field.
 
- Protected Attributes inherited from valor::BaseSensor< int >
std::function< int()> sensorLambda
 Lambda function to fetch sensor data.
 
std::function< int(int)> postProcessor
 Lambda function to post-process sensor data.
 
int prevState
 Previous and current sensor states.
 
int currState
 
frc::Timer profiler
 

Detailed Description

Sensor for controlling the CANdle and associated LEDs.

This class manages a CANdle device and any connected LEDs. It supports setting static colors, animations, and segment-specific configurations.

Constructor & Destructor Documentation

◆ CANdleSensor()

valor::CANdleSensor::CANdleSensor ( frc::TimedRobot & robot,
int ledCount,
int segments,
int canID,
std::string canbus = "baseCAN" )

Construct a new CANdleSensor object.

Parameters
robotReference to the main robot instance.
ledCountNumber of external LEDs connected to the CANdle.
segmentsNumber of LED segments.
canIDCAN ID assigned to the CANdle.
canbusCAN bus the CANdle is attached to (default: "baseCAN").

Member Function Documentation

◆ cancoderMagnetHealthGetter()

static frc::Color8Bit valor::CANdleSensor::cancoderMagnetHealthGetter ( ctre::phoenix6::hardware::CANcoder * cancoder)
static

Get the health status of a CANcoder magnet.

Parameters
cancoderPointer to the CANcoder device.
Returns
frc::Color8Bit Color representing the health status.

◆ clearAnimation()

void valor::CANdleSensor::clearAnimation ( int segment)

Clears any active animation for a specific segment.

Also responsible for clearing the appropriate memory associated with the animation.

Parameters
segmentThe segment that will be cleared.

◆ reset()

void valor::CANdleSensor::reset ( )
overridevirtual

Resets the CANdle device.

Reimplemented from valor::BaseSensor< int >.

◆ setAnimation() [1/2]

template<typename T >
void valor::CANdleSensor::setAnimation ( frc::Color8Bit color,
Priority priority = LOW )
inline

Set an animation for all segments.

Template Parameters
TAnimation type.
Parameters
colorColor for the animation.
priorityPriority for the animation.

◆ setAnimation() [2/2]

template<typename T >
void valor::CANdleSensor::setAnimation ( int segment,
frc::Color8Bit color,
Priority priority = LOW )
inline

Set an animation for a specific segment.

Template Parameters
TAnimation type.
Parameters
segmentSegment index to modify.
colorColor for the animation.
priorityPriority for the animation.

◆ setColor() [1/2]

void valor::CANdleSensor::setColor ( frc::Color8Bit color,
Priority priority = LOW )

Set the color for all segments.

Parameters
colorRGB hex code to set.
priorityPriority level for the color setting.

◆ setColor() [2/2]

void valor::CANdleSensor::setColor ( int segment,
frc::Color8Bit color,
Priority priority = LOW )

Set the color of a specific segment.

Parameters
segmentSegment index to modify.
colorColor to set.
priorityPriority for the color setting.

◆ setLED()

void valor::CANdleSensor::setLED ( int led,
frc::Color8Bit color )

Set the color of a specific LED.

Parameters
ledIndex of the LED to set.
colorColor to set.

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