AP_DAL: add define AP_AIRSPEED_ENABLED

This commit is contained in:
Josh Henderson 2021-11-01 04:18:15 -04:00 committed by Andrew Tridgell
parent f219d56e9c
commit af348e6ba1
2 changed files with 6 additions and 0 deletions

View File

@ -129,10 +129,12 @@ void AP_DAL::init_sensors(void)
alloc_failed |= (_rangefinder = new AP_DAL_RangeFinder) == nullptr;
}
#if AP_AIRSPEED_ENABLED
auto *aspeed = AP::airspeed();
if (aspeed != nullptr && aspeed->get_num_sensors() > 0) {
alloc_failed |= (_airspeed = new AP_DAL_Airspeed) == nullptr;
}
#endif
auto *bcn = AP::beacon();
if (bcn != nullptr && bcn->enabled()) {

View File

@ -5,13 +5,16 @@
AP_DAL_Airspeed::AP_DAL_Airspeed()
{
#if AP_AIRSPEED_ENABLED
for (uint8_t i=0; i<ARRAY_SIZE(_RASI); i++) {
_RASI[i].instance = i;
}
#endif
}
void AP_DAL_Airspeed::start_frame()
{
#if AP_AIRSPEED_ENABLED
const auto *airspeed = AP::airspeed();
if (airspeed == nullptr) {
return;
@ -31,4 +34,5 @@ void AP_DAL_Airspeed::start_frame()
RASI.airspeed = airspeed->get_airspeed(i);
WRITE_REPLAY_BLOCK_IFCHANGED(RASI, RASI, old_RASI);
}
#endif
}