Skip to content

Use new OpenTX Tools screen / Add Menu / Use Virtual Events #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ luac.out
#directories
tmp
obj
.vscode
17 changes: 0 additions & 17 deletions src/SCRIPTS/BF/HORUS/horuspre.lua

This file was deleted.

17 changes: 0 additions & 17 deletions src/SCRIPTS/BF/NV14/nv14pre.lua

This file was deleted.

16 changes: 0 additions & 16 deletions src/SCRIPTS/BF/X7/x7pre.lua

This file was deleted.

17 changes: 0 additions & 17 deletions src/SCRIPTS/BF/X9/x9pre.lua

This file was deleted.

29 changes: 0 additions & 29 deletions src/SCRIPTS/BF/events.lua

This file was deleted.

2 changes: 1 addition & 1 deletion src/SCRIPTS/FUNCTIONS/pids.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SCRIPT_HOME = "/SCRIPTS/BF"
SCRIPT_HOME = "/SCRIPTS/TOOLS/BF"

assert(loadScript(SCRIPT_HOME.."/MSP/messages.lua"))()

Expand Down
2 changes: 1 addition & 1 deletion src/SCRIPTS/TELEMETRY/bf.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SCRIPT_HOME = "/SCRIPTS/BF"
SCRIPT_HOME = "/SCRIPTS/TOOLS/BF"

apiVersion = 0

Expand Down
17 changes: 17 additions & 0 deletions src/SCRIPTS/TOOLS/BF/HORUS/horuspre.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PageFiles =
{
{ title = "PIDs 1", script = "pids1.lua"},
{ title = "PIDs 2", script = "pids2.lua"},
{ title = "Rates", script = "rates.lua"},
{ title = "Advanced PIDs", script = "pid_advanced.lua"},
{ title = "Filters", script = "filters.lua"},
{ title = "vTX Settings", script = "vtx.lua"},
{ title = "Gyro / Motor", script = "pwm.lua"},
{ title = "Rx", script = "rx.lua"},
{ title = "GPS Rescue", script = "rescue.lua", requiredVersion = 1.041},
{ title = "GPS PIDs", script = "gpspids.lua", requiredVersion = 1.041},
}

MenuBox = { x=120, y=100, w=200, x_offset=68, h_line=20, h_offset=6 }
SaveBox = { x=120, y=100, w=180, x_offset=12, h=60, h_offset=12 }
NoTelem = { 192, LCD_H - 28, "No Telemetry", TEXT_COLOR + INVERS + BLINK }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
MSP_PID_FORMAT = {
read = 112, -- MSP_PID
write = 202, -- MSP_SET_PID
minBytes = 8,
fields = {
-- P
{ vals = { 1 } },
{ vals = { 4 } },
{ vals = { 7 } },
-- I
{ vals = { 2 } },
{ vals = { 5 } },
{ vals = { 8 } },
-- D
{ vals = { 3 } },
{ vals = { 6 } },
},
}
MSP_PID_ADVANCED_FORMAT = {
read = 94, -- MSP_PID_ADVANCED
write = 95, -- MSP_SET_PID_ADVANCED
minBytes = 23,
fields = {
-- weight
{ vals = { 10 }, scale = 100 },
-- transition
{ vals = { 9 }, scale = 100 },
},
}
local INTRO_DELAY = 1600
local READOUT_DELAY = 500
function extractMspValues(cmd, rx_buf, msgFormat, msgValues)
if cmd == nil or rx_buf == nil then
return
end
if cmd ~= msgFormat.read then
return
end
if #(rx_buf) > 0 then
msgValues.raw = {}
for i=1,#(rx_buf) do
msgValues.raw[i] = rx_buf[i]
end
msgValues.values = {}
for i=1,#(msgFormat.fields) do
if (#(msgValues.raw) or 0) >= msgFormat.minBytes then
local f = msgFormat.fields[i]
if f.vals then
local value = 0;
for idx=1, #(f.vals) do
local raw_val = msgValues.raw[f.vals[idx]]
raw_val = bit32.lshift(raw_val, (idx-1)*8)
value = bit32.bor(value, raw_val)
end
msgValues.values[i] = value/(f.scale or 1)
end
end
end
end
end
function readoutMsp(msgFormat, msg)
local t = getTime()
if msg.lastTrigger == nil or msg.lastTrigger + INTRO_DELAY <= t then
playFile(msg.intro)
msg.lastTrigger = t
elseif msg.reqTS == nil or msg.reqTS + READOUT_DELAY <= t then
protocol.mspRead(msgFormat.read)
msg.reqTS = t
else
local cmd, rx_buf = mspPollReply()
extractMspValues(cmd, rx_buf, msgFormat, msg)
if msg.raw then
for i=1,#(msg.readoutValues) do
playNumber(msg.values[msg.readoutValues[i]], 0)
end
msg.raw = nil
end
end
mspProcessTxQ()
end
MSP_PID_FORMAT = {
read = 112, -- MSP_PID
write = 202, -- MSP_SET_PID
minBytes = 8,
fields = {
-- P
{ vals = { 1 } },
{ vals = { 4 } },
{ vals = { 7 } },
-- I
{ vals = { 2 } },
{ vals = { 5 } },
{ vals = { 8 } },
-- D
{ vals = { 3 } },
{ vals = { 6 } },
},
}

MSP_PID_ADVANCED_FORMAT = {
read = 94, -- MSP_PID_ADVANCED
write = 95, -- MSP_SET_PID_ADVANCED
minBytes = 23,
fields = {
-- weight
{ vals = { 10 }, scale = 100 },
-- transition
{ vals = { 9 }, scale = 100 },
},
}

local INTRO_DELAY = 1600
local READOUT_DELAY = 500

function extractMspValues(cmd, rx_buf, msgFormat, msgValues)
if cmd == nil or rx_buf == nil then
return
end
if cmd ~= msgFormat.read then
return
end
if #(rx_buf) > 0 then
msgValues.raw = {}
for i=1,#(rx_buf) do
msgValues.raw[i] = rx_buf[i]
end

msgValues.values = {}
for i=1,#(msgFormat.fields) do
if (#(msgValues.raw) or 0) >= msgFormat.minBytes then
local f = msgFormat.fields[i]
if f.vals then
local value = 0;
for idx=1, #(f.vals) do
local raw_val = msgValues.raw[f.vals[idx]]
raw_val = bit32.lshift(raw_val, (idx-1)*8)
value = bit32.bor(value, raw_val)
end
msgValues.values[i] = value/(f.scale or 1)
end
end
end
end
end

function readoutMsp(msgFormat, msg)
local t = getTime()
if msg.lastTrigger == nil or msg.lastTrigger + INTRO_DELAY <= t then
playFile(msg.intro)
msg.lastTrigger = t
elseif msg.reqTS == nil or msg.reqTS + READOUT_DELAY <= t then
protocol.mspRead(msgFormat.read)
msg.reqTS = t
else
local cmd, rx_buf = mspPollReply()
extractMspValues(cmd, rx_buf, msgFormat, msg)
if msg.raw then
for i=1,#(msg.readoutValues) do
playNumber(msg.values[msg.readoutValues[i]], 0)
end
msg.raw = nil
end
end
mspProcessTxQ()
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/SCRIPTS/TOOLS/BF/NV14/nv14pre.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PageFiles =
{
{ title = "PIDs 1", script = "pids1.lua"},
{ title = "PIDs 2", script = "pids2.lua"},
{ title = "Rates", script = "rates.lua"},
{ title = "Advanced PIDs", script = "pid_advanced.lua"},
{ title = "Filters", script = "filters.lua"},
{ title = "vTX Settings", script = "vtx.lua"},
{ title = "Gyro / Motor", script = "pwm.lua"},
{ title = "Rx", script = "rx.lua"},
{ title = "GPS Rescue", script = "rescue.lua", requiredVersion = 1.041},
{ title = "GPS PIDs", script = "gpspids.lua", requiredVersion = 1.041},
}

MenuBox = { x= (LCD_W -200)/2, y=LCD_H/2, w=200, x_offset=68, h_line=20, h_offset=6 }
SaveBox = { x= (LCD_W -200)/2, y=LCD_H/2, w=180, x_offset=12, h=60, h_offset=12 }
NoTelem = { LCD_W/2 - 50, LCD_H - 28, "No Telemetry", TEXT_COLOR + INVERS + BLINK }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions src/SCRIPTS/TOOLS/BF/X7/x7pre.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PageFiles =
{
{ title = "vTX Settings", script = "vtx.lua"},
{ title = "Gyro / Motor", script = "pwm.lua"},
{ title = "PIDs 1", script = "pids1.lua"},
{ title = "PIDs 2", script = "pids2.lua"},
{ title = "Rates", script = "rates.lua"},
{ title = "Advanced PIDs", script = "pid_advanced.lua"},
{ title = "Filters", script = "filters.lua"},
{ title = "GPS Rescue", script = "rescue.lua", requiredVersion = 1.041},
{ title = "GPS PIDs", script = "gpspids.lua", requiredVersion = 1.041},
}

MenuBox = { x=15, y=12, w=100, x_offset=36, h_line=8, h_offset=3 }
SaveBox = { x=15, y=12, w=100, x_offset=4, h=30, h_offset=5 }
NoTelem = { 30, 55, "No Telemetry", BLINK }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/SCRIPTS/TOOLS/BF/X9/x9pre.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PageFiles =
{
{ title = "PIDs 1", script = "pids1.lua"},
{ title = "PIDs 2", script = "pids2.lua"},
{ title = "Rates", script = "rates.lua"},
{ title = "Advanced PIDs", script = "pid_advanced.lua"},
{ title = "Filters", script = "filters.lua"},
{ title = "vTX Settings", script = "vtx.lua"},
{ title = "Gyro / Motor", script = "pwm.lua"},
{ title = "Rx", script = "rx.lua"},
{ title = "GPS Rescue", script = "rescue.lua", requiredVersion = 1.041},
{ title = "GPS PIDs", script = "gpspids.lua", requiredVersion = 1.041},
}

MenuBox = { x=40, y=12, w=120, x_offset=36, h_line=8, h_offset=3 }
SaveBox = { x=40, y=12, w=120, x_offset=4, h=30, h_offset=5 }
NoTelem = { 70, 55, "No Telemetry", BLINK }
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/SCRIPTS/BF/radios.lua → src/SCRIPTS/TOOLS/BF/radios.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ local supportedRadios =
["x3"] = supportedPlatforms.x7,
["x7"] = supportedPlatforms.x7,
["x7s"] = supportedPlatforms.x7,
["x7-simu"] = supportedPlatforms.x7,
["t12"] = supportedPlatforms.x7,
["xlite"] = supportedPlatforms.x7,
["xlites"] = supportedPlatforms.x7,
["x9lite"] = supportedPlatforms.x7,
["x9d"] = supportedPlatforms.x9,
["x9d+"] = supportedPlatforms.x9,
["x9d+-simu"] = supportedPlatforms.x9,
["x9d+2019"] = supportedPlatforms.x9,
["x9e"] = supportedPlatforms.x9,
["x10"] = supportedPlatforms.horus,
["x10-simu"] = supportedPlatforms.horus,
["x10express"] = supportedPlatforms.horus,
["x12s"] = supportedPlatforms.horus,
["NV14"] = supportedPlatforms.nv14,
Expand Down
Loading