Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/SCRIPTS/BF/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local currentState = pageStatus.display
local requestTimeout = 80 -- 800ms request timeout
local currentPage = 1
local currentLine = 1
local availablePages = #(PageFiles)
local saveTS = 0
local saveTimeout = 0
local saveRetries = 0
Expand Down Expand Up @@ -355,10 +356,23 @@ function run_ui(event)
end
end
while Page == nil do
Page = assert(loadScript(radio.templateHome .. PageFiles[currentPage]))()
if Page.requiredVersion and Page.requiredVersion > apiVersion then
if PageFiles[currentPage] then
Page = assert(loadScript(radio.templateHome .. PageFiles[currentPage]))()
if Page.requiredVersion and apiVersion > 0 then
if Page.requiredVersion > apiVersion then
PageFiles[currentPage] = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause problems if users are using multiple craft with different firmware versions with the same TX side model, and do not power cycle their TX in between.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone would be required to power cycle or change models anyway if they want to obtain the API version, too. The init function only runs once at the time of initial invocation, so there's a possibility that the API version retained in memory might not match the new FC. If they do match, though, the same set of pages would still be compatible.

Copy link
Member

@mikeller mikeller Apr 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init function runs every time a connection is established. As a consequence, the API version will be queried again after models have been changed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the init functions confused I think... apologies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe re-seed the pages here?

if dataInitialised then
data_init = nil
collectgarbage()
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a lot of complexity for not much gain, compared to what I have proposed in #203.

But adding the graceful exit makes sense.

availablePages = availablePages - 1
incPage(1)
end
end
else
incPage(1)
end
if availablePages < 1 then
lcd.clear()
lcd.drawText(NoTelem[1], NoTelem[2], "No Pages Available!", NoTelem[4])
return 1
end
end
if not Page.values and currentState == pageStatus.display then
requestPage()
Expand Down