-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
feat(color): add FILE type for widget options #5605
Conversation
Just tested in simulator: works for me! Many thanks!!! |
If a widget wants to use this feature but uses fw without this PR, in simulator it gives a PANIC. |
LGTM with a dumb picture widget on TX16S. This should be handy for quite a few types of widget :) As has been the case when using other capabilities not existant in older firmware , a widget that uses this new option will simply not be available on older firmware. local name = "showimg"
-- Create a table with default options
-- Options can be changed by the user from the Widget Settings menu
-- Notice that each line is a table inside { }
local options = {
{ "File", FILE, "testimg.png", "/IMAGES"},
{ "Text", STRING, "Max8chrs" } -- now 12
}
local function log(s)
print("showimg: " .. s)
return
end
local function create(zone, options)
-- Runs one time when the widget instance is registered
-- Store zone and options in the widget table for later use
local wgt= {
zone = zone,
options = options
}
-- Return widget table to EdgeTX
return wgt
end
local function update(wgt, options)
-- Runs if options are changed from the Widget Settings menu
if (wgt == nil) then return end
wgt.options = options
end
local function background(wgt)
-- Runs periodically only when widget instance is not visible
end
local function refresh(wgt, event, touchState)
-- Runs periodically only when widget instance is visible
-- If full screen, then event is 0 or event value, otherwise nil
if (wgt == nil) then log("refresh(nil)") return end
if (wgt.options == nil) then log("refresh(wgt.options=nil)") return end
log("check if file exists")
local file = io.open("/IMAGES/" .. wgt.options.File, "r")
if file then
log("show image - " .. wgt.options.File)
io.close(file)
local myLogo = bitmap.open("/IMAGES/" .. wgt.options.File)
lcd.drawBitmap(myLogo,10,10)
else
log("refresh(wgt.options.File=not exist)")
return
end
end
return {
name = name,
options = options,
create = create,
update = update,
refresh = refresh,
background = background
} |
Where are you seeing a PANIC? If you try and use the option on 2.10 or earlier it should ignore the widget because of the unknown option type. |
In
|
Resolves #5573
Parameters:
Only the filename is returned for the option, excluding the path.
Filenames are limited to 12 characters maximum length.
Note
String widget option is increased from 8 characters to 12 characters
Example: