CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
ModulateVBatOut.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
10#include <wpi/units/frequency.hpp>
11#include <wpi/units/time.hpp>
12#include <wpi/units/dimensionless.hpp>
13
14namespace ctre {
15namespace phoenix6 {
16namespace controls {
17
18/**
19 * Modulates the CANdle VBat output to the specified duty cycle. This can be
20 * used to control a single-color LED strip.
21 *
22 * Note that configs::CANdleFeaturesConfigs::VBatOutputMode must be set to
23 * signals::VBatOutputModeValue::Modulated.
24 */
25class ModulateVBatOut final : public ControlRequest {
26 ctre::phoenix::StatusCode SendRequest(const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req) const override;
27
28public:
29 /**
30 * \brief Proportion of VBat to output in fractional units between 0.0 and 1.0.
31 *
32 * - Units: fractional
33 *
34 */
35 wpi::units::scalar_t Output;
36
37 /**
38 * \brief The frequency at which this control will update.
39 * This is designated in Hertz, with a minimum of 20 Hz
40 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
41 * Some update frequencies are not supported and will be
42 * promoted up to the next highest supported frequency.
43 *
44 * If this field is set to 0 Hz, the control request will
45 * be sent immediately as a one-shot frame. This may be useful
46 * for advanced applications that require outputs to be
47 * synchronized with data acquisition. In this case, we
48 * recommend not exceeding 50 ms between control calls.
49 */
50 wpi::units::hertz_t UpdateFreqHz{50_Hz};
51
52 /**
53 * \brief Modulates the CANdle VBat output to the specified duty cycle. This can
54 * be used to control a single-color LED strip.
55 *
56 * Note that configs::CANdleFeaturesConfigs::VBatOutputMode must be set
57 * to signals::VBatOutputModeValue::Modulated.
58 *
59 * \param Output Proportion of VBat to output in fractional units between 0.0
60 * and 1.0.
61 */
62 constexpr ModulateVBatOut(wpi::units::scalar_t Output) : ControlRequest{},
63 Output{std::move(Output)}
64 {}
65
66 constexpr ~ModulateVBatOut() override {}
67
68 /**
69 * \brief Gets the name of this control request.
70 *
71 * \returns Name of the control request
72 */
73 constexpr std::string_view GetName() const override
74 {
75 return "ModulateVBatOut";
76 }
77
78 /**
79 * \brief Modifies this Control Request's Output parameter and returns itself for
80 * method-chaining and easier to use request API.
81 *
82 * Proportion of VBat to output in fractional units between 0.0 and 1.0.
83 *
84 * - Units: fractional
85 *
86 *
87 * \param newOutput Parameter to modify
88 * \returns Itself
89 */
90 constexpr ModulateVBatOut &WithOutput(wpi::units::scalar_t newOutput)
91 {
92 Output = std::move(newOutput);
93 return *this;
94 }
95
96 /**
97 * \brief Sets the frequency at which this control will update.
98 * This is designated in Hertz, with a minimum of 20 Hz
99 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
100 * Some update frequencies are not supported and will be
101 * promoted up to the next highest supported frequency.
102 *
103 * If this field is set to 0 Hz, the control request will
104 * be sent immediately as a one-shot frame. This may be useful
105 * for advanced applications that require outputs to be
106 * synchronized with data acquisition. In this case, we
107 * recommend not exceeding 50 ms between control calls.
108 *
109 * \param newUpdateFreqHz Parameter to modify
110 * \returns Itself
111 */
112 constexpr ModulateVBatOut &WithUpdateFreqHz(wpi::units::hertz_t newUpdateFreqHz)
113 {
114 UpdateFreqHz = newUpdateFreqHz;
115 return *this;
116 }
117
118 /**
119 * \brief Returns a string representation of the object.
120 *
121 * \returns a string representation of the object.
122 */
123 std::string ToString() const override;
124
125 /**
126 * \brief Gets information about this control request.
127 *
128 * \returns Map of control parameter names and corresponding applied values
129 */
130 std::map<std::string_view, std::string> GetControlInfo() const override;
131};
132
133}
134}
135}
136
constexpr ControlRequest(ControlRequest const &)=default
constexpr ModulateVBatOut(wpi::units::scalar_t Output)
Modulates the CANdle VBat output to the specified duty cycle.
Definition ModulateVBatOut.hpp:62
std::map< std::string_view, std::string > GetControlInfo() const override
Gets information about this control request.
constexpr ~ModulateVBatOut() override
Definition ModulateVBatOut.hpp:66
constexpr std::string_view GetName() const override
Gets the name of this control request.
Definition ModulateVBatOut.hpp:73
constexpr ModulateVBatOut & WithOutput(wpi::units::scalar_t newOutput)
Modifies this Control Request's Output parameter and returns itself for method-chaining and easier to...
Definition ModulateVBatOut.hpp:90
constexpr ModulateVBatOut & WithUpdateFreqHz(wpi::units::hertz_t newUpdateFreqHz)
Sets the frequency at which this control will update.
Definition ModulateVBatOut.hpp:112
wpi::units::scalar_t Output
Proportion of VBat to output in fractional units between 0.0 and 1.0.
Definition ModulateVBatOut.hpp:35
std::string ToString() const override
Returns a string representation of the object.
wpi::units::hertz_t UpdateFreqHz
The frequency at which this control will update.
Definition ModulateVBatOut.hpp:50
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