2020-11-05 19:22:38 -04:00
|
|
|
#include "AP_DAL_Compass.h"
|
|
|
|
|
|
|
|
#include <AP_Compass/AP_Compass.h>
|
|
|
|
|
|
|
|
#include <AP_Logger/AP_Logger.h>
|
|
|
|
#include "AP_DAL.h"
|
|
|
|
|
|
|
|
AP_DAL_Compass::AP_DAL_Compass()
|
|
|
|
{
|
|
|
|
for (uint8_t i=0; i<ARRAY_SIZE(_RMGI); i++) {
|
|
|
|
_RMGI[i].instance = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AP_DAL_Compass::start_frame()
|
|
|
|
{
|
|
|
|
const auto &compass = AP::compass();
|
|
|
|
|
|
|
|
const log_RMGH old = _RMGH;
|
2021-07-27 02:54:28 -03:00
|
|
|
_RMGH.available = compass.available();
|
2020-11-05 19:22:38 -04:00
|
|
|
_RMGH.count = compass.get_count();
|
|
|
|
_RMGH.auto_declination_enabled = compass.auto_declination_enabled();
|
|
|
|
_RMGH.declination = compass.get_declination();
|
|
|
|
_RMGH.num_enabled = compass.get_num_enabled();
|
|
|
|
_RMGH.consistent = compass.consistent();
|
2021-05-20 13:07:51 -03:00
|
|
|
_RMGH.first_usable = compass.get_first_usable();
|
2023-01-30 12:30:55 -04:00
|
|
|
_RMGH.learn_offsets_enabled = compass.learn_offsets_enabled();
|
2020-11-05 19:22:38 -04:00
|
|
|
|
2020-11-07 17:29:45 -04:00
|
|
|
WRITE_REPLAY_BLOCK_IFCHANGED(RMGH, _RMGH, old);
|
2020-11-05 19:22:38 -04:00
|
|
|
|
2020-11-07 17:29:45 -04:00
|
|
|
for (uint8_t i=0; i<_RMGH.count; i++) {
|
2020-11-05 19:22:38 -04:00
|
|
|
log_RMGI &RMGI = _RMGI[i];
|
|
|
|
const log_RMGI old_RMGI = RMGI;
|
|
|
|
RMGI.use_for_yaw = compass.use_for_yaw(i);
|
|
|
|
RMGI.healthy = compass.healthy(i);
|
|
|
|
RMGI.offsets = compass.get_offsets(i);
|
|
|
|
RMGI.have_scale_factor = compass.have_scale_factor(i);
|
|
|
|
RMGI.last_update_usec = compass.last_update_usec(i);
|
|
|
|
RMGI.field = compass.get_field(i);
|
|
|
|
|
2020-11-07 17:29:45 -04:00
|
|
|
WRITE_REPLAY_BLOCK_IFCHANGED(RMGI, RMGI, old_RMGI);
|
2020-11-05 19:22:38 -04:00
|
|
|
}
|
|
|
|
}
|