Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/SCRIPTS/BF/PAGES/rates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ if apiVersion >= 1.016 then
inc.y(lineSpacing*0.4)
end

if apiVersion >= 1.043 then
fields[#fields + 1] = { t = "Rates Type", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 4, vals = { 23 }, table = { [0] = "BF", "RF", "KISS", "ACTUAL", "QUICK"}, postEdit = function(self) self.updateRatesType(self, true) end }
end

if apiVersion >= 1.016 then
labels[#labels + 1] = { t = "Throttle", x = x, y = inc.y(lineSpacing) }
fields[#fields + 1] = { t = "Mid", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 7 }, scale = 100 }
Expand All @@ -91,4 +95,49 @@ return {
minBytes = 12,
labels = labels,
fields = fields,
ratesType,
getRatesType = function(self)
for i = 1, #self.fields do
if self.fields[i].vals and self.fields[i].vals[1] == 23 then
return self.fields[i].table[self.fields[i].value]
end
end
end,
updateRatesType = function(self, applyDefaults)
local ratesTable = assert(loadScript("RATETABLES/"..self.getRatesType(self)..".lua"))()
for i = 1, #ratesTable.labels do
self.labels[i].t = ratesTable.labels[i]
end
for i = 1, #ratesTable.fields do
for k, v in pairs(ratesTable.fields[i]) do
self.fields[i][k] = v
end
end
if applyDefaults and self.ratesType ~= self.getRatesType(self) then
for i = 1, #ratesTable.defaults do
local f = self.fields[i]
f.value = ratesTable.defaults[i]
for idx=1, #f.vals do
self.values[f.vals[idx]] = bit32.rshift(math.floor(f.value*(f.scale or 1) + 0.5), (idx-1)*8)
end
end
else
for i = 1, 9 do
local f = self.fields[i]
f.value = 0
for idx=1, #f.vals do
local raw_val = self.values[f.vals[idx]] or 0
raw_val = bit32.lshift(raw_val, (idx-1)*8)
f.value = bit32.bor(f.value, raw_val)
end
f.value = f.value/(f.scale or 1)
end
end
self.ratesType = self.getRatesType(self)
end,
postLoad = function(self)
if apiVersion >= 1.043 then
self.updateRatesType(self)
end
end,
}
15 changes: 15 additions & 0 deletions src/SCRIPTS/BF/RATETABLES/ACTUAL.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
return {
labels = { "", "", "ROLL", "PITCH", "YAW", "Cntr", "Sens", "Max", "Rate", "", "Expo" },
fields = {
{ min = 1, max = 200, scale = 0.1 },
{ min = 1, max = 200, scale = 0.1 },
{ min = 1, max = 200, scale = 0.1 },
{ min = 0, max = 200, scale = 0.1 },
{ min = 0, max = 200, scale = 0.1 },
{ min = 0, max = 200, scale = 0.1 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 }
},
defaults = { 200, 200, 200, 670, 670, 670, 0.54, 0.54, 0.54 }
}
15 changes: 15 additions & 0 deletions src/SCRIPTS/BF/RATETABLES/BF.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
return {
labels = { "", "", "ROLL", "PITCH", "YAW", "RC", "Rate", "Super", "Rate", "RC", "Expo" },
fields = {
{ min = 0, max = 255, scale = 100 },
{ min = 0, max = 255, scale = 100 },
{ min = 0, max = 255, scale = 100 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 255, scale = 100 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 }
},
defaults = { 1.0, 1.0, 1.0, 0.7, 0.7, 0.7, 0.0, 0.0, 0.0 }
}
15 changes: 15 additions & 0 deletions src/SCRIPTS/BF/RATETABLES/KISS.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
return {
labels = { "", "", "ROLL", "PITCH", "YAW", "RC", "Rate", "", "Rate", "RC", "Curve" },
fields = {
{ min = 1, max = 255, scale = 100 },
{ min = 1, max = 255, scale = 100 },
{ min = 1, max = 255, scale = 100 },
{ min = 0, max = 99, scale = 100 },
{ min = 0, max = 99, scale = 100 },
{ min = 0, max = 99, scale = 100 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 }
},
defaults = { 1.0, 1.0, 1.0, 0.7, 0.7, 0.7, 0.0, 0.0, 0.0 }
}
15 changes: 15 additions & 0 deletions src/SCRIPTS/BF/RATETABLES/QUICK.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
return {
labels = { "", "", "ROLL", "PITCH", "YAW", "RC", "Rate", "Max", "Rate", "", "Expo" },
fields = {
{ min = 1, max = 255, scale = 100 },
{ min = 1, max = 255, scale = 100 },
{ min = 1, max = 255, scale = 100 },
{ min = 0, max = 200, scale = 0.1 },
{ min = 0, max = 200, scale = 0.1 },
{ min = 0, max = 200, scale = 0.1 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 },
{ min = 0, max = 100, scale = 100 }
},
defaults = { 1.0, 1.0, 1.0, 670, 670, 670, 0.0, 0.0, 0.0 }
}
15 changes: 15 additions & 0 deletions src/SCRIPTS/BF/RATETABLES/RF.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
return {
labels = { "", "", "ROLL", "PITCH", "YAW", "", "Rate", "", "Acro+", "", "Expo" },
fields = {
{ min = 1, max = 200, scale = 0.1 },
{ min = 1, max = 200, scale = 0.1 },
{ min = 1, max = 200, scale = 0.1 },
{ min = 0, max = 100, scale = 1 },
{ min = 0, max = 100, scale = 1 },
{ min = 0, max = 100, scale = 1 },
{ min = 0, max = 100, scale = 1 },
{ min = 0, max = 100, scale = 1 },
{ min = 0, max = 100, scale = 1 }
},
defaults = { 370, 370, 370, 80, 80, 80, 50, 50, 50 }
}
3 changes: 3 additions & 0 deletions src/SCRIPTS/BF/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ local function run_ui(event)
end
elseif pageState == pageStatus.editing then
if event == EVT_VIRTUAL_EXIT or event == EVT_VIRTUAL_ENTER then
if Page.fields[currentField].postEdit then
Page.fields[currentField].postEdit(Page)
end
pageState = pageStatus.display
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
incValue(1)
Expand Down