Skip to content
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

add Blackbox Info #492

Closed
wants to merge 1 commit 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
34 changes: 34 additions & 0 deletions src/SCRIPTS/BF/PAGES/blackbox.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local template = assert(loadScript(radio.template))()
local margin = template.margin
local indent = template.indent
local lineSpacing = template.lineSpacing
local tableSpacing = template.tableSpacing
local sp = template.listSpacing.field
local yMinLim = radio.yMinLimit
local x = margin
local y = yMinLim - lineSpacing
local inc = { x = function(val) x = x + val return x end, y = function(val) y = y + val return y end }
local labels = {}
local fields = {}

if apiVersion >= 1.45 then
fields[#fields + 1] = { t = "flags", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 2, vals = { 1 }, table = { [0] = "NOT_SUPPORTED", "SUPPORTED" } }
fields[#fields + 1] = { t = "state", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 4, vals = { 2 }, table = { [0] = "NOT_PRESENT", "FATAL", "CARD_INIT", "FS_INIT", "READY" } }
fields[#fields + 1] = { t = "lastError", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 9, vals = { 3 } }
fields[#fields + 1] = { t = "freeSpace MB", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 9999999999, vals = { 4, 5, 6, 7 }, scale = 1024, upd = function(self) self.updateItems(self) end }
fields[#fields + 1] = { t = "totalSpace MB", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 9999999999, vals = { 8, 9, 10, 11 }, scale = 1024 }
end

return {
read = 79, -- MSP_SDCARD_SUMMARY
-- write = 72, -- MSP_DATAFLASH_ERASE
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to also allow erase function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have testes this But nötig happens also if i send no value

Copy link
Member

@haslinghuis haslinghuis Dec 6, 2023

Choose a reason for hiding this comment

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

msp code 72 only works for erasing flash chip and will take some time to complete.
You can poll ready flag with first byte from msp code 70 but need to consume whole payload (13 bytes).

ready = (1st byte & 1) != 0;
supported = (1st byte & 2) != 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok then i will have a Look thx for information

title = "Blackbox Info",
reboot = false,
eepromWrite = false,
minBytes = 0,
labels = labels,
fields = fields,
updateItems = function(self)
self.fields[4].value = string.format("%.0f",self.fields[4].value)
end,
}
4 changes: 4 additions & 0 deletions src/SCRIPTS/BF/pages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ if apiVersion >= 1.45 then
PageFiles[#PageFiles + 1] = { title = "OSD Elements", script = "pos_osd.lua" }
end

if apiVersion >= 1.45 then
PageFiles[#PageFiles + 1] = { title = "Blackbox", script = "blackbox.lua" }
end

return PageFiles