diff --git a/libraries/AP_Mount/AP_Mount.cpp b/libraries/AP_Mount/AP_Mount.cpp index 9ae07b70dc..f6d8a45688 100644 --- a/libraries/AP_Mount/AP_Mount.cpp +++ b/libraries/AP_Mount/AP_Mount.cpp @@ -443,8 +443,10 @@ void AP_Mount::init() // check for servo mounts if (mount_type == Mount_Type_Servo) { +#if HAL_MOUNT_SERVO_ENABLED _backends[instance] = new AP_Mount_Servo(*this, state[instance], instance); _num_instances++; +#endif #if HAL_SOLO_GIMBAL_ENABLED // check for MAVLink mounts diff --git a/libraries/AP_Mount/AP_Mount_Servo.cpp b/libraries/AP_Mount/AP_Mount_Servo.cpp index a5314daa82..ce9934466f 100644 --- a/libraries/AP_Mount/AP_Mount_Servo.cpp +++ b/libraries/AP_Mount/AP_Mount_Servo.cpp @@ -1,5 +1,5 @@ #include "AP_Mount_Servo.h" -#if HAL_MOUNT_ENABLED +#if HAL_MOUNT_SERVO_ENABLED extern const AP_HAL::HAL& hal; @@ -221,4 +221,4 @@ void AP_Mount_Servo::move_servo(uint8_t function_idx, int16_t angle, int16_t ang int16_t servo_out = closest_limit(angle, angle_min, angle_max); SRV_Channels::move_servo((SRV_Channel::Aux_servo_function_t)function_idx, servo_out, angle_min, angle_max); } -#endif // HAL_MOUNT_ENABLED +#endif // HAL_MOUNT_SERVO_ENABLED diff --git a/libraries/AP_Mount/AP_Mount_Servo.h b/libraries/AP_Mount/AP_Mount_Servo.h index f5ce1b28c4..28708a090c 100644 --- a/libraries/AP_Mount/AP_Mount_Servo.h +++ b/libraries/AP_Mount/AP_Mount_Servo.h @@ -3,13 +3,19 @@ */ #pragma once +#include "AP_Mount_Backend.h" + +#ifndef HAL_MOUNT_SERVO_ENABLED +#define HAL_MOUNT_SERVO_ENABLED HAL_MOUNT_ENABLED +#endif + +#if HAL_MOUNT_SERVO_ENABLED + #include #include #include #include #include -#include "AP_Mount_Backend.h" -#if HAL_MOUNT_ENABLED class AP_Mount_Servo : public AP_Mount_Backend { @@ -71,4 +77,4 @@ private: uint32_t _last_check_servo_map_ms; // system time of latest call to check_servo_map function }; -#endif // HAL_MOUNT_ENABLED +#endif // HAL_MOUNT_SERVO_ENABLED