Skip to content

Commit

Permalink
AP_Sccripting: examples: Flip Mode: refuse mode entry if not armed an…
Browse files Browse the repository at this point in the history
…d flying
  • Loading branch information
IamPete1 committed Nov 14, 2024
1 parent 6d03d9e commit ce65f28
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libraries/AP_Scripting/examples/Flip_Mode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
local MODE_NUMBER = 100

-- Register flip as mode 100
assert(vehicle:register_custom_mode(MODE_NUMBER, "Flip", "FLIP"))
local FLIP_MODE_STATE = assert(vehicle:register_custom_mode(MODE_NUMBER, "Flip 2", "FLI2"))

-- Get input channels
local THROTTLE_CHAN = math.floor(assert(param:get("RCMAP_THROTTLE")))
Expand Down Expand Up @@ -217,6 +217,12 @@ local function exit()
end

local function update()

-- Only allow entry into flip mode if armed and flying
local armed = arming:is_armed()
local flying = vehicle:get_likely_flying()
FLIP_MODE_STATE:allow_entry(armed and flying)

local mode = vehicle:get_mode()
if mode == MODE_NUMBER then
if last_mode_number ~= MODE_NUMBER then
Expand Down

0 comments on commit ce65f28

Please sign in to comment.