add param api also for firmware builds

This commit is contained in:
Thomas Gubler
2015-02-08 17:53:26 +01:00
parent 69f5726d70
commit bc8efeb73e
+38 -4
View File
@@ -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;
} }