44 #include <parameters/px4_parameters_public.h> 49 inline static param_t param_handle(px4::params p)
57 #define _DEFINE_SINGLE_PARAMETER(x) \ 58 do_not_explicitly_use_this_namespace::PAIR(x); 60 #define _CALL_UPDATE(x) \ 65 #define _DEFINE_PARAMETER_UPDATE_METHOD(...) \ 67 void updateParamsImpl() final { \ 68 APPLY_ALL(_CALL_UPDATE, __VA_ARGS__) \ 78 #define DEFINE_PARAMETERS(...) \ 79 APPLY_ALL(_DEFINE_SINGLE_PARAMETER, __VA_ARGS__) \ 80 _DEFINE_PARAMETER_UPDATE_METHOD(__VA_ARGS__) 83 #define _DEFINE_PARAMETER_UPDATE_METHOD_CUSTOM_PARENT(parent_class, ...) \ 85 void updateParamsImpl() override { \ 86 parent_class::updateParamsImpl(); \ 87 APPLY_ALL(_CALL_UPDATE, __VA_ARGS__) \ 91 #define DEFINE_PARAMETERS_CUSTOM_PARENT(parent_class, ...) \ 92 APPLY_ALL(_DEFINE_SINGLE_PARAMETER, __VA_ARGS__) \ 93 _DEFINE_PARAMETER_UPDATE_METHOD_CUSTOM_PARENT(parent_class, __VA_ARGS__) 103 template<
typename T, px4::params p>
110 template<px4::params p>
115 static_assert(px4::param_types_array[(
int)p] == PARAM_TYPE_FLOAT,
"parameter type must be float");
123 float get()
const {
return _val; }
125 const float &reference()
const {
return _val; }
133 void set(
float val) { _val = val; }
135 bool update() {
return param_get(handle(), &_val) == 0; }
137 param_t handle()
const {
return param_handle(p); }
143 template<px4::params p>
148 static_assert(px4::param_types_array[(
int)p] == PARAM_TYPE_FLOAT,
"parameter type must be float");
150 Param(
float &external_val)
157 float get()
const {
return _val; }
159 const float &reference()
const {
return _val; }
167 void set(
float val) { _val = val; }
169 bool update() {
return param_get(handle(), &_val) == 0; }
171 param_t handle()
const {
return param_handle(p); }
176 template<px4::params p>
181 static_assert(px4::param_types_array[(
int)p] ==
PARAM_TYPE_INT32,
"parameter type must be int32_t");
189 int32_t
get()
const {
return _val; }
191 const int32_t &reference()
const {
return _val; }
199 void set(int32_t val) { _val = val; }
201 bool update() {
return param_get(handle(), &_val) == 0; }
203 param_t handle()
const {
return param_handle(p); }
209 template<px4::params p>
214 static_assert(px4::param_types_array[(
int)p] ==
PARAM_TYPE_INT32,
"parameter type must be int32_t");
216 Param(int32_t &external_val)
223 int32_t
get()
const {
return _val; }
225 const int32_t &reference()
const {
return _val; }
233 void set(int32_t val) { _val = val; }
235 bool update() {
return param_get(handle(), &_val) == 0; }
237 param_t handle()
const {
return param_handle(p); }
242 template<px4::params p>
247 static_assert(px4::param_types_array[(
int)p] ==
PARAM_TYPE_INT32,
"parameter type must be int32_t");
255 bool get()
const {
return _val; }
257 const bool &reference()
const {
return _val; }
262 int32_t value_int = (int32_t)_val;
263 return param_set(handle(), &value_int) == 0;
269 int32_t value_int = (int32_t)_val;
273 void set(
bool val) { _val = val; }
278 int ret =
param_get(handle(), &value_int);
281 _val = value_int != 0;
288 param_t handle()
const {
return param_handle(p); }
293 template <px4::params p>
296 template <px4::params p>
299 template <px4::params p>
302 template <px4::params p>
305 template <px4::params p>
312 template<px4::params p>
315 static_assert((
int)p &&
false,
"Do not use this class directly, use the DEFINE_PARAMETERS macro instead");
317 template<px4::params p>
320 static_assert((
int)p &&
false,
"Do not use this class directly, use the DEFINE_PARAMETERS macro instead");
bool commit_no_notification() const
Store the parameter value to the parameter storage, w/o notifying the system (.
Definition: px4_param.h:131
Definition: px4_param.h:313
Definition: px4_param.h:243
#define PARAM_TYPE_INT32
Parameter types.
Definition: param.h:60
__EXPORT int param_get(param_t param, void *val)
Copy the value of a parameter.
Definition: parameters.cpp:587
__EXPORT int param_set_no_notification(param_t param, const void *val)
Set the value of a parameter, but do not notify the system about the change.
Definition: parameters.cpp:803
__EXPORT int param_set(param_t param, const void *val)
Set the value of a parameter.
Definition: parameters.cpp:797
bool commit_no_notification() const
Store the parameter value to the parameter storage, w/o notifying the system (.
Definition: px4_param.h:165
bool commit_no_notification() const
Store the parameter value to the parameter storage, w/o notifying the system (.
Definition: px4_param.h:231
__EXPORT void param_set_used(param_t param)
Mark a parameter as used.
Definition: parameters.cpp:821
bool commit_no_notification() const
Store the parameter value to the parameter storage, w/o notifying the system (.
Definition: px4_param.h:197
Definition: px4_param.h:111
bool commit() const
Store the parameter value to the parameter storage (.
Definition: px4_param.h:260
Definition: px4_param.h:210
Definition: px4_param.h:177
Definition: px4_param.h:318
bool commit() const
Store the parameter value to the parameter storage (.
Definition: px4_param.h:128
Definition: px4_param.h:100
Definition: px4_param.h:104
Helper macros used by px4_param.h.
bool commit() const
Store the parameter value to the parameter storage (.
Definition: px4_param.h:228
bool commit() const
Store the parameter value to the parameter storage (.
Definition: px4_param.h:194
bool commit_no_notification() const
Store the parameter value to the parameter storage, w/o notifying the system (.
Definition: px4_param.h:267
Definition: px4_param.h:144
bool commit() const
Store the parameter value to the parameter storage (.
Definition: px4_param.h:162
uint32_t param_t
Parameter handle.
Definition: param.h:98