I'm checking last things to be able to close PR and I have found a problem when using f-number with a dot (ex. 2.8, 4.5 ...)
Value is written correctly in Lens Info, MLV and .xmp sidecar but not in Manual Lens submenu (but it works when setting value in submenu itself)... It set automatically aperture to 1.0 when menu is opened
After reading again ML Lua Documentation and digging deep in lua's source code, I have now understood how value for a submenu with attribute "choices" is set.
I believe the problem here is in function update_menu() when assigning aperture... It expect a String but when assigning from lenses[].manual_aperture it return a Number
lenses = {
....
{ name = "Portrait 85mm", focal_length = 85, manual_aperture = 2.8 },
{ name = "Portrait 105mm", focal_length = 105, focal_min = 105, focal_max = 105, manual_aperture = 4.5 },
}
-- f-number values in 1/2 Stop
Fnumbers = {"1.0","1.2","1.4","1.7","2","2.4","2.8","3.3","4","4.8","5.6","6.7","8","9.5","11","13","16","19","22","27","32"}
lens_menu = menu.new
{
...
submenu =
{
...
{
name = "Aperture",
help = "Set Aperture to metadata",
choices = Fnumbers,
-- Update Aperture with selected value from submenu
update = function(this)
if lensSelected == true then
lens.manual_aperture = tonumber(this.value)
update_xmp()
else
-- Reset menu value to the corrected one
this.value = lens.manual_aperture
end end,
warning = function()
if lensSelected == false then
return "this value is not supported for non-manual lens"
end end,
}
},
...
}
-- Update the menu with values for Focal Length and Aperture from selected Lens
-- To be called when switching manual lens
function update_menu()
....
lens_menu.submenu["Aperture"].value = lens.manual_aperture
end
I tried converting to string by using:
lens_menu.submenu["Aperture"].value = tostring(lens.manual_aperture)
Doesn't works... instead this works when aperture value chosen is in Fnumbers{}:
lens_menu.submenu["Aperture"].value = "2.8"
Someone can explain to me why can't get it working? I have also tried to merge into lua_fix to get latest fixes, but nothing usefull happened.
Question: Should I include also 1/3 stop values to Fnumbers? Currently if an aperture value of the lens isn't found in Fnumbers when opening Manual Lens submenu, it get set to first index (ex. aperture 4.5 not found -> set by script to 1.0)
[EDIT]
It's a problem of floating points rapresentation in lua:
1.4 -> 1.399999
2.8 -> 2.799999
4.5 -> 4.5 (ok)
5.6 -> 5.59999