mirror of https://github.com/ArduPilot/ardupilot
AP_EFI: convert to using ap_object approach
This commit is contained in:
parent
55b87b1e78
commit
d25e2b5ba2
|
@ -276,18 +276,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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,8 +95,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:
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue