diff --git a/libraries/AP_Scripting/applets/ahrs-source-modalai-optflow.lua b/libraries/AP_Scripting/applets/ahrs-source-modalai-optflow.lua index 1fe4c31f1c87be..fabadb9dfb05a8 100644 --- a/libraries/AP_Scripting/applets/ahrs-source-modalai-optflow.lua +++ b/libraries/AP_Scripting/applets/ahrs-source-modalai-optflow.lua @@ -31,18 +31,25 @@ -- innovations are below ESRC_FLOW_THRESH -- rangefinder distance is below ESRC_RNGFND_MAX +local PARAM_TABLE_KEY = 81 +PARAM_TABLE_PREFIX = "ESRC_" local MAV_SEVERITY = {EMERGENCY=0, ALERT=1, CRITICAL=2, ERROR=3, WARNING=4, NOTICE=5, INFO=6, DEBUG=7} +-- bind a parameter to a variable +function bind_param(name) + local p = Parameter() + assert(p:init(name), string.format('could not find %s parameter', name)) + return p +end + -- add a parameter and bind it to a variable -function bind_add_param(name, idx, default_value) +local function bind_add_param(name, idx, default_value) assert(param:add_param(PARAM_TABLE_KEY, idx, name, default_value), string.format('could not add param %s', name)) - return Parameter(PARAM_TABLE_PREFIX .. name) + return bind_param(PARAM_TABLE_PREFIX .. name) end --- param table -local PARAM_TABLE_KEY = 81 -PARAM_TABLE_PREFIX = "ESCR_" -assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 6), 'ahrs-source-modalai-optflow: could not add param table') +-- add param table +assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 5), 'ahrs-source-modalai-optflow: could not add param table') --[[ // @Param: ESRC_EXTN_THRESH @@ -227,7 +234,6 @@ function update() end play_source_tune(source_prev) end - end -- auto switching if auto_switch and (auto_source >= 0) and (auto_source ~= source_prev) then