Skip to content

Commit

Permalink
AP_Scripting: add arming-check-batt-temp example script
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Feb 14, 2020
1 parent b11760e commit be33fbd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions libraries/AP_Scripting/examples/arming-check-batt-temp .lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- This script runs a custom arming check of the battery temperature

auth_id = arming:get_aux_auth_id()
batt_temp_max = 35

function update() -- this is the loop which periodically runs
if auth_id then
now = millis()
batt_temp = battery:get_temperature(0)
if not batt_temp then
arming:set_aux_auth_failed(auth_id, "Could not retrieve battery temperature")
elseif (batt_temp >= batt_temp_max) then
arming:set_aux_auth_failed(auth_id, "Batt temp too high (" .. tostring(batt_temp) .. "C > " .. tostring(batt_temp_max) .. "C)")
end
end
return update, 5000 -- reschedules the loop in 5 seconds
end

return update() -- run immediately before starting to reschedule

0 comments on commit be33fbd

Please sign in to comment.