diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-12 22:41:32 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-12 22:41:32 +0100 |
commit | 15b61d4c15730c7a3e832a47f454ec7398303b55 (patch) | |
tree | f1a461dc85e2148cde2b1b1161c93851c3ee15e5 /apps/sensors/sensors.cpp | |
parent | 6c1b00e22fca4272c0cd3b861074893d351fe903 (diff) | |
download | px4-firmware-15b61d4c15730c7a3e832a47f454ec7398303b55.tar.gz px4-firmware-15b61d4c15730c7a3e832a47f454ec7398303b55.tar.bz2 px4-firmware-15b61d4c15730c7a3e832a47f454ec7398303b55.zip |
Improved battery voltage init, removed bogus printf() from debugging
Diffstat (limited to 'apps/sensors/sensors.cpp')
-rw-r--r-- | apps/sensors/sensors.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/sensors/sensors.cpp b/apps/sensors/sensors.cpp index 8b5c66b4f..577dc483b 100644 --- a/apps/sensors/sensors.cpp +++ b/apps/sensors/sensors.cpp @@ -994,6 +994,11 @@ Sensors::adc_poll(struct sensor_combined_s &raw) if (voltage > VOLTAGE_BATTERY_IGNORE_THRESHOLD_VOLTS) { + /* one-time initialization of low-pass value to avoid long init delays */ + if (_battery_status.voltage_v < 3.0f) { + _battery_status.voltage_v = voltage; + } + _battery_status.timestamp = hrt_absolute_time(); _battery_status.voltage_v = (BAT_VOL_LOWPASS_1 * (_battery_status.voltage_v + BAT_VOL_LOWPASS_2 * voltage));; /* current and discharge are unknown */ @@ -1003,7 +1008,6 @@ Sensors::adc_poll(struct sensor_combined_s &raw) /* announce the battery voltage if needed, just publish else */ if (_battery_pub > 0) { orb_publish(ORB_ID(battery_status), _battery_pub, &_battery_status); - printf("DBG: ADC PUB: %d, val: %d\n", ret, (int)(buf_adc[0].am_data)); } else { _battery_pub = orb_advertise(ORB_ID(battery_status), &_battery_status); |