From 49a0fe4120fd19be29f8524c56996dd3303048a2 Mon Sep 17 00:00:00 2001 From: George Zogopoulos Date: Tue, 7 Jan 2025 16:23:46 +0100 Subject: [PATCH] Scripting: EFI_Skypower: Added max throttle cap --- libraries/AP_Scripting/drivers/EFI_SkyPower.lua | 16 +++++++++++++++- libraries/AP_Scripting/drivers/EFI_SkyPower.md | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Scripting/drivers/EFI_SkyPower.lua b/libraries/AP_Scripting/drivers/EFI_SkyPower.lua index 5fb9a1a02379a..6af9734d3c963 100644 --- a/libraries/AP_Scripting/drivers/EFI_SkyPower.lua +++ b/libraries/AP_Scripting/drivers/EFI_SkyPower.lua @@ -74,7 +74,7 @@ end local efi_backend = nil -- Setup EFI Parameters -assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 19), 'could not add EFI_SP param table') +assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 20), 'could not add EFI_SP param table') --[[ // @Param: EFI_SP_ENABLE @@ -252,6 +252,15 @@ local EFI_SP_GEN_TIMER = bind_add_param('GEN_TIMER', 18, 2) --]] local EFI_SP_GEN_TOUT = bind_add_param('GEN_TOUT', 19, 5) +--[[ + // @Param: EFI_SP_THR_MAX + // @DisplayName: SkyPower EFI max throttle + // @Description: SkyPower EFI maximum throttle command. Use this parameter to limit the maximum demanded throttle, in case your engine power curve drops off past a throttle value. It is recommended that you limit your autopilot throttle limit instead. + // @Range: 0 1 + // @User: Standard +--]] +local EFI_SP_THR_MAX = bind_add_param('THR_MAX', 20, 1) + if EFI_SP_ENABLE:get() == 0 then gcs:send_text(0, string.format("EFISP: disabled")) @@ -488,6 +497,11 @@ local function engine_control(_driver) --- send throttle command, thr is 0 to 1 function self.send_throttle(thr) + -- Constrain to set max throttle + local max_throttle = EFI_SP_THR_MAX:get() + if max_throttle then + thr = math.min(thr, max_throttle) + end last_throttle = thr local msg = CANFrame() msg:id(FRM_500) diff --git a/libraries/AP_Scripting/drivers/EFI_SkyPower.md b/libraries/AP_Scripting/drivers/EFI_SkyPower.md index 95f75e3030afd..2021e97c4f51d 100644 --- a/libraries/AP_Scripting/drivers/EFI_SkyPower.md +++ b/libraries/AP_Scripting/drivers/EFI_SkyPower.md @@ -87,6 +87,10 @@ Enable generator control. 0:Disabled,1:Enabled SkyPower EFI restart time. If engine should be running and it has stopped for this amount of time then auto-restart. To disable this feature set this value to zero. +## EFI_SP_THR_MAX + +SkyPower EFI maximum throttle command. Use this parameter to limit the maximum demanded throttle, in case your engine power curve drops off past a throttle value. It is recommended that you limit your autopilot throttle limit instead. + ## EFI_SP_GEN_AUTO Enable automatic EFI Generator on/off logic. This will automatically switch