AP_EFI: use enum class for protocol

This commit is contained in:
Peter Barker 2020-08-07 14:04:06 +10:00 committed by Peter Barker
parent 5edfed0083
commit 7ea5bc7e3e
2 changed files with 18 additions and 16 deletions

View File

@ -72,18 +72,20 @@ void AP_EFI::init(void)
// Init called twice, perhaps // Init called twice, perhaps
return; return;
} }
// Check for MegaSquirt Serial EFI switch ((Type)type.get()) {
switch (type) { case Type::NONE:
case EFI_COMMUNICATION_TYPE_NONE:
break; break;
case EFI_COMMUNICATION_TYPE_SERIAL_MS: case Type::MegaSquirt:
backend = new AP_EFI_Serial_MS(*this); backend = new AP_EFI_Serial_MS(*this);
break; break;
case EFI_COMMUNICATION_TYPE_NWPMU: case Type::NWPMU:
#if HAL_EFI_NWPWU_ENABLED #if HAL_EFI_NWPWU_ENABLED
backend = new AP_EFI_NWPMU(*this); backend = new AP_EFI_NWPMU(*this);
#endif #endif
break; break;
default:
gcs().send_text(MAV_SEVERITY_INFO, "Unknown EFI type");
break;
} }
} }

View File

@ -60,7 +60,7 @@ public:
uint32_t get_rpm() const { return state.engine_speed_rpm; } uint32_t get_rpm() const { return state.engine_speed_rpm; }
// returns enabled state of EFI // returns enabled state of EFI
bool enabled() const { return type != EFI_COMMUNICATION_TYPE_NONE; } bool enabled() const { return type != Type::NONE; }
bool is_healthy() const; bool is_healthy() const;
@ -68,10 +68,10 @@ public:
static const struct AP_Param::GroupInfo var_info[]; static const struct AP_Param::GroupInfo var_info[];
// Backend driver types // Backend driver types
enum EFI_Communication_Type { enum class Type : uint8_t {
EFI_COMMUNICATION_TYPE_NONE = 0, NONE = 0,
EFI_COMMUNICATION_TYPE_SERIAL_MS = 1, MegaSquirt = 1,
EFI_COMMUNICATION_TYPE_NWPMU = 2, NWPMU = 2,
}; };
static AP_EFI *get_singleton(void) { static AP_EFI *get_singleton(void) {
@ -91,7 +91,7 @@ protected:
private: private:
// Front End Parameters // Front End Parameters
AP_Int8 type; AP_Enum<Type> type;
// Tracking backends // Tracking backends
AP_EFI_Backend *backend; AP_EFI_Backend *backend;