Skip to content
Merged
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
2 changes: 0 additions & 2 deletions src/SCRIPTS/BF/protocols.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ local supportedProtocols =
{
transport = SCRIPT_HOME.."/MSP/sp.lua",
rssi = function() return getValue("RSSI") end,
exitFunc = function() return 0 end,
stateSensor = "Tmp1",
push = sportTelemetryPush,
maxTxBufferSize = 6,
Expand All @@ -16,7 +15,6 @@ local supportedProtocols =
{
transport = SCRIPT_HOME.."/MSP/crsf.lua",
rssi = function() return getValue("TQly") end,
exitFunc = function() return "/CROSSFIRE/crossfire.lua" end,
stateSensor = "1RSS",
push = crossfireTelemetryPush,
maxTxBufferSize = 8,
Expand Down
41 changes: 9 additions & 32 deletions src/SCRIPTS/BF/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ local saveTimeout = 0
local saveRetries = 0
local saveMaxRetries = 0
local popupMenuActive = false
local lastRunTS = 0
local killEnterBreak = 0
local stopDisplay = false
local pageScrollY = 0
local mainMenuScrollY = 0
local PageFiles = nil
Expand Down Expand Up @@ -273,13 +271,6 @@ local function drawPopupMenu()
end

local function run_ui(event)
local now = getTime()
-- if lastRunTS old than 500ms
if lastRunTS + 50 < now then
invalidatePages()
uiState = uiStatus.init
end
lastRunTS = now
if uiState == uiStatus.init then
local yMinLim = radio.yMinLimit
lcd.clear()
Expand All @@ -295,11 +286,7 @@ local function run_ui(event)
background = nil
PageFiles = assert(loadScript("/SCRIPTS/BF/pages.lua"))()
invalidatePages()
if isTelemetryScript then
uiState = uiStatus.pages
else
uiState = uiStatus.mainMenu
end
uiState = uiStatus.mainMenu
end
elseif uiState == uiStatus.mainMenu then
if event == EVT_VIRTUAL_EXIT then
Expand Down Expand Up @@ -336,7 +323,7 @@ local function run_ui(event)
end
elseif uiState == uiStatus.pages then
if (pageState == pageStatus.saving) then
if (saveTS + saveTimeout < now) then
if (saveTS + saveTimeout < getTime()) then
if saveRetries < saveMaxRetries then
saveSettings()
else
Expand All @@ -347,10 +334,7 @@ local function run_ui(event)
end
end
-- navigation
if isTelemetryScript and event == EVT_VIRTUAL_MENU_LONG then -- telemetry script
popupMenuActive = 1
pageState = pageStatus.popupMenu
elseif (not isTelemetryScript) and event == EVT_VIRTUAL_ENTER_LONG then -- standalone
if event == EVT_VIRTUAL_ENTER_LONG then
popupMenuActive = 1
killEnterBreak = 1
pageState = pageStatus.popupMenu
Expand All @@ -372,10 +356,10 @@ local function run_ui(event)
end
-- normal page viewing
elseif pageState <= pageStatus.display then
if not isTelemetryScript and event == EVT_VIRTUAL_PREV_PAGE then
if event == EVT_VIRTUAL_PREV_PAGE then
incPage(-1)
killEvents(event) -- X10/T16 issue: pageUp is a long press
elseif (not isTelemetryScript and event == EVT_VIRTUAL_NEXT_PAGE) or (isTelemetryScript and event == EVT_VIRTUAL_MENU) then
elseif event == EVT_VIRTUAL_NEXT_PAGE then
incPage(1)
elseif event == EVT_VIRTUAL_PREV or event == EVT_VIRTUAL_PREV_REPT then
incField(-1)
Expand All @@ -389,11 +373,10 @@ local function run_ui(event)
end
end
elseif event == EVT_VIRTUAL_EXIT then
if isTelemetryScript then
return protocol.exitFunc();
else
stopDisplay = true
end
invalidatePages()
currentField = 1
uiState = uiStatus.mainMenu
return 0
end
-- editing value
elseif pageState == pageStatus.editing then
Expand Down Expand Up @@ -433,12 +416,6 @@ local function run_ui(event)
lcd.drawText(radio.SaveBox.x+radio.SaveBox.x_offset,radio.SaveBox.y+radio.SaveBox.h_offset,"Retrying",DBLSIZE + (globalTextOptions))
end
end
if stopDisplay and (not isTelemetryScript) then
invalidatePages()
currentField = 1
uiState = uiStatus.mainMenu
stopDisplay = false
end
end
-- process send queue
mspProcessTxQ()
Expand Down
39 changes: 3 additions & 36 deletions src/SCRIPTS/TELEMETRY/bf.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
SCRIPT_HOME = "/SCRIPTS/BF"

apiVersion = 0
isTelemetryScript = true

protocol = assert(loadScript(SCRIPT_HOME.."/protocols.lua"))()
radio = assert(loadScript(SCRIPT_HOME.."/radios.lua"))()

assert(loadScript(SCRIPT_HOME.."/pages.lua"))()
assert(loadScript(protocol.transport))()
assert(loadScript(SCRIPT_HOME.."/MSP/common.lua"))()

local run_ui = assert(loadScript(SCRIPT_HOME.."/ui.lua"))()
local background = assert(loadScript(SCRIPT_HOME.."/background.lua"))()

local MENU_TIMESLICE = 100

local lastMenuEvent = 0

local function run(event)
if background then
background = nil
collectgarbage()
end
lastMenuEvent = getTime()
run_ui(event)
end

local function run_bg()
if lastMenuEvent + MENU_TIMESLICE < getTime() then
if not background then
background = assert(loadScript(SCRIPT_HOME.."/background.lua"))()
collectgarbage()
end
background()
end
lcd.clear()
lcd.drawText(2, 2, "Use TOOLS menu instead of this")
end

return { run=run, background=run_bg }
return { run=run }
2 changes: 0 additions & 2 deletions src/SCRIPTS/TOOLS/bf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ local toolName = "TNS|Betaflight setup|TNE"
SCRIPT_HOME = "/SCRIPTS/BF"

apiVersion = 0
isTelemetryScript = false

protocol = assert(loadScript(SCRIPT_HOME.."/protocols.lua"))()
radio = assert(loadScript(SCRIPT_HOME.."/radios.lua"))()

assert(loadScript(SCRIPT_HOME.."/pages.lua"))()
assert(loadScript(protocol.transport))()
assert(loadScript(SCRIPT_HOME.."/MSP/common.lua"))()

Expand Down