Browse Source

AP_Airspeed: added get_num_sensors()

c415-sdk
Andrew Tridgell 6 years ago
parent
commit
505953bdb2
  1. 3
      libraries/AP_Airspeed/AP_Airspeed.cpp
  2. 6
      libraries/AP_Airspeed/AP_Airspeed.h

3
libraries/AP_Airspeed/AP_Airspeed.cpp

@ -333,6 +333,9 @@ void AP_Airspeed::init()
delete sensor[i]; delete sensor[i];
sensor[i] = nullptr; sensor[i] = nullptr;
} }
if (sensor[i] != nullptr) {
num_sensors = i+1;
}
} }
} }

6
libraries/AP_Airspeed/AP_Airspeed.h

@ -161,6 +161,9 @@ public:
// get current primary sensor // get current primary sensor
uint8_t get_primary(void) const { return primary; } uint8_t get_primary(void) const { return primary; }
// get number of sensors
uint8_t get_num_sensors(void) const { return num_sensors; }
static AP_Airspeed *get_singleton() { return _singleton; } static AP_Airspeed *get_singleton() { return _singleton; }
// return the current corrected pressure, public for AP_Periph // return the current corrected pressure, public for AP_Periph
@ -226,7 +229,8 @@ private:
// current primary sensor // current primary sensor
uint8_t primary; uint8_t primary;
uint8_t num_sensors;
void read(uint8_t i); void read(uint8_t i);
// return the differential pressure in Pascal for the last airspeed reading for the requested instance // return the differential pressure in Pascal for the last airspeed reading for the requested instance
// returns 0 if the sensor is not enabled // returns 0 if the sensor is not enabled

Loading…
Cancel
Save