CTRE Phoenix 6 C++ 26.0.0-beta-1
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 <units/frequency.h>
12#include <units/time.h>
13
14namespace ctre {
15namespace phoenix6 {
16namespace controls {
17
18/**
19 * Sets LEDs to a solid color.
20 *
21 *
22 */
23class SolidColor 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 color to apply to the LEDs.
40 */
42
43 /**
44 * \brief The frequency at which this control will update.
45 * This is designated in Hertz, with a minimum of 20 Hz
46 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
47 * Some update frequencies are not supported and will be
48 * promoted up to the next highest supported frequency.
49 *
50 * If this field is set to 0 Hz, the control request will
51 * be sent immediately as a one-shot frame. This may be useful
52 * for advanced applications that require outputs to be
53 * synchronized with data acquisition. In this case, we
54 * recommend not exceeding 50 ms between control calls.
55 */
56 // This request is always 0 Hz. units::frequency::hertz_t UpdateFreqHz{0_Hz};
57
58 /**
59 * \brief Sets LEDs to a solid color.
60 *
61 * \details
62 *
63 * \param LEDStartIndex The index of the first LED this animation controls
64 * (inclusive). Indices 0-7 control the onboard LEDs, and
65 * 8-399 control an attached LED strip.
66 * \param LEDEndIndex The index of the last LED this animation controls
67 * (inclusive). Indices 0-7 control the onboard LEDs, and
68 * 8-399 control an attached LED strip.
69 */
71 LEDStartIndex{std::move(LEDStartIndex)},
72 LEDEndIndex{std::move(LEDEndIndex)}
73 {}
74
75 constexpr ~SolidColor() override {}
76
77 /**
78 * \brief Gets the name of this control request.
79 *
80 * \returns Name of the control request
81 */
82 constexpr std::string_view GetName() const override
83 {
84 return "SolidColor";
85 }
86
87 /**
88 * \brief Modifies this Control Request's LEDStartIndex parameter and returns itself for
89 * method-chaining and easier to use request API.
90 *
91 * The index of the first LED this animation controls (inclusive). Indices 0-7
92 * control the onboard LEDs, and 8-399 control an attached LED strip.
93 *
94 * \param newLEDStartIndex Parameter to modify
95 * \returns Itself
96 */
97 constexpr SolidColor &WithLEDStartIndex(int newLEDStartIndex)
98 {
99 LEDStartIndex = std::move(newLEDStartIndex);
100 return *this;
101 }
102
103 /**
104 * \brief Modifies this Control Request's LEDEndIndex parameter and returns itself for
105 * method-chaining and easier to use request API.
106 *
107 * The index of the last LED this animation controls (inclusive). Indices 0-7
108 * control the onboard LEDs, and 8-399 control an attached LED strip.
109 *
110 * \param newLEDEndIndex Parameter to modify
111 * \returns Itself
112 */
113 constexpr SolidColor &WithLEDEndIndex(int newLEDEndIndex)
114 {
115 LEDEndIndex = std::move(newLEDEndIndex);
116 return *this;
117 }
118
119 /**
120 * \brief Modifies this Control Request's Color parameter and returns itself for
121 * method-chaining and easier to use request API.
122 *
123 * The color to apply to the LEDs.
124 *
125 * \param newColor Parameter to modify
126 * \returns Itself
127 */
129 {
130 Color = std::move(newColor);
131 return *this;
132 }
133
134 /**
135 * \brief Sets the frequency at which this control will update.
136 * This is designated in Hertz, with a minimum of 20 Hz
137 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
138 * Some update frequencies are not supported and will be
139 * promoted up to the next highest supported frequency.
140 *
141 * If this field is set to 0 Hz, the control request will
142 * be sent immediately as a one-shot frame. This may be useful
143 * for advanced applications that require outputs to be
144 * synchronized with data acquisition. In this case, we
145 * recommend not exceeding 50 ms between control calls.
146 *
147 * \param newUpdateFreqHz Parameter to modify
148 * \returns Itself
149 */
150 constexpr SolidColor &WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
151 {
152 // This request is always 0 Hz. UpdateFreqHz = newUpdateFreqHz;
153 return *this;
154 }
155
156 /**
157 * \brief Returns a string representation of the object.
158 *
159 * \returns a string representation of the object.
160 */
161 std::string ToString() const override;
162
163 /**
164 * \brief Gets information about this control request.
165 *
166 * \returns Map of control parameter names and corresponding applied values
167 */
168 std::map<std::string, std::string> GetControlInfo() const override;
169};
170
171}
172}
173}
174
Common interface implemented by all control requests.
Definition ControlRequest.hpp:27
Sets LEDs to a solid color.
Definition SolidColor.hpp:23
int LEDStartIndex
The index of the first LED this animation controls (inclusive).
Definition SolidColor.hpp:32
constexpr SolidColor & WithLEDStartIndex(int newLEDStartIndex)
Modifies this Control Request's LEDStartIndex parameter and returns itself for method-chaining and ea...
Definition SolidColor.hpp:97
constexpr SolidColor(int LEDStartIndex, int LEDEndIndex)
The frequency at which this control will update.
Definition SolidColor.hpp:70
int LEDEndIndex
The index of the last LED this animation controls (inclusive).
Definition SolidColor.hpp:37
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:128
constexpr SolidColor & WithLEDEndIndex(int newLEDEndIndex)
Modifies this Control Request's LEDEndIndex parameter and returns itself for method-chaining and easi...
Definition SolidColor.hpp:113
constexpr SolidColor & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the frequency at which this control will update.
Definition SolidColor.hpp:150
constexpr ~SolidColor() override
Definition SolidColor.hpp:75
constexpr std::string_view GetName() const override
Gets the name of this control request.
Definition SolidColor.hpp:82
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
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:41
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 motor_constants.h:14