CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
TwinkleOffAnimation.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#include <wpi/units/dimensionless.hpp>
14
15namespace ctre {
16namespace phoenix6 {
17namespace controls {
18
19/**
20 * Animation that randomly turns on LEDs until it reaches the maximum count, and
21 * then turns them all off.
22 */
23class TwinkleOffAnimation final : public ControlRequest {
24 ctre::phoenix::StatusCode SendRequest(const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req) const override;
25
26public:
27 /**
28 * \brief The index of the first LED this animation controls (inclusive).
29 * Indices 0-7 control the onboard LEDs, and 8-399 control an attached LED
30 * strip.
31 */
33 /**
34 * \brief The index of the last LED this animation controls (inclusive). Indices
35 * 0-7 control the onboard LEDs, and 8-399 control an attached LED strip.
36 */
38 /**
39 * \brief The slot of this animation, within [0, 7]. Each slot on the CANdle can
40 * store and run one animation.
41 */
42 int Slot = 0;
43 /**
44 * \brief The color to use in the animation.
45 */
47 /**
48 * \brief The max proportion of LEDs that can be on, in the range [0.1, 1.0].
49 */
50 wpi::units::scalar_t MaxLEDsOnProportion = 1.0;
51 /**
52 * \brief The frame rate of the animation, from [2, 1000] Hz. This determines
53 * the speed of the animation.
54 *
55 * A frame is defined as a transition in the state of the LEDs, turning one LED
56 * on or all LEDs off.
57 *
58 * - Units: Hz
59 *
60 */
61 wpi::units::hertz_t FrameRate = 25_Hz;
62
63 /**
64 * \brief The frequency at which this control will update.
65 * This is designated in Hertz, with a minimum of 20 Hz
66 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
67 * Some update frequencies are not supported and will be
68 * promoted up to the next highest supported frequency.
69 *
70 * If this field is set to 0 Hz, the control request will
71 * be sent immediately as a one-shot frame. This may be useful
72 * for advanced applications that require outputs to be
73 * synchronized with data acquisition. In this case, we
74 * recommend not exceeding 50 ms between control calls.
75 */
76 wpi::units::hertz_t UpdateFreqHz{20_Hz};
77
78 /**
79 * \brief Animation that randomly turns on LEDs until it reaches the maximum
80 * count, and then turns them all off.
81 *
82 * \param LEDStartIndex The index of the first LED this animation controls
83 * (inclusive). Indices 0-7 control the onboard LEDs, and
84 * 8-399 control an attached LED strip.
85 * \param LEDEndIndex The index of the last LED this animation controls
86 * (inclusive). Indices 0-7 control the onboard LEDs, and
87 * 8-399 control an attached LED strip.
88 */
93
94 constexpr ~TwinkleOffAnimation() override {}
95
96 /**
97 * \brief Gets the name of this control request.
98 *
99 * \returns Name of the control request
100 */
101 constexpr std::string_view GetName() const override
102 {
103 return "TwinkleOffAnimation";
104 }
105
106 /**
107 * \brief Modifies this Control Request's LEDStartIndex parameter and returns itself for
108 * method-chaining and easier to use request API.
109 *
110 * The index of the first LED this animation controls (inclusive). Indices 0-7
111 * control the onboard LEDs, and 8-399 control an attached LED strip.
112 *
113 * \param newLEDStartIndex Parameter to modify
114 * \returns Itself
115 */
116 constexpr TwinkleOffAnimation &WithLEDStartIndex(int newLEDStartIndex)
117 {
118 LEDStartIndex = std::move(newLEDStartIndex);
119 return *this;
120 }
121
122 /**
123 * \brief Modifies this Control Request's LEDEndIndex parameter and returns itself for
124 * method-chaining and easier to use request API.
125 *
126 * The index of the last LED this animation controls (inclusive). Indices 0-7
127 * control the onboard LEDs, and 8-399 control an attached LED strip.
128 *
129 * \param newLEDEndIndex Parameter to modify
130 * \returns Itself
131 */
132 constexpr TwinkleOffAnimation &WithLEDEndIndex(int newLEDEndIndex)
133 {
134 LEDEndIndex = std::move(newLEDEndIndex);
135 return *this;
136 }
137
138 /**
139 * \brief Modifies this Control Request's Slot parameter and returns itself for
140 * method-chaining and easier to use request API.
141 *
142 * The slot of this animation, within [0, 7]. Each slot on the CANdle can store
143 * and run one animation.
144 *
145 * \param newSlot Parameter to modify
146 * \returns Itself
147 */
148 constexpr TwinkleOffAnimation &WithSlot(int newSlot)
149 {
150 Slot = std::move(newSlot);
151 return *this;
152 }
153
154 /**
155 * \brief Modifies this Control Request's Color parameter and returns itself for
156 * method-chaining and easier to use request API.
157 *
158 * The color to use in the animation.
159 *
160 * \param newColor Parameter to modify
161 * \returns Itself
162 */
164 {
165 Color = std::move(newColor);
166 return *this;
167 }
168
169 /**
170 * \brief Modifies this Control Request's MaxLEDsOnProportion parameter and returns itself for
171 * method-chaining and easier to use request API.
172 *
173 * The max proportion of LEDs that can be on, in the range [0.1, 1.0].
174 *
175 * \param newMaxLEDsOnProportion Parameter to modify
176 * \returns Itself
177 */
178 constexpr TwinkleOffAnimation &WithMaxLEDsOnProportion(wpi::units::scalar_t newMaxLEDsOnProportion)
179 {
180 MaxLEDsOnProportion = std::move(newMaxLEDsOnProportion);
181 return *this;
182 }
183
184 /**
185 * \brief Modifies this Control Request's FrameRate parameter and returns itself for
186 * method-chaining and easier to use request API.
187 *
188 * The frame rate of the animation, from [2, 1000] Hz. This determines the speed
189 * of the animation.
190 *
191 * A frame is defined as a transition in the state of the LEDs, turning one LED
192 * on or all LEDs off.
193 *
194 * - Units: Hz
195 *
196 *
197 * \param newFrameRate Parameter to modify
198 * \returns Itself
199 */
200 constexpr TwinkleOffAnimation &WithFrameRate(wpi::units::hertz_t newFrameRate)
201 {
202 FrameRate = std::move(newFrameRate);
203 return *this;
204 }
205
206 /**
207 * \brief Sets the frequency at which this control will update.
208 * This is designated in Hertz, with a minimum of 20 Hz
209 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
210 * Some update frequencies are not supported and will be
211 * promoted up to the next highest supported frequency.
212 *
213 * If this field is set to 0 Hz, the control request will
214 * be sent immediately as a one-shot frame. This may be useful
215 * for advanced applications that require outputs to be
216 * synchronized with data acquisition. In this case, we
217 * recommend not exceeding 50 ms between control calls.
218 *
219 * \param newUpdateFreqHz Parameter to modify
220 * \returns Itself
221 */
222 constexpr TwinkleOffAnimation &WithUpdateFreqHz(wpi::units::hertz_t newUpdateFreqHz)
223 {
224 UpdateFreqHz = newUpdateFreqHz;
225 return *this;
226 }
227
228 /**
229 * \brief Returns a string representation of the object.
230 *
231 * \returns a string representation of the object.
232 */
233 std::string ToString() const override;
234
235 /**
236 * \brief Gets information about this control request.
237 *
238 * \returns Map of control parameter names and corresponding applied values
239 */
240 std::map<std::string_view, std::string> GetControlInfo() const override;
241};
242
243}
244}
245}
246
constexpr ControlRequest(ControlRequest const &)=default
constexpr TwinkleOffAnimation & WithColor(signals::RGBWColor newColor)
Modifies this Control Request's Color parameter and returns itself for method-chaining and easier to ...
Definition TwinkleOffAnimation.hpp:163
constexpr std::string_view GetName() const override
Gets the name of this control request.
Definition TwinkleOffAnimation.hpp:101
constexpr TwinkleOffAnimation & WithMaxLEDsOnProportion(wpi::units::scalar_t newMaxLEDsOnProportion)
Modifies this Control Request's MaxLEDsOnProportion parameter and returns itself for method-chaining ...
Definition TwinkleOffAnimation.hpp:178
constexpr TwinkleOffAnimation(int LEDStartIndex, int LEDEndIndex)
Animation that randomly turns on LEDs until it reaches the maximum count, and then turns them all off...
Definition TwinkleOffAnimation.hpp:89
wpi::units::hertz_t UpdateFreqHz
The frequency at which this control will update.
Definition TwinkleOffAnimation.hpp:76
constexpr TwinkleOffAnimation & WithLEDStartIndex(int newLEDStartIndex)
Modifies this Control Request's LEDStartIndex parameter and returns itself for method-chaining and ea...
Definition TwinkleOffAnimation.hpp:116
wpi::units::scalar_t MaxLEDsOnProportion
The max proportion of LEDs that can be on, in the range [0.1, 1.0].
Definition TwinkleOffAnimation.hpp:50
constexpr TwinkleOffAnimation & WithUpdateFreqHz(wpi::units::hertz_t newUpdateFreqHz)
Sets the frequency at which this control will update.
Definition TwinkleOffAnimation.hpp:222
int LEDEndIndex
The index of the last LED this animation controls (inclusive).
Definition TwinkleOffAnimation.hpp:37
constexpr TwinkleOffAnimation & WithSlot(int newSlot)
Modifies this Control Request's Slot parameter and returns itself for method-chaining and easier to u...
Definition TwinkleOffAnimation.hpp:148
std::string ToString() const override
Returns a string representation of the object.
std::map< std::string_view, std::string > GetControlInfo() const override
Gets information about this control request.
signals::RGBWColor Color
The color to use in the animation.
Definition TwinkleOffAnimation.hpp:46
constexpr ~TwinkleOffAnimation() override
Definition TwinkleOffAnimation.hpp:94
constexpr TwinkleOffAnimation & WithFrameRate(wpi::units::hertz_t newFrameRate)
Modifies this Control Request's FrameRate parameter and returns itself for method-chaining and easier...
Definition TwinkleOffAnimation.hpp:200
wpi::units::hertz_t FrameRate
The frame rate of the animation, from [2, 1000] Hz.
Definition TwinkleOffAnimation.hpp:61
int LEDStartIndex
The index of the first LED this animation controls (inclusive).
Definition TwinkleOffAnimation.hpp:32
constexpr TwinkleOffAnimation & WithLEDEndIndex(int newLEDEndIndex)
Modifies this Control Request's LEDEndIndex parameter and returns itself for method-chaining and easi...
Definition TwinkleOffAnimation.hpp:132
int Slot
The slot of this animation, within [0, 7].
Definition TwinkleOffAnimation.hpp:42
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