Skip to content

Commit

Permalink
AP_Scripting: use cached in AHRS_switch example
Browse files Browse the repository at this point in the history
and use EKF2/EKF3, more likely to be useful
  • Loading branch information
tridge committed Oct 12, 2024
1 parent c3affa4 commit c7cc5e1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions libraries/AP_Scripting/examples/AHRS_switch.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
-- switch between DCM and EKF3 on a switch
-- switch between EKF2 and EKF3 on a switch

---@diagnostic disable: need-check-nil

local scripting_rc1 = rc:find_channel_for_option(300)
local AUX_FUNCTION_NUM = 300
local EKF_TYPE = Parameter('AHRS_EKF_TYPE')

function update()
local sw_pos = scripting_rc1:get_aux_switch_pos()
if sw_pos == 0 then
local sw_pos = rc:get_aux_cached(AUX_FUNCTION_NUM)
if not sw_pos then
return update, 100
end
if sw_pos == 2 then
EKF_TYPE:set(3)
else
EKF_TYPE:set(0)
EKF_TYPE:set(2)
end
return update, 100
end

gcs:send_text(0, "Loaded AHRS switch for EKF3/EKF2")

return update()

0 comments on commit c7cc5e1

Please sign in to comment.