AP_EFI: convert to using ap_object approach

This commit is contained in:
Andrew Tridgell 2022-10-01 11:28:30 +10:00
parent 6e308814ad
commit fed4909dd1
6 changed files with 9 additions and 21 deletions

View File

@ -277,18 +277,6 @@ void AP_EFI::get_state(EFI_State &_state)
_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 { namespace AP {
AP_EFI *EFI() AP_EFI *EFI()
{ {

View File

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

View File

@ -32,7 +32,7 @@ public:
virtual void update() = 0; virtual void update() = 0;
#if AP_SCRIPTING_ENABLED #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 #endif
protected: protected:

View File

@ -9,10 +9,11 @@ void AP_EFI_Scripting::update()
} }
// handle EFI message from scripting // 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; internal_state = efi_state;
copy_to_frontend(); copy_to_frontend();
return true;
} }
#endif // AP_EFI_SCRIPTING_ENABLED #endif // AP_EFI_SCRIPTING_ENABLED

View File

@ -3,10 +3,6 @@
#include "AP_EFI.h" #include "AP_EFI.h"
#include "AP_EFI_Backend.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 #if AP_EFI_SCRIPTING_ENABLED
class AP_EFI_Scripting : public AP_EFI_Backend { class AP_EFI_Scripting : public AP_EFI_Backend {
@ -15,6 +11,6 @@ public:
void update() override; 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 #endif // AP_EFI_SCRIPTING_ENABLED

View File

@ -5,3 +5,7 @@
#ifndef HAL_EFI_ENABLED #ifndef HAL_EFI_ENABLED
#define HAL_EFI_ENABLED !HAL_MINIMIZE_FEATURES && BOARD_FLASH_SIZE > 1024 #define HAL_EFI_ENABLED !HAL_MINIMIZE_FEATURES && BOARD_FLASH_SIZE > 1024
#endif #endif
#ifndef AP_EFI_SCRIPTING_ENABLED
#define AP_EFI_SCRIPTING_ENABLED (HAL_EFI_ENABLED && AP_SCRIPTING_ENABLED)
#endif