diff --git a/platforms/common/include/px4_platform_common/param.h b/platforms/common/include/px4_platform_common/param.h index 21de1c8f3a..3a4a19410d 100644 --- a/platforms/common/include/px4_platform_common/param.h +++ b/platforms/common/include/px4_platform_common/param.h @@ -40,6 +40,8 @@ #pragma once #include "param_macros.h" +#include +#include #include @@ -130,6 +132,18 @@ public: /// Store the parameter value to the parameter storage, w/o notifying the system (@see param_set_no_notification()) bool commit_no_notification() const { return param_set_no_notification(handle(), &_val) == 0; } + /// Set and commit a new value. Returns true if the value changed. + bool commit_no_notification(float val) + { + if (fabsf(val - _val) > FLT_EPSILON) { + set(val); + commit_no_notification(); + return true; + } + + return false; + } + void set(float val) { _val = val; } void reset() @@ -170,6 +184,18 @@ public: /// Store the parameter value to the parameter storage, w/o notifying the system (@see param_set_no_notification()) bool commit_no_notification() const { return param_set_no_notification(handle(), &_val) == 0; } + /// Set and commit a new value. Returns true if the value changed. + bool commit_no_notification(float val) + { + if (fabsf(val - _val) > FLT_EPSILON) { + set(val); + commit_no_notification(); + return true; + } + + return false; + } + void set(float val) { _val = val; } void reset() @@ -208,6 +234,18 @@ public: /// Store the parameter value to the parameter storage, w/o notifying the system (@see param_set_no_notification()) bool commit_no_notification() const { return param_set_no_notification(handle(), &_val) == 0; } + /// Set and commit a new value. Returns true if the value changed. + bool commit_no_notification(int32_t val) + { + if (val != _val) { + set(val); + commit_no_notification(); + return true; + } + + return false; + } + void set(int32_t val) { _val = val; } void reset() @@ -248,6 +286,18 @@ public: /// Store the parameter value to the parameter storage, w/o notifying the system (@see param_set_no_notification()) bool commit_no_notification() const { return param_set_no_notification(handle(), &_val) == 0; } + /// Set and commit a new value. Returns true if the value changed. + bool commit_no_notification(int32_t val) + { + if (val != _val) { + set(val); + commit_no_notification(); + return true; + } + + return false; + } + void set(int32_t val) { _val = val; } void reset() @@ -294,6 +344,18 @@ public: return param_set_no_notification(handle(), &value_int) == 0; } + /// Set and commit a new value. Returns true if the value changed. + bool commit_no_notification(bool val) + { + if (val != _val) { + set(val); + commit_no_notification(); + return true; + } + + return false; + } + void set(bool val) { _val = val; } void reset()