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