AP_Proximity: Remove primary_instance

This commit is contained in:
rishabsingh3003 2022-08-24 03:12:42 +05:30 committed by Andrew Tridgell
parent 3a347374c8
commit 6e603418eb
2 changed files with 2 additions and 10 deletions

View File

@ -213,13 +213,6 @@ void AP_Proximity::update()
// check if any face has valid distance when it should not
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
@ -372,7 +365,7 @@ bool AP_Proximity::sensor_present() const
bool AP_Proximity::sensor_enabled() const
{
// check atleast one sensor is enabled
return get_type(primary_instance) != Type::None;
return (num_instances > 0);
}
bool AP_Proximity::sensor_failed() const
@ -395,7 +388,7 @@ bool AP_Proximity::get_upward_distance(float &distance) const
// get upward distance from backend
for (uint8_t i=0; i<num_instances; i++) {
// return first good upward distance
if (get_upward_distance(primary_instance, distance)) {
if (get_upward_distance(i, distance)) {
return true;
}
}

View File

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