aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2015-02-08 12:35:10 +0100
committerThomas Gubler <thomasgubler@gmail.com>2015-02-08 17:53:25 +0100
commit69f5726d7027ef45ccbb1a568ff33e91bd742654 (patch)
tree97f99fa7799c0f4fe9f2721e96c4750dcbb95d66
parentdf5ad88df7d925278356f9480a0c2418c0316c9d (diff)
downloadpx4-firmware-69f5726d7027ef45ccbb1a568ff33e91bd742654.tar.gz
px4-firmware-69f5726d7027ef45ccbb1a568ff33e91bd742654.tar.bz2
px4-firmware-69f5726d7027ef45ccbb1a568ff33e91bd742654.zip
make subscriber example use the new param api
-rw-r--r--src/examples/subscriber/subscriber_example.cpp24
-rw-r--r--src/examples/subscriber/subscriber_example.h7
2 files changed, 14 insertions, 17 deletions
diff --git a/src/examples/subscriber/subscriber_example.cpp b/src/examples/subscriber/subscriber_example.cpp
index e1292f788..496e1dcd8 100644
--- a/src/examples/subscriber/subscriber_example.cpp
+++ b/src/examples/subscriber/subscriber_example.cpp
@@ -49,20 +49,18 @@ void rc_channels_callback_function(const px4_rc_channels &msg) {
SubscriberExample::SubscriberExample() :
_n(),
- _p_sub_interv(PX4_PARAM_INIT(SUB_INTERV)),
- _interval(0),
- _p_test_float(PX4_PARAM_INIT(SUB_TESTF)),
- _test_float(0.0f)
+ _p_sub_interv("SUB_INTERV", PARAM_SUB_INTERV_DEFAULT),
+ _p_test_float("SUB_TESTF", PARAM_SUB_TESTF_DEFAULT)
{
/* Read the parameter back as example */
- PX4_PARAM_GET(_p_sub_interv, &_interval);
- PX4_INFO("Param SUB_INTERV = %d", _interval);
- PX4_PARAM_GET(_p_test_float, &_test_float);
- PX4_INFO("Param SUB_TESTF = %.3f", (double)_test_float);
+ _p_sub_interv.update();
+ _p_test_float.update();
+ PX4_INFO("Param SUB_INTERV = %d", _p_sub_interv.get());
+ PX4_INFO("Param SUB_TESTF = %.3f", (double)_p_test_float.get());
/* Do some subscriptions */
/* Function */
- _n.subscribe<px4_rc_channels>(rc_channels_callback_function, _interval);
+ _n.subscribe<px4_rc_channels>(rc_channels_callback_function, _p_sub_interv.get());
/* No callback */
_sub_rc_chan = _n.subscribe<px4_rc_channels>(500);
@@ -98,8 +96,8 @@ void SubscriberExample::vehicle_attitude_callback(const px4_vehicle_attitude &ms
void SubscriberExample::parameter_update_callback(const px4_parameter_update &msg) {
PX4_INFO("parameter_update_callback (method): [%llu]",
msg.data().timestamp);
- PX4_PARAM_GET(_p_sub_interv, &_interval);
- PX4_INFO("Param SUB_INTERV = %d", _interval);
- PX4_PARAM_GET(_p_test_float, &_test_float);
- PX4_INFO("Param SUB_TESTF = %.3f", (double)_test_float);
+ _p_sub_interv.update();
+ PX4_INFO("Param SUB_INTERV = %d", _p_sub_interv.get());
+ _p_test_float.update();
+ PX4_INFO("Param SUB_TESTF = %.3f", (double)_p_test_float.get());
}
diff --git a/src/examples/subscriber/subscriber_example.h b/src/examples/subscriber/subscriber_example.h
index 9b6d890e3..686fed023 100644
--- a/src/examples/subscriber/subscriber_example.h
+++ b/src/examples/subscriber/subscriber_example.h
@@ -52,12 +52,11 @@ public:
void spin() {_n.spin();}
protected:
px4::NodeHandle _n;
- px4_param_t _p_sub_interv;
- int32_t _interval;
- px4_param_t _p_test_float;
- float _test_float;
+ px4::ParameterInt _p_sub_interv;
+ px4::ParameterFloat _p_test_float;
px4::Subscriber<px4_rc_channels> * _sub_rc_chan;
+
void rc_channels_callback(const px4_rc_channels &msg);
void vehicle_attitude_callback(const px4_vehicle_attitude &msg);
void parameter_update_callback(const px4_parameter_update &msg);