Skip to content

Commit 3d5b716

Browse files
committed
Add apiVersion detection for TOOLS script
1 parent 9b0f34f commit 3d5b716

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/SCRIPTS/BF/ui.lua

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
local uiStatus =
22
{
3-
mainMenu = 1,
3+
init = 1,
44
pages = 2,
5+
mainMenu = 3,
56
}
67

78
local pageStatus =
@@ -20,7 +21,7 @@ local uiMsp =
2021

2122
local menuLine = 1
2223
local pageCount = 1
23-
local uiState = uiStatus.mainMenu
24+
local uiState = uiStatus.init
2425
local pageState = pageStatus.display
2526
local requestTimeout = 80 -- 800ms request timeout
2627
local currentPage = 1
@@ -37,6 +38,7 @@ local pageScrollY = 0
3738
local mainMenuScrollY = 0
3839

3940
local Page = nil
41+
local background = nil
4042

4143
local backgroundFill = TEXT_BGCOLOR or ERASE
4244
local foregroundColor = LINE_COLOR or SOLID
@@ -298,14 +300,32 @@ function run_ui(event)
298300
if isTelemetryScript then
299301
uiState = uiStatus.pages
300302
else
301-
uiState = uiStatus.mainMenu
303+
uiState = uiStatus.init
302304
end
303305
end
304306
lastRunTS = now
305307
if isTelemetryScript then
306308
uiState = uiStatus.pages
307309
end
308-
if uiState == uiStatus.mainMenu then
310+
if uiState == uiStatus.init then
311+
local yMinLim = radio.yMinLimit
312+
lcd.clear()
313+
drawScreenTitle("Betaflight Config", 0, 0)
314+
lcd.drawText(6, yMinLim, "Initialising")
315+
if apiVersion == 0 then
316+
if not background then
317+
background = assert(loadScript("/SCRIPTS/BF/background.lua"))()
318+
background.init()
319+
else
320+
background.run_bg()
321+
end
322+
return 0
323+
else
324+
background = nil
325+
invalidatePages()
326+
uiState = uiStatus.mainMenu
327+
end
328+
elseif uiState == uiStatus.mainMenu then
309329
getPageCount()
310330
if event == EVT_VIRTUAL_EXIT then
311331
return 2

0 commit comments

Comments
 (0)