AP_DAL: add and use AP_BEACON_ENABLED

This commit is contained in:
Peter Barker 2022-01-28 11:09:43 +11:00 committed by Peter Barker
parent 88e164aed3
commit 67986e8402
4 changed files with 21 additions and 3 deletions

View File

@ -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();

View File

@ -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

View File

@ -1,6 +1,6 @@
#include "AP_DAL_Beacon.h"
#include <AP_Beacon/AP_Beacon.h>
#if AP_BEACON_ENABLED
#include <AP_Logger/AP_Logger.h>
#include "AP_DAL.h"
@ -47,3 +47,5 @@ void AP_DAL_Beacon::start_frame()
WRITE_REPLAY_BLOCK_IFCHANGED(RBCI, RBCI, old_RBCI);
}
}
#endif

View File

@ -1,9 +1,11 @@
#pragma once
#include <AP_Logger/LogStructure.h>
#include <AP_Beacon/AP_Beacon.h>
#if AP_BEACON_ENABLED
#include <AP_Logger/LogStructure.h>
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