#344 renderer integration with new assertion handling
This commit is contained in:
@@ -5,18 +5,23 @@
|
||||
local main_view = require("pocket.ui.main")
|
||||
local style = require("pocket.ui.style")
|
||||
|
||||
local core = require("graphics.core")
|
||||
local flasher = require("graphics.flasher")
|
||||
|
||||
local DisplayBox = require("graphics.elements.displaybox")
|
||||
|
||||
---@class pocket_renderer
|
||||
local renderer = {}
|
||||
|
||||
local ui = {
|
||||
display = nil
|
||||
}
|
||||
|
||||
-- start the pocket GUI
|
||||
function renderer.start_ui()
|
||||
-- try to start the pocket GUI
|
||||
---@return boolean success, any error_msg
|
||||
function renderer.try_start_ui()
|
||||
local status, msg = true, nil
|
||||
|
||||
if ui.display == nil then
|
||||
-- reset screen
|
||||
term.setTextColor(colors.white)
|
||||
@@ -30,12 +35,22 @@ function renderer.start_ui()
|
||||
end
|
||||
|
||||
-- init front panel view
|
||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
||||
main_view(ui.display)
|
||||
status, msg = pcall(function ()
|
||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
||||
main_view(ui.display)
|
||||
end)
|
||||
|
||||
-- start flasher callback task
|
||||
flasher.run()
|
||||
if status then
|
||||
-- start flasher callback task
|
||||
flasher.run()
|
||||
else
|
||||
-- report fail and close ui
|
||||
msg = core.extract_assert_msg(msg)
|
||||
renderer.close_ui()
|
||||
end
|
||||
end
|
||||
|
||||
return status, msg
|
||||
end
|
||||
|
||||
-- close out the UI
|
||||
|
||||
Reference in New Issue
Block a user