// =============================================================================
//  rudder_actuator_factory.h -- selects concrete actuator at build time
// =============================================================================
//
//  The AR_ACTUATOR_TYPE macro is defined in firmware_config.h (generated by
//  the .appack compiler).  If firmware_config.h is not present (standalone
//  build), falls back to ACTUATOR_HYDRAULIC_REVERSIBLE.
//
//  Usage in main.cpp:
//
//      #include "hal/rudder_actuator_factory.h"
//      // ...
//      IRudderActuator& actuator = arautopilot::hal::g_rudder_actuator;
//      actuator.init();
// =============================================================================

#pragma once

// Pull in generated config if available
#if __has_include("firmware_config.h")
#  include "firmware_config.h"
#endif

// Actuator type constants (must match _actuator_type_to_enum in appack.py)
#define ACTUATOR_HYDRAULIC_REVERSIBLE  0
#define ACTUATOR_ELECTRIC_DC           1
#define ACTUATOR_SERVOMOTOR            2
#define ACTUATOR_STERNDRIVE_ANALOG     3
#define ACTUATOR_TEST_RIG_MOTOR        4

#ifndef AR_ACTUATOR_TYPE
#  define AR_ACTUATOR_TYPE ACTUATOR_HYDRAULIC_REVERSIBLE
#endif

#if AR_ACTUATOR_TYPE == ACTUATOR_HYDRAULIC_REVERSIBLE
#  include "hal/rudder_actuator_hydraulic.h"
   namespace arautopilot::hal {
       static HydraulicRudderActuator g_rudder_actuator;
   }
#elif AR_ACTUATOR_TYPE == ACTUATOR_ELECTRIC_DC
#  include "hal/rudder_actuator_electric.h"
   namespace arautopilot::hal {
       static ElectricDcRudderActuator g_rudder_actuator;
   }
#else
   // Fallback: hydraulic (compile warning so the integrator notices)
#  pragma message("AR_ACTUATOR_TYPE not recognised — defaulting to HydraulicRudderActuator")
#  include "hal/rudder_actuator_hydraulic.h"
   namespace arautopilot::hal {
       static HydraulicRudderActuator g_rudder_actuator;
   }
#endif
