Browse Source

AP_Baro: added all_healthy() method

mission-4.1.18
Andrew Tridgell 10 years ago
parent
commit
1c2a6deaaf
  1. 13
      libraries/AP_Baro/AP_Baro.cpp
  2. 3
      libraries/AP_Baro/AP_Baro.h

13
libraries/AP_Baro/AP_Baro.cpp

@ -329,3 +329,16 @@ uint8_t AP_Baro::register_sensor(void) @@ -329,3 +329,16 @@ uint8_t AP_Baro::register_sensor(void)
return _num_sensors++;
}
/*
check if all barometers are healthy
*/
bool AP_Baro::all_healthy(void) const
{
for (uint8_t i=0; i<_num_sensors; i++) {
if (!healthy(i)) {
return false;
}
}
return _num_sensors > 0;
}

3
libraries/AP_Baro/AP_Baro.h

@ -44,6 +44,9 @@ public: @@ -44,6 +44,9 @@ public:
bool healthy(void) const { return healthy(_primary); }
bool healthy(uint8_t instance) const { return sensors[instance].healthy && sensors[instance].alt_ok; }
// check if all baros are healthy - used for SYS_STATUS report
bool all_healthy(void) const;
// pressure in Pascal. Divide by 100 for millibars or hectopascals
float get_pressure(void) const { return get_pressure(_primary); }
float get_pressure(uint8_t instance) const { return sensors[instance].pressure; }

Loading…
Cancel
Save