20 #ifndef INCLUDE_OLA_RDM_RESPONDERSETTINGS_H_ 21 #define INCLUDE_OLA_RDM_RESPONDERSETTINGS_H_ 57 uint8_t *data)
const = 0;
65 typedef const char* ArgType;
80 return sizeof(description_s);
88 struct description_s {
90 char description[MAX_RDM_STRING_LENGTH];
93 std::string m_description;
131 return sizeof(description_s);
135 uint8_t *data)
const;
139 struct description_s {
142 char description[MAX_RDM_STRING_LENGTH];
145 uint32_t m_frequency;
146 std::string m_description;
158 template <
class SettingType>
167 unsigned int arg_count,
168 bool zero_offset =
false)
169 : m_zero_offset(zero_offset) {
170 for (
unsigned int i = 0; i < arg_count; i++) {
171 m_settings.push_back(SettingType(args[i]));
175 uint8_t Count()
const {
return m_settings.size(); }
177 const SettingType *Lookup(uint8_t index)
const {
178 if (index > m_settings.size()) {
181 return &m_settings[index];
184 unsigned int Offset()
const {
185 return m_zero_offset ? 0 : 1;
192 std::vector<SettingType> m_settings;
193 const bool m_zero_offset;
200 template <
class SettingType>
204 : m_settings(settings),
205 m_current_setting(settings->Offset()) {
214 uint8_t Count()
const {
215 return m_settings->Count();
218 uint8_t CurrentSetting()
const {
219 return m_current_setting + m_settings->Offset();
222 bool ChangeSetting(uint8_t state);
226 uint8_t m_current_setting;
232 template <
class SettingType>
234 uint16_t data = ((m_current_setting + m_settings->Offset()) << 8 |
235 m_settings->Count());
236 if (m_settings->Offset() == 0) {
240 return ResponderHelper::GetUInt16Value(request, data);
243 template <
class SettingType>
246 if (!ResponderHelper::ExtractUInt8(request, &arg)) {
250 unsigned int offset = m_settings->Offset();
251 if (arg < offset || arg >= m_settings->Count() + offset) {
254 m_current_setting = arg - offset;
255 return ResponderHelper::EmptySetResponse(request);
259 template <
class SettingType>
263 if (!ResponderHelper::ExtractUInt8(request, &arg)) {
267 unsigned int offset = m_settings->Offset();
269 if (arg == 0 || arg >= m_settings->Count() + offset) {
272 const SettingType *setting = m_settings->Lookup(arg - offset);
274 setting->DescriptionResponseSize()];
275 unsigned int size = setting->GenerateDescriptionResponse(arg, output);
280 template <
class SettingType>
282 uint8_t offset = m_settings->Offset();
284 if (new_setting < offset || new_setting >= m_settings->Count() + offset)
287 m_current_setting = new_setting - offset;
292 #endif // INCLUDE_OLA_RDM_RESPONDERSETTINGS_H_ Definition: ResponderSettings.h:201
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition: RDMCommand.h:457
RDMResponse * GetResponseFromData(const RDMRequest *request, const uint8_t *data, unsigned int length, rdm_response_type type, uint8_t outstanding_messages)
Generate an ACK Response with some data.
Definition: RDMCommand.cpp:595
#define PACK(__Declaration__)
Pack structures.
Definition: Macro.h:170
std::string Description() const
The text description of this setting.
Definition: ResponderSettings.h:77
uint32_t frequency
Definition: ResponderSettings.h:107
virtual std::string Description() const =0
The text description of this setting.
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:234
RDMResponse * NackWithReason(const RDMRequest *request, rdm_nack_reason reason_enum, uint8_t outstanding_messages)
Generate a NACK response with a reason code.
Definition: RDMCommand.cpp:583
virtual unsigned int GenerateDescriptionResponse(uint8_t index, uint8_t *data) const =0
Populate the _DESCRIPTION parameter data.
unsigned int DescriptionResponseSize() const
Return the size of the _DESCRIPTION parameter data.
Definition: ResponderSettings.h:79
A Setting which has a description and no other properties.
Definition: ResponderSettings.h:63
The constructor argument for the FrequencyModulationSetting.
Definition: ResponderSettings.h:106
const char * description
Definition: ResponderSettings.h:108
The base class all Settings inherit from.
Definition: ResponderSettings.h:36
unsigned int DescriptionResponseSize() const
Return the size of the _DESCRIPTION parameter data.
Definition: ResponderSettings.h:130
Holds the list of settings for a class of responder. A single instance is shared between all responde...
Definition: ResponderSettings.h:159
SettingCollection(const typename SettingType::ArgType args[], unsigned int arg_count, bool zero_offset=false)
Definition: ResponderSettings.h:166
std::string Description() const
The text description of this setting.
Definition: ResponderSettings.h:123
Helper methods for building RDM responders.
virtual unsigned int DescriptionResponseSize() const =0
Return the size of the _DESCRIPTION parameter data.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
uint32_t Frequency() const
returns the frequency for this setting.
Definition: ResponderSettings.h:128
A PWM Frequency Setting. See Section 4.10 of E1.37-1.
Definition: ResponderSettings.h:101
Classes that represent RDM commands.