Skip to content

Commit 20beaab

Browse files
authored
Merge pull request #432 from klutvott123/profile-select
Add Profiles page.
2 parents 13e1708 + 1a1522e commit 20beaab

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/SCRIPTS/BF/PAGES/profiles.lua

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
local template = assert(loadScript(radio.template))()
2+
local margin = template.margin
3+
local indent = template.indent
4+
local lineSpacing = template.lineSpacing
5+
local tableSpacing = template.tableSpacing
6+
local sp = template.listSpacing.field
7+
local yMinLim = radio.yMinLimit
8+
local x = margin
9+
local y = yMinLim - lineSpacing
10+
local inc = { x = function(val) x = x + val return x end, y = function(val) y = y + val return y end }
11+
local labels = {}
12+
local fields = {}
13+
14+
local RATEPROFILE_MASK = bit32.lshift(1, 7)
15+
local profileNumbers = { [0] = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }
16+
17+
fields[#fields + 1] = { t = "PID Profile", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 11 }, table = profileNumbers }
18+
fields[#fields + 1] = { t = "Rate Profile", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 5, vals = { 15 }, table = profileNumbers }
19+
20+
return {
21+
read = 150, -- MSP_STATUS_EX
22+
write = 210, -- MSP_SELECT_SETTING
23+
title = "Profiles",
24+
reboot = false,
25+
eepromWrite = true,
26+
minBytes = 11,
27+
labels = labels,
28+
fields = fields,
29+
pidProfile = 0,
30+
postLoad = function(self)
31+
local pidProfileCount = self.values[14]
32+
self.fields[1].max = pidProfileCount - 1
33+
self.pidProfile = self.fields[1].value
34+
end,
35+
preSave = function(self)
36+
local value = 0
37+
if self.fields[1].value ~= self.pidProfile then
38+
value = self.fields[1].value
39+
else
40+
value = bit32.bor(self.fields[2].value, RATEPROFILE_MASK)
41+
end
42+
self.values = {}
43+
self.values[1] = value
44+
return self.values
45+
end,
46+
}

src/SCRIPTS/BF/pages.lua

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ if apiVersion >= 1.036 then
44
PageFiles[#PageFiles + 1] = { title = "VTX Settings", script = "vtx.lua" }
55
end
66

7+
if apiVersion >= 1.016 then
8+
PageFiles[#PageFiles + 1] = { title = "Profiles", script = "profiles.lua" }
9+
end
10+
711
if apiVersion >= 1.016 then
812
PageFiles[#PageFiles + 1] = { title = "PIDs 1", script = "pids1.lua" }
913
end

0 commit comments

Comments
 (0)