Skip to content

Commit

Permalink
Merge pull request #399 from klutvott123/update-simplified-tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeller authored Nov 1, 2021
2 parents 511f99a + 1ae54d1 commit bad5cb3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
28 changes: 18 additions & 10 deletions src/SCRIPTS/BF/PAGES/pids1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y =
local labels = {}
local fields = {}

local pidMax = 200
local dLabel = "D"

if apiVersion >= 1.044 then
pidMax = 250
dLabel = "D Max"
end

if apiVersion >= 1.016 then
x = margin
y = yMinLim - tableSpacing.header
Expand All @@ -24,26 +32,26 @@ if apiVersion >= 1.016 then
y = yMinLim - tableSpacing.header

labels[#labels + 1] = { t = "P", x = x, y = inc.y(tableSpacing.header) }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 1 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 4 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 7 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 1 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 4 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 7 } }

x = x + tableSpacing.col
y = yMinLim - tableSpacing.header

labels[#labels + 1] = { t = "I", x = x, y = inc.y(tableSpacing.header) }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 2 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 5 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 8 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 2 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 5 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 8 } }

x = x + tableSpacing.col
y = yMinLim - tableSpacing.header

labels[#labels + 1] = { t = "D", x = x, y = inc.y(tableSpacing.header) }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 3 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 6 } }
labels[#labels + 1] = { t = dLabel, x = x, y = inc.y(tableSpacing.header) }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 3 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 6 } }
if apiVersion >= 1.041 then
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 200, vals = { 9 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 9 } }
end
end

Expand Down
12 changes: 9 additions & 3 deletions src/SCRIPTS/BF/PAGES/pids2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y =
local labels = {}
local fields = {}

local dMinMax = 100

if apiVersion >= 1.044 then
dMinMax = 250
end

if apiVersion >= 1.040 then
x = margin
y = yMinLim - tableSpacing.header
Expand All @@ -33,9 +39,9 @@ if apiVersion >= 1.040 then
y = yMinLim - tableSpacing.header

labels[#labels + 1] = { t = "D Min", x = x, y = inc.y(tableSpacing.header) }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 100, vals = { 40 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 100, vals = { 41 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 100, vals = { 42 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = dMinMax, vals = { 40 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = dMinMax, vals = { 41 } }
fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = dMinMax, vals = { 42 } }
end

x = margin
Expand Down
29 changes: 15 additions & 14 deletions src/SCRIPTS/BF/PAGES/simplified_tuning.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,30 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y =
local labels = {}
local fields = {}

labels[#labels + 1] = { t = "Simplified Pid", x = x, y = inc.y(lineSpacing) }
fields[#fields + 1] = { t = "Pid Tuning", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 2, vals = { 1 }, table = { [0] = "OFF", "RP", "RPY" } }
fields[#fields + 1] = { t = "Master Mult", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 2 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "R/P Ratio", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 3 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "I Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 4 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "P/D Ratio", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 5 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "PD Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 6 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "Dmin Ratio", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 7 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "FF Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 8 }, scale = 100, mult = 5 }
labels[#labels + 1] = { t = "Simplified PID", x = x, y = inc.y(lineSpacing) }
fields[#fields + 1] = { t = "PID Tuning", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 2, vals = { 1 }, table = { [0] = "OFF", "RP", "RPY" } }
fields[#fields + 1] = { t = "Master Mult", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 2 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "P/I Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 6 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "D Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 5 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "FF Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 8 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "I Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 4 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "D Max Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 7 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "Pitch D Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 3 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "Pitch P/I/FF Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 9 }, scale = 100, mult = 5 }

labels[#labels + 1] = { t = "Simplified Filter", x = x, y = inc.y(lineSpacing) }
fields[#fields + 1] = { t = "Gyro Tuning", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 9 }, table = { [0] = "OFF", "ON" } }
fields[#fields + 1] = { t = "Gyro Mult", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 10 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "D Tuning", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 11 }, table = { [0] = "OFF", "ON" } }
fields[#fields + 1] = { t = "D Mult", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 12 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "Gyro Tuning", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 12 }, table = { [0] = "OFF", "ON" } }
fields[#fields + 1] = { t = "Gyro Mult", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 13 }, scale = 100, mult = 5 }
fields[#fields + 1] = { t = "D Tuning", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 10 }, table = { [0] = "OFF", "ON" } }
fields[#fields + 1] = { t = "D Mult", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 11 }, scale = 100, mult = 5 }

return {
read = 140, -- MSP_SIMPLIFIED_TUNING
write = 141, -- MSP_SET_SIMPLIFIED_TUNING
title = "Simplified Tuning",
reboot = false,
eepromWrite = true,
minBytes = 12,
minBytes = 13,
labels = labels,
fields = fields,
}

0 comments on commit bad5cb3

Please sign in to comment.