Browse Source

AP_Proximity: Remove primary_instance

master
rishabsingh3003 2 years ago committed by Andrew Tridgell
parent
commit
6e603418eb
  1. 11
      libraries/AP_Proximity/AP_Proximity.cpp
  2. 1
      libraries/AP_Proximity/AP_Proximity.h

11
libraries/AP_Proximity/AP_Proximity.cpp

@ -213,13 +213,6 @@ void AP_Proximity::update()
// check if any face has valid distance when it should not // check if any face has valid distance when it should not
boundary.check_face_timeout(); boundary.check_face_timeout();
// work out primary instance - first sensor returning good data
for (int8_t i=num_instances-1; i>=0; i--) {
if (drivers[i] != nullptr && (state[i].status == Status::Good)) {
primary_instance = i;
}
}
} }
AP_Proximity::Type AP_Proximity::get_type(uint8_t instance) const AP_Proximity::Type AP_Proximity::get_type(uint8_t instance) const
@ -372,7 +365,7 @@ bool AP_Proximity::sensor_present() const
bool AP_Proximity::sensor_enabled() const bool AP_Proximity::sensor_enabled() const
{ {
// check atleast one sensor is enabled // check atleast one sensor is enabled
return get_type(primary_instance) != Type::None; return (num_instances > 0);
} }
bool AP_Proximity::sensor_failed() const bool AP_Proximity::sensor_failed() const
@ -395,7 +388,7 @@ bool AP_Proximity::get_upward_distance(float &distance) const
// get upward distance from backend // get upward distance from backend
for (uint8_t i=0; i<num_instances; i++) { for (uint8_t i=0; i<num_instances; i++) {
// return first good upward distance // return first good upward distance
if (get_upward_distance(primary_instance, distance)) { if (get_upward_distance(i, distance)) {
return true; return true;
} }
} }

1
libraries/AP_Proximity/AP_Proximity.h

@ -167,7 +167,6 @@ private:
static AP_Proximity *_singleton; static AP_Proximity *_singleton;
Proximity_State state[PROXIMITY_MAX_INSTANCES]; Proximity_State state[PROXIMITY_MAX_INSTANCES];
AP_Proximity_Backend *drivers[PROXIMITY_MAX_INSTANCES]; AP_Proximity_Backend *drivers[PROXIMITY_MAX_INSTANCES];
uint8_t primary_instance;
uint8_t num_instances; uint8_t num_instances;
// return true if the given instance exists // return true if the given instance exists

Loading…
Cancel
Save