From 2e4c0c3156c72eb2f1ef99008a77fbce939a790e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 15 Feb 2015 16:17:13 +0100 Subject: sensors app: Comment handling of old param values properly --- src/modules/sensors/sensors.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index 666025c71..9a90c84e0 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -1519,16 +1519,23 @@ Sensors::parameter_update_poll(bool forced) int32_t mag_rot = 0; param_get(param_find(str), &mag_rot); - /* handling of old setups, will be removed */ - if (s == 0) { - int32_t deprecated_mag_rot = 0; - param_get(param_find("SENS_EXT_MAG_ROT"), &deprecated_mag_rot); - - /* if the old param is non-zero, set the new one to the same value */ - if ((deprecated_mag_rot != 0) && (mag_rot <= 0)) { - mag_rot = deprecated_mag_rot; - param_set_no_notification(param_find(str), &mag_rot); - } + /* handling of old setups, will be removed later (noted Feb 2015) */ + int32_t deprecated_mag_rot = 0; + param_get(param_find("SENS_EXT_MAG_ROT"), &deprecated_mag_rot); + + /* + * If the deprecated parameter is non-default (is != 0), + * and the new parameter is default (is == 0), then this board + * was configured already and we need to copy the old value + * to the new parameter. + * The < 0 case is special: It means that this param slot was + * used previously by an internal sensor, but the the call above + * proved that it is currently occupied by an external sensor. + * In that case we consider the orientation to be default as well. + */ + if ((deprecated_mag_rot != 0) && (mag_rot <= 0)) { + mag_rot = deprecated_mag_rot; + param_set_no_notification(param_find(str), &mag_rot); } /* handling of transition from internal to external */ -- cgit v1.2.3