AP_EFI: convert to using ap_object approach

This commit is contained in:
Andrew Tridgell 2022-10-02 09:00:05 +11:00 committed by Randy Mackay
parent 55b87b1e78
commit d25e2b5ba2
6 changed files with 16 additions and 21 deletions

View File

@ -276,18 +276,6 @@ void AP_EFI::get_state(EFI_State &_state)
_state = state;
}
#if AP_EFI_SCRIPTING_ENABLED && AP_SCRIPTING_ENABLED
void AP_EFI::handle_scripting(const EFI_State &efi_state)
{
if (!backend || (Type(type.get()) != Type::SCRIPTING)) {
return;
}
backend->handle_scripting(efi_state);
}
#endif
namespace AP {
AP_EFI *EFI()
{

View File

@ -95,8 +95,7 @@ public:
void send_mavlink_status(mavlink_channel_t chan);
#if AP_SCRIPTING_ENABLED
// Ingest EFI_State from scripting driver
void handle_scripting(const EFI_State &efi_state);
AP_EFI_Backend* get_backend(uint8_t idx) { return idx==0?backend:nullptr; }
#endif
protected:

View File

@ -32,7 +32,7 @@ public:
virtual void update() = 0;
#if AP_SCRIPTING_ENABLED
virtual void handle_scripting(const EFI_State &efi_state) { return; }
virtual bool handle_scripting(const EFI_State &efi_state) { return false; }
#endif
protected:

View File

@ -9,10 +9,11 @@ void AP_EFI_Scripting::update()
}
// handle EFI message from scripting
void AP_EFI_Scripting::handle_scripting(const EFI_State &efi_state)
bool AP_EFI_Scripting::handle_scripting(const EFI_State &efi_state)
{
internal_state = efi_state;
copy_to_frontend();
return true;
}
#endif // AP_EFI_SCRIPTING_ENABLED

View File

@ -3,10 +3,6 @@
#include "AP_EFI.h"
#include "AP_EFI_Backend.h"
#ifndef AP_EFI_SCRIPTING_ENABLED
#define AP_EFI_SCRIPTING_ENABLED (HAL_EFI_ENABLED && AP_SCRIPTING_ENABLED)
#endif
#if AP_EFI_SCRIPTING_ENABLED
class AP_EFI_Scripting : public AP_EFI_Backend {
@ -15,6 +11,6 @@ public:
void update() override;
void handle_scripting(const EFI_State &efi_state) override;
bool handle_scripting(const EFI_State &efi_state) override;
};
#endif // AP_EFI_SCRIPTING_ENABLED

View File

@ -0,0 +1,11 @@
#pragma once
#include <AP_HAL/AP_HAL_Boards.h>
#ifndef HAL_EFI_ENABLED
#define HAL_EFI_ENABLED !HAL_MINIMIZE_FEATURES && BOARD_FLASH_SIZE > 1024
#endif
#ifndef AP_EFI_SCRIPTING_ENABLED
#define AP_EFI_SCRIPTING_ENABLED (HAL_EFI_ENABLED && AP_SCRIPTING_ENABLED)
#endif