AP_DAL: move structure used for location references into cpp

Outside we get a copy per compilation unit.
This commit is contained in:
Peter Barker 2020-11-14 09:14:48 +11:00 committed by Andrew Tridgell
parent 8c2c6141f7
commit 32ba55e756
2 changed files with 13 additions and 9 deletions

View File

@ -3,6 +3,9 @@
#include <AP_Logger/AP_Logger.h>
#include "AP_DAL.h"
// we use a static here as the "location" accessor wants to be const
static Location tmp_location[GPS_MAX_INSTANCES];
AP_DAL_GPS::AP_DAL_GPS()
{
for (uint8_t i=0; i<ARRAY_SIZE(_RGPI); i++) {
@ -11,6 +14,15 @@ AP_DAL_GPS::AP_DAL_GPS()
}
}
const Location &AP_DAL_GPS::location(uint8_t instance) const
{
Location &loc = tmp_location[instance];
loc.lat = _RGPJ[instance].lat;
loc.lng = _RGPJ[instance].lng;
loc.alt = _RGPJ[instance].alt;
return loc;
}
void AP_DAL_GPS::start_frame()
{
const auto &gps = AP::gps();

View File

@ -6,8 +6,6 @@
#include <AP_Vehicle/AP_Vehicle_Type.h>
static Location tmp_location[GPS_MAX_INSTANCES];
class AP_DAL_GPS {
public:
@ -30,13 +28,7 @@ public:
GPS_Status status() const {
return status(primary_sensor());
}
const Location &location(uint8_t instance) const {
Location &loc = tmp_location[instance];
loc.lat = _RGPJ[instance].lat;
loc.lng = _RGPJ[instance].lng;
loc.alt = _RGPJ[instance].alt;
return loc;
}
const Location &location(uint8_t instance) const;
bool have_vertical_velocity(uint8_t instance) const {
return _RGPI[instance].have_vertical_velocity;
}