Sensors app: Stop the bad habit of params per board

This commit is contained in:
Lorenz Meier
2015-10-03 13:13:55 +02:00
parent e0702ce48d
commit 4f5e50396c
2 changed files with 11 additions and 24 deletions
+1 -24
View File
@@ -1807,36 +1807,13 @@ PARAM_DEFINE_INT32(RC_DSM_BIND, -1);
*/
PARAM_DEFINE_INT32(BAT_V_SCALE_IO, 10000);
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2
/**
* Scaling factor for battery voltage sensor on FMU v2.
*
* @board CONFIG_ARCH_BOARD_PX4FMU_V2
* @group Battery Calibration
*/
PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.0082f);
#elif CONFIG_ARCH_BOARD_AEROCORE
/**
* Scaling factor for battery voltage sensor on AeroCore.
*
* For R70 = 133K, R71 = 10K --> scale = 1.8 * 143 / (4096*10) = 0.0063
*
* @board CONFIG_ARCH_BOARD_AEROCORE
* @group Battery Calibration
*/
PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.0063f);
#else
/**
* Scaling factor for battery voltage sensor on FMU v1.
*
* FMUv1 standalone: 1/(10 / (47+10)) * (3.3 / 4095) = 0.00459340659
* FMUv1 with PX4IO: 0.00459340659
* FMUv1 with PX4IOAR: (3.3f * 52.0f / 5.0f / 4095.0f) = 0.00838095238
*
* @group Battery Calibration
*/
PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.00459340659f);
#endif
PARAM_DEFINE_FLOAT(BAT_V_SCALING, -1.0f);
/**
* Scaling factor for battery current sensor.
+10
View File
@@ -825,6 +825,16 @@ Sensors::parameters_update()
/* scaling of ADC ticks to battery voltage */
if (param_get(_parameter_handles.battery_voltage_scaling, &(_parameters.battery_voltage_scaling)) != OK) {
warnx("%s", paramerr);
} else if (_parameters.battery_voltage_scaling < 0.0f) {
/* apply scaling according to defaults if set to default */
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2
_parameters.battery_voltage_scaling = 0.0082f;
#elif CONFIG_ARCH_BOARD_AEROCORE
_parameters.battery_voltage_scaling = 0.0063f;
#else
_parameters.battery_voltage_scaling = 0.00459340659f;
#endif
}
/* scaling of ADC ticks to battery current */