Skip to content

Commit 2bb514d

Browse files
authored
Merge pull request #390 from klutvott123/failsafe
2 parents c2eb818 + 32f7ba5 commit 2bb514d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/SCRIPTS/BF/PAGES/failsafe.lua

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
local template = loadScript(radio.templateHome.."failsafe.lua")
2+
if template then
3+
template = template()
4+
else
5+
template = assert(loadScript(radio.templateHome.."default_template.lua"))()
6+
end
7+
local margin = template.margin
8+
local indent = template.indent
9+
local lineSpacing = template.lineSpacing
10+
local tableSpacing = template.tableSpacing
11+
local sp = template.listSpacing.field
12+
local yMinLim = radio.yMinLimit
13+
local x = margin
14+
local y = yMinLim - lineSpacing
15+
local inc = { x = function(val) x = x + val return x end, y = function(val) y = y + val return y end }
16+
local labels = {}
17+
local fields = {}
18+
19+
local procedure = { [0] = "Land", "Drop" }
20+
21+
if apiVersion >= 1.039 then
22+
procedure[#procedure + 1] = "Rescue"
23+
end
24+
25+
if apiVersion >= 1.039 then
26+
labels[#labels + 1] = { t = "Failsafe Switch", x = x, y = inc.y(lineSpacing) }
27+
fields[#fields + 1] = { t = "Action", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 2, vals = { 5 }, table = { [0] = "Stage 1", "Kill", "Stage 2" } }
28+
else
29+
fields[#fields + 1] = { t = "Kill switch", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 5 }, table = { [0] = "OFF", "ON" } }
30+
end
31+
32+
labels[#labels + 1] = { t = "Stage 2 Settings" , x = x, y = inc.y(lineSpacing) }
33+
fields[#fields + 1] = { t = "Procedure", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #procedure, vals = { 8 }, table = procedure }
34+
fields[#fields + 1] = { t = "Guard Time", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 1 }, scale = 10 }
35+
fields[#fields + 1] = { t = "Thrl Low Delay", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 300, vals = { 6, 7 }, scale = 10 }
36+
37+
labels[#labels + 1] = { t = "Stage 2 Land Settings", x = x, y = inc.y(lineSpacing) }
38+
fields[#fields + 1] = { t = "Thrl Land Value", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 750, max = 2250, vals = { 3, 4 } }
39+
fields[#fields + 1] = { t = "Motor Off Delay", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 2 }, scale = 10 }
40+
41+
return {
42+
read = 75, -- MSP_FAILSAFE_CONFIG
43+
write = 76, -- MSP_SET_FAILSAFE_CONFIG
44+
title = "Failsafe",
45+
reboot = true,
46+
eepromWrite = true,
47+
minBytes = 8,
48+
labels = labels,
49+
fields = fields,
50+
}

src/SCRIPTS/BF/pages.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ if apiVersion >= 1.016 then
4040
PageFiles[#PageFiles + 1] = { title = "Receiver", script = "rx.lua" }
4141
end
4242

43+
if apiVersion >= 1.016 then
44+
PageFiles[#PageFiles + 1] = { title = "Failsafe", script = "failsafe.lua" }
45+
end
46+
4347
if apiVersion >= 1.041 then
4448
PageFiles[#PageFiles + 1] = { title = "GPS Rescue", script = "rescue.lua" }
4549
end

0 commit comments

Comments
 (0)