CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
SolidColor.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
11#include <wpi/units/frequency.hpp>
12#include <wpi/units/time.hpp>
13
14namespace ctre {
15namespace phoenix6 {
16namespace controls {
17
18/**
19 * Sets LEDs to a solid color.
20 */
21class SolidColor final : public ControlRequest {
22 ctre::phoenix::StatusCode SendRequest(const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req) const override;
23
24public:
25 /**
26 * \brief The index of the first LED this animation controls (inclusive).
27 * Indices 0-7 control the onboard LEDs, and 8-399 control an attached LED
28 * strip.
29 */
31 /**
32 * \brief The index of the last LED this animation controls (inclusive). Indices
33 * 0-7 control the onboard LEDs, and 8-399 control an attached LED strip.
34 */
36 /**
37 * \brief The color to apply to the LEDs.
38 */
40
41 /**
42 * \brief The frequency at which this control will update.
43 * This is designated in Hertz, with a minimum of 20 Hz
44 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
45 * Some update frequencies are not supported and will be
46 * promoted up to the next highest supported frequency.
47 *
48 * If this field is set to 0 Hz, the control request will
49 * be sent immediately as a one-shot frame. This may be useful
50 * for advanced applications that require outputs to be
51 * synchronized with data acquisition. In this case, we
52 * recommend not exceeding 50 ms between control calls.
53 */
54 // This request is always 0 Hz. wpi::units::hertz_t UpdateFreqHz{0_Hz};
55
56 /**
57 * \brief Sets LEDs to a solid color.
58 *
59 * \param LEDStartIndex The index of the first LED this animation controls
60 * (inclusive). Indices 0-7 control the onboard LEDs, and
61 * 8-399 control an attached LED strip.
62 * \param LEDEndIndex The index of the last LED this animation controls
63 * (inclusive). Indices 0-7 control the onboard LEDs, and
64 * 8-399 control an attached LED strip.
65 */
67 LEDStartIndex{std::move(LEDStartIndex)},
68 LEDEndIndex{std::move(LEDEndIndex)}
69 {}
70
71 constexpr ~SolidColor() override {}
72
73 /**
74 * \brief Gets the name of this control request.
75 *
76 * \returns Name of the control request
77 */
78 constexpr std::string_view GetName() const override
79 {
80 return "SolidColor";
81 }
82
83 /**
84 * \brief Modifies this Control Request's LEDStartIndex parameter and returns itself for
85 * method-chaining and easier to use request API.
86 *
87 * The index of the first LED this animation controls (inclusive). Indices 0-7
88 * control the onboard LEDs, and 8-399 control an attached LED strip.
89 *
90 * \param newLEDStartIndex Parameter to modify
91 * \returns Itself
92 */
93 constexpr SolidColor &WithLEDStartIndex(int newLEDStartIndex)
94 {
95 LEDStartIndex = std::move(newLEDStartIndex);
96 return *this;
97 }
98
99 /**
100 * \brief Modifies this Control Request's LEDEndIndex parameter and returns itself for
101 * method-chaining and easier to use request API.
102 *
103 * The index of the last LED this animation controls (inclusive). Indices 0-7
104 * control the onboard LEDs, and 8-399 control an attached LED strip.
105 *
106 * \param newLEDEndIndex Parameter to modify
107 * \returns Itself
108 */
109 constexpr SolidColor &WithLEDEndIndex(int newLEDEndIndex)
110 {
111 LEDEndIndex = std::move(newLEDEndIndex);
112 return *this;
113 }
114
115 /**
116 * \brief Modifies this Control Request's Color parameter and returns itself for
117 * method-chaining and easier to use request API.
118 *
119 * The color to apply to the LEDs.
120 *
121 * \param newColor Parameter to modify
122 * \returns Itself
123 */
125 {
126 Color = std::move(newColor);
127 return *this;
128 }
129
130 /**
131 * \brief Sets the frequency at which this control will update.
132 * This is designated in Hertz, with a minimum of 20 Hz
133 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
134 * Some update frequencies are not supported and will be
135 * promoted up to the next highest supported frequency.
136 *
137 * If this field is set to 0 Hz, the control request will
138 * be sent immediately as a one-shot frame. This may be useful
139 * for advanced applications that require outputs to be
140 * synchronized with data acquisition. In this case, we
141 * recommend not exceeding 50 ms between control calls.
142 *
143 * \param newUpdateFreqHz Parameter to modify
144 * \returns Itself
145 */
146 constexpr SolidColor &WithUpdateFreqHz(wpi::units::hertz_t newUpdateFreqHz)
147 {
148 // This request is always 0 Hz. UpdateFreqHz = newUpdateFreqHz;
149 return *this;
150 }
151
152 /**
153 * \brief Returns a string representation of the object.
154 *
155 * \returns a string representation of the object.
156 */
157 std::string ToString() const override;
158
159 /**
160 * \brief Gets information about this control request.
161 *
162 * \returns Map of control parameter names and corresponding applied values
163 */
164 std::map<std::string_view, std::string> GetControlInfo() const override;
165};
166
167}
168}
169}
170
constexpr ControlRequest(ControlRequest const &)=default
int LEDStartIndex
The index of the first LED this animation controls (inclusive).
Definition SolidColor.hpp:30
std::map< std::string_view, std::string > GetControlInfo() const override
Gets information about this control request.
constexpr SolidColor & WithLEDStartIndex(int newLEDStartIndex)
Modifies this Control Request's LEDStartIndex parameter and returns itself for method-chaining and ea...
Definition SolidColor.hpp:93
constexpr SolidColor(int LEDStartIndex, int LEDEndIndex)
The frequency at which this control will update.
Definition SolidColor.hpp:66
int LEDEndIndex
The index of the last LED this animation controls (inclusive).
Definition SolidColor.hpp:35
constexpr SolidColor & WithColor(signals::RGBWColor newColor)
Modifies this Control Request's Color parameter and returns itself for method-chaining and easier to ...
Definition SolidColor.hpp:124
constexpr SolidColor & WithLEDEndIndex(int newLEDEndIndex)
Modifies this Control Request's LEDEndIndex parameter and returns itself for method-chaining and easi...
Definition SolidColor.hpp:109
constexpr ~SolidColor() override
Definition SolidColor.hpp:71
constexpr std::string_view GetName() const override
Gets the name of this control request.
Definition SolidColor.hpp:78
std::string ToString() const override
Returns a string representation of the object.
signals::RGBWColor Color
The color to apply to the LEDs.
Definition SolidColor.hpp:39
constexpr SolidColor & WithUpdateFreqHz(wpi::units::hertz_t newUpdateFreqHz)
Sets the frequency at which this control will update.
Definition SolidColor.hpp:146
Represents an RGBW color that can be applied to an LED.
Definition RGBWColor.hpp:27
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition MotionMagicDutyCycle.hpp:17
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14