From 67986e840220a4eccba4d6602f999dc0b995d61f Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 28 Jan 2022 11:09:43 +1100 Subject: [PATCH] AP_DAL: add and use AP_BEACON_ENABLED --- libraries/AP_DAL/AP_DAL.cpp | 4 ++++ libraries/AP_DAL/AP_DAL.h | 8 ++++++++ libraries/AP_DAL/AP_DAL_Beacon.cpp | 4 +++- libraries/AP_DAL/AP_DAL_Beacon.h | 8 ++++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libraries/AP_DAL/AP_DAL.cpp b/libraries/AP_DAL/AP_DAL.cpp index 706cb6ac23..7cb4545275 100644 --- a/libraries/AP_DAL/AP_DAL.cpp +++ b/libraries/AP_DAL/AP_DAL.cpp @@ -85,9 +85,11 @@ void AP_DAL::start_frame(AP_DAL::FrameType frametype) if (_rangefinder) { _rangefinder->start_frame(); } +#if AP_BEACON_ENABLED if (_beacon) { _beacon->start_frame(); } +#endif #if HAL_VISUALODOM_ENABLED if (_visualodom) { _visualodom->start_frame(); @@ -136,10 +138,12 @@ void AP_DAL::init_sensors(void) } #endif +#if AP_BEACON_ENABLED auto *bcn = AP::beacon(); if (bcn != nullptr && bcn->enabled()) { alloc_failed |= (_beacon = new AP_DAL_Beacon) == nullptr; } +#endif #if HAL_VISUALODOM_ENABLED auto *vodom = AP::visualodom(); diff --git a/libraries/AP_DAL/AP_DAL.h b/libraries/AP_DAL/AP_DAL.h index 4c0c945540..53719089f5 100644 --- a/libraries/AP_DAL/AP_DAL.h +++ b/libraries/AP_DAL/AP_DAL.h @@ -135,9 +135,11 @@ public: AP_DAL_Airspeed *airspeed() { return _airspeed; } +#if AP_BEACON_ENABLED AP_DAL_Beacon *beacon() { return _beacon; } +#endif #if HAL_VISUALODOM_ENABLED AP_DAL_VisualOdom *visualodom() { return _visualodom; @@ -287,16 +289,20 @@ public: } void handle_message(const log_RBCH &msg) { +#if AP_BEACON_ENABLED if (_beacon == nullptr) { _beacon = new AP_DAL_Beacon; } _beacon->handle_message(msg); +#endif } void handle_message(const log_RBCI &msg) { +#if AP_BEACON_ENABLED if (_beacon == nullptr) { _beacon = new AP_DAL_Beacon; } _beacon->handle_message(msg); +#endif } void handle_message(const log_RVOH &msg) { #if HAL_VISUALODOM_ENABLED @@ -349,7 +355,9 @@ private: AP_DAL_RangeFinder *_rangefinder; AP_DAL_Compass _compass; AP_DAL_Airspeed *_airspeed; +#if AP_BEACON_ENABLED AP_DAL_Beacon *_beacon; +#endif #if HAL_VISUALODOM_ENABLED AP_DAL_VisualOdom *_visualodom; #endif diff --git a/libraries/AP_DAL/AP_DAL_Beacon.cpp b/libraries/AP_DAL/AP_DAL_Beacon.cpp index e1a1f34d03..a1d661ea5d 100644 --- a/libraries/AP_DAL/AP_DAL_Beacon.cpp +++ b/libraries/AP_DAL/AP_DAL_Beacon.cpp @@ -1,6 +1,6 @@ #include "AP_DAL_Beacon.h" -#include +#if AP_BEACON_ENABLED #include #include "AP_DAL.h" @@ -47,3 +47,5 @@ void AP_DAL_Beacon::start_frame() WRITE_REPLAY_BLOCK_IFCHANGED(RBCI, RBCI, old_RBCI); } } + +#endif diff --git a/libraries/AP_DAL/AP_DAL_Beacon.h b/libraries/AP_DAL/AP_DAL_Beacon.h index 73a4fcc83a..b494d79476 100644 --- a/libraries/AP_DAL/AP_DAL_Beacon.h +++ b/libraries/AP_DAL/AP_DAL_Beacon.h @@ -1,9 +1,11 @@ #pragma once -#include - #include +#if AP_BEACON_ENABLED + +#include + class AP_DAL_Beacon { public: @@ -73,3 +75,5 @@ private: struct log_RBCH _RBCH; struct log_RBCI _RBCI[AP_BEACON_MAX_BEACONS]; }; + +#endif // AP_BEACON_ENABLED