ets_airspeed: cope with zero value from ETS airspeed sensor

This commit is contained in:
Andrew Tridgell 2013-07-29 07:42:23 +10:00 committed by Lorenz Meier
parent 043dc4e225
commit dad76c56c6
1 changed files with 8 additions and 0 deletions

View File

@ -157,6 +157,14 @@ ETSAirspeed::collect()
}
uint16_t diff_pres_pa = val[1] << 8 | val[0];
if (diff_pres_pa == 0) {
// a zero value means the pressure sensor cannot give us a
// value. We need to return, and not report a value or the
// caller could end up using this value as part of an
// average
log("zero value from sensor");
return -1;
}
if (diff_pres_pa < _diff_pres_offset + MIN_ACCURATE_DIFF_PRES_PA) {
diff_pres_pa = 0;