15#include <units/frequency.h>
16#include <units/time.h>
29 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req)
const override
31 if (req.get() !=
this)
34 if (reqCast !=
nullptr)
40 req = std::make_shared<LarsonAnimation>(*
this);
44 return c_ctre_phoenix6_RequestControlLarsonAnimation(network, deviceHash,
UpdateFreqHz.to<
double>(),
LEDStartIndex,
LEDEndIndex,
Slot,
Color.
Red,
Color.
Green,
Color.
Blue,
Color.
White,
Size,
BounceMode.
value,
FrameRate.to<
double>());
163 Slot = std::move(newSlot);
178 Color = std::move(newColor);
193 Size = std::move(newSize);
259 std::stringstream ss;
260 ss <<
"Control: LarsonAnimation" << std::endl;
262 ss <<
" LEDEndIndex: " <<
LEDEndIndex << std::endl;
263 ss <<
" Slot: " <<
Slot << std::endl;
264 ss <<
" Color: " <<
Color << std::endl;
265 ss <<
" Size: " <<
Size << std::endl;
266 ss <<
" BounceMode: " <<
BounceMode << std::endl;
267 ss <<
" FrameRate: " <<
FrameRate.to<
double>() <<
" Hz" << std::endl;
278 std::map<std::string, std::string> controlInfo;
279 std::stringstream ss;
280 controlInfo[
"Name"] =
GetName();
281 ss <<
LEDStartIndex; controlInfo[
"LEDStartIndex"] = ss.str(); ss.str(std::string{});
282 ss <<
LEDEndIndex; controlInfo[
"LEDEndIndex"] = ss.str(); ss.str(std::string{});
283 ss <<
Slot; controlInfo[
"Slot"] = ss.str(); ss.str(std::string{});
284 ss <<
Color; controlInfo[
"Color"] = ss.str(); ss.str(std::string{});
285 ss <<
Size; controlInfo[
"Size"] = ss.str(); ss.str(std::string{});
286 ss <<
BounceMode; controlInfo[
"BounceMode"] = ss.str(); ss.str(std::string{});
287 ss <<
FrameRate.to<
double>(); controlInfo[
"FrameRate"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlLarsonAnimation(const char *canbus, uint32_t ecuEncoding, double updateFrequency, int LEDStartIndex, int LEDEndIndex, int Slot, int Color_Red, int Color_Green, int Color_Blue, int Color_White, int Size, int BounceMode, double FrameRate)
Abstract Control Request class that other control requests extend for use.
Definition ControlRequest.hpp:30
std::string const & GetName() const
Definition ControlRequest.hpp:53
Animation that bounces a pocket of light across the LED strip.
Definition LarsonAnimation.hpp:28
int LEDEndIndex
The index of the last LED this animation controls (inclusive).
Definition LarsonAnimation.hpp:58
LarsonAnimation & WithColor(signals::RGBWColor newColor)
Modifies this Control Request's Color parameter and returns itself for method-chaining and easier to ...
Definition LarsonAnimation.hpp:176
signals::RGBWColor Color
The color to use in the animation.
Definition LarsonAnimation.hpp:67
LarsonAnimation & WithFrameRate(units::frequency::hertz_t newFrameRate)
Modifies this Control Request's FrameRate parameter and returns itself for method-chaining and easier...
Definition LarsonAnimation.hpp:228
LarsonAnimation & WithSlot(int newSlot)
Modifies this Control Request's Slot parameter and returns itself for method-chaining and easier to u...
Definition LarsonAnimation.hpp:161
LarsonAnimation & WithLEDEndIndex(int newLEDEndIndex)
Modifies this Control Request's LEDEndIndex parameter and returns itself for method-chaining and easi...
Definition LarsonAnimation.hpp:145
int Size
The number of LEDs in the pocket of light, up to 15.
Definition LarsonAnimation.hpp:71
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition LarsonAnimation.hpp:100
LarsonAnimation & WithSize(int newSize)
Modifies this Control Request's Size parameter and returns itself for method-chaining and easier to u...
Definition LarsonAnimation.hpp:191
units::frequency::hertz_t FrameRate
The frame rate of the animation, from [2, 1000] Hz.
Definition LarsonAnimation.hpp:87
int Slot
The slot of this animation, within [0, 7].
Definition LarsonAnimation.hpp:63
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition LarsonAnimation.hpp:276
LarsonAnimation(int LEDStartIndex, int LEDEndIndex)
Animation that bounces a pocket of light across the LED strip.
Definition LarsonAnimation.hpp:114
LarsonAnimation & WithBounceMode(signals::LarsonBounceValue newBounceMode)
Modifies this Control Request's BounceMode parameter and returns itself for method-chaining and easie...
Definition LarsonAnimation.hpp:206
signals::LarsonBounceValue BounceMode
The behavior of the pocket of light when it reaches the end of the strip.
Definition LarsonAnimation.hpp:76
LarsonAnimation & WithLEDStartIndex(int newLEDStartIndex)
Modifies this Control Request's LEDStartIndex parameter and returns itself for method-chaining and ea...
Definition LarsonAnimation.hpp:129
int LEDStartIndex
The index of the first LED this animation controls (inclusive).
Definition LarsonAnimation.hpp:53
std::string ToString() const override
Returns a string representation of the object.
Definition LarsonAnimation.hpp:257
LarsonAnimation & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition LarsonAnimation.hpp:247
The behavior of the larson animation pocket of light when it reaches the end of the strip.
Definition SpnEnums.hpp:6470
int value
Definition SpnEnums.hpp:6472
static constexpr int Front
The animation bounces as soon as the first LED reaches the end of the strip.
Definition SpnEnums.hpp:6478
Represents an RGBW color that can be applied to an LED.
Definition RGBWColor.hpp:27
uint8_t Green
The green component of the color, within [0, 255].
Definition RGBWColor.hpp:36
uint8_t Blue
The blue component of the color, within [0, 255].
Definition RGBWColor.hpp:40
uint8_t White
The white component of the color, within [0, 255].
Definition RGBWColor.hpp:45
uint8_t Red
The red component of the color, within [0, 255].
Definition RGBWColor.hpp:32
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
Definition Diff_PositionDutyCycle_Position.hpp:15