mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 16:53:33 +08:00
add param api also for firmware builds
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#else
|
#else
|
||||||
/* includes when building for NuttX */
|
/* includes when building for NuttX */
|
||||||
|
#include <systemlib/param/param.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace px4
|
namespace px4
|
||||||
@@ -96,7 +97,6 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the parameter value
|
* Update the parameter value
|
||||||
* Nothing to do for ROS
|
|
||||||
*/
|
*/
|
||||||
T update()
|
T update()
|
||||||
{
|
{
|
||||||
@@ -113,11 +113,45 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
template <typename T>
|
||||||
|
class Parameter :
|
||||||
|
public ParameterBase<T>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Parameter(const char *name, T value) :
|
||||||
|
ParameterBase<T>(name, value),
|
||||||
|
_handle(param_find(name))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~Parameter() {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the parameter value
|
||||||
|
*/
|
||||||
|
T update()
|
||||||
|
{
|
||||||
|
if (_handle != PARAM_INVALID) {
|
||||||
|
param_get(_handle, &(this->_value));
|
||||||
|
}
|
||||||
|
return get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current parameter value
|
||||||
|
*/
|
||||||
|
T get()
|
||||||
|
{
|
||||||
|
return this->_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
param_t _handle;
|
||||||
|
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef Parameter<double> ParameterFloat;
|
typedef Parameter<float> ParameterFloat;
|
||||||
typedef Parameter<int> ParameterInt;
|
typedef Parameter<int> ParameterInt;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user