Skip to content

Commit

Permalink
Scripting: EFI_Skypower: Added max throttle cap
Browse files Browse the repository at this point in the history
  • Loading branch information
Georacer committed Jan 7, 2025
1 parent 6b38eef commit 49a0fe4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 15 additions & 1 deletion libraries/AP_Scripting/drivers/EFI_SkyPower.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions libraries/AP_Scripting/drivers/EFI_SkyPower.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49a0fe4

Please sign in to comment.