AP_RangeFinder: add build option for Rangefinders

This commit is contained in:
Henry Wurzburg 2022-03-07 22:04:15 -06:00 committed by Tom Pittenger
parent e07e22c0fe
commit 8ab92f42cd
2 changed files with 14 additions and 3 deletions

View File

@ -339,6 +339,7 @@ bool RangeFinder::_add_backend(AP_RangeFinder_Backend *backend, uint8_t instance
*/
void RangeFinder::detect_instance(uint8_t instance, uint8_t& serial_instance)
{
#if AP_RANGEFINDER_ENABLED
const Type _type = (Type)params[instance].type.get();
switch (_type) {
case Type::PLI2C:
@ -583,7 +584,7 @@ void RangeFinder::detect_instance(uint8_t instance, uint8_t& serial_instance)
case Type::Benewake_CAN:
_add_backend(new AP_RangeFinder_Benewake_CAN(state[instance], params[instance]), instance);
break;
#endif
#endif //HAL_MAX_CAN_PROTOCOL_DRIVERS
case Type::NONE:
default:
break;
@ -597,6 +598,7 @@ void RangeFinder::detect_instance(uint8_t instance, uint8_t& serial_instance)
// param count could have changed
AP_Param::invalidate_count();
}
#endif //AP_RANGEFINDER_ENABLED
}
AP_RangeFinder_Backend *RangeFinder::get_backend(uint8_t id) const {
@ -841,3 +843,4 @@ RangeFinder *rangefinder()
}
}

View File

@ -21,9 +21,17 @@
#include <AP_MSP/msp.h>
#include "AP_RangeFinder_Params.h"
#ifndef AP_RANGEFINDER_ENABLED
#define AP_RANGEFINDER_ENABLED 1
#endif
// Maximum number of range finder instances available on this platform
#ifndef RANGEFINDER_MAX_INSTANCES
#define RANGEFINDER_MAX_INSTANCES 10
#ifndef RANGEFINDER_MAX_INSTANCES
#if AP_RANGEFINDER_ENABLED
#define RANGEFINDER_MAX_INSTANCES 10
#else
#define RANGEFINDER_MAX_INSTANCES 1
#endif
#endif
#define RANGEFINDER_GROUND_CLEARANCE_CM_DEFAULT 10