Skip to content

Commit

Permalink
Lua getCurve was changed in 2.9, widgets updated to match
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrickmann committed Sep 9, 2023
1 parent 099712b commit 13ea9db
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 60 deletions.
15 changes: 4 additions & 11 deletions sdcard/c480x272/WIDGETS/SoarETX/1/brkcrv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,16 @@ local function stepOff()
end
end

-- Work around the stupid fact that getCurve and setCurve tables are incompatible...
-- Make sure that we have the right number of points on the curve
local function GetCurve(crvIndex)
local oldTbl = model.getCurve(crvIndex)
local tbl = model.getCurve(crvIndex)

if #oldTbl.y ~= N - 1 then
if #tbl.y ~= N - 1 then
stepOff()
error("Wrong number of points on curve CV" .. crvIndex + 1)
end

local newTbl = { }
newTbl.y = { }
for p = 1, N do
newTbl.y[p] = oldTbl.y[p - 1]
end
newTbl.smooth = 1
newTbl.name = oldTbl.name
return newTbl
return tbl
end -- GetCurve()

local function init()
Expand Down
15 changes: 4 additions & 11 deletions sdcard/c480x272/WIDGETS/SoarETX/1/wing2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,16 @@ local lftYs = { }
local rgtYs = { }
local activeP -- The point currently being edited

-- Work around the stupid fact that getCurve and setCurve tables are incompatible...
-- Make sure that we have the right number of points on the curve
local function GetCurve(crvIndex)
local oldTbl = model.getCurve(crvIndex)
local tbl = model.getCurve(crvIndex)

if #oldTbl.y ~= N - 1 then
if #tbl.y ~= N - 1 then
setStickySwitch(LS_STEP, false)
error("Wrong number of points on curve CV" .. crvIndex + 1)
end

local newTbl = { }
newTbl.y = { }
for p = 1, N do
newTbl.y[p] = oldTbl.y[p - 1]
end
newTbl.smooth = 1
newTbl.name = oldTbl.name
return newTbl
return tbl
end -- GetCurve()

-- Find the output where the specified curve index is being used
Expand Down
15 changes: 4 additions & 11 deletions sdcard/c480x272/WIDGETS/SoarETX/1/wing4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,16 @@ local function stepOff()
end
end

-- Work around the stupid fact that getCurve and setCurve tables are incompatible...
-- Make sure that we have the right number of points on the curve
local function GetCurve(crvIndex)
local oldTbl = model.getCurve(crvIndex)
local tbl = model.getCurve(crvIndex)

if #oldTbl.y ~= N - 1 then
if #tbl.y ~= N - 1 then
stepOff()
error("Wrong number of points on curve CV" .. crvIndex + 1)
end

local newTbl = { }
newTbl.y = { }
for p = 1, N do
newTbl.y[p] = oldTbl.y[p - 1]
end
newTbl.smooth = 1
newTbl.name = oldTbl.name
return newTbl
return tbl
end -- GetCurve()

-- Find the output where the specified curve index is being used
Expand Down
7 changes: 0 additions & 7 deletions sdcard/c480x272/WIDGETS/SoarETX/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ local function init()
if not parameterCurve then
error("Curve #32 is missing! It is used to store persistent model parameters for Lua.")
end

-- Work around the stupid fact that getCurve and setCurve tables are incompatible...
local y = parameterCurve.y
parameterCurve.y = { }
for i = 1, parameterCurve.points do
parameterCurve.y[i] = y[i - 1]
end

function soarGlobals.getParameter(idx)
return parameterCurve.y[idx]
Expand Down
19 changes: 6 additions & 13 deletions sdcard/c480x320/WIDGETS/SoarETX/1/wing2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,16 @@ local lftYs = { }
local rgtYs = { }
local activeP -- The point currently being edited

-- Work around the stupid fact that getCurve and setCurve tables are incompatible...
-- Make sure that we have the right number of points on the curve
local function GetCurve(crvIndex)
local oldTbl = model.getCurve(crvIndex)
if #oldTbl.y ~= N - 1 then
local tbl = model.getCurve(crvIndex)

if #tbl.y ~= N - 1 then
setStickySwitch(LS_STEP, false)
error("Wrong number of points on curve CV" .. crvIndex + 1)
end

local newTbl = { }
newTbl.y = { }
for p = 1, N do
newTbl.y[p] = oldTbl.y[p - 1]
end
newTbl.smooth = 1
newTbl.name = oldTbl.name
return newTbl

return tbl
end -- GetCurve()

-- Find the output where the specified curve index is being used
Expand Down
7 changes: 0 additions & 7 deletions sdcard/c480x320/WIDGETS/SoarETX/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ local function init()
error("Curve #32 is missing! It is used to store persistent model parameters for Lua.")
end

-- Work around the stupid fact that getCurve and setCurve tables are incompatible...
local y = parameterCurve.y
parameterCurve.y = { }
for i = 1, parameterCurve.points do
parameterCurve.y[i] = y[i - 1]
end

function soarGlobals.getParameter(idx)
return parameterCurve.y[idx]
end
Expand Down

0 comments on commit 13ea9db

Please sign in to comment.