Last active
June 12, 2016 16:00
-
-
Save pigeonhill/6fd92bf47f18c77d4892db74c745a477 to your computer and use it in GitHub Desktop.
ML Menu state toggler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Still photography toggler script | |
NOTE: Tested on a 5D3 and 50D | |
Version 2 (should work on all ML enabled cameras with the Lua module BUT maybe not the EOSM) | |
Garry George June 2016 | |
http://photography.grayheron.net/ | |
Toggles through ML settings using the multi-controller toggle, plus a button you rarely use. | |
Must be in LV. | |
--]] | |
-- Declare some variables | |
toggler_play = 1 | |
toggler = KEY.RATE -- change this to your choice, eg PLAY | |
frsp = false | |
frsp_ok = false | |
iso = false | |
iso_delta = 0 | |
iso_apex = 5 | |
iso_toggled = false | |
enabled = true | |
toggled = 0 | |
-- Change toggler value to your choice of button, eg KEY.RATE or KEY.PLAY. | |
-- See http://davidmilligan.github.io/ml-lua/modules/constants.html for key constants | |
-- Default is KEY.RATE | |
function property.SHUTTER:handler(value) -- Check if shutter value changed between toggles | |
if keymenu.submenu["Enabled?"].value == "Yes" and frsp then -- then need to recheck FRSP values in case user changes shutter speed | |
if camera.shutter.value < 0.2 or camera.shutter.value > 14 then | |
frsp_ok = false -- outside FRSP range | |
menu.set("Shoot","Silent Picture",0) | |
else | |
frsp_ok = true -- Good to go with FRSP | |
menu.set("Shoot","Silent Picture",1) | |
end | |
end | |
end | |
toggler_presets = | |
{ | |
{ | |
name = "OFF ", -- Toggler active but all ML Toggler menus turned off | |
menus= | |
{ | |
{ menu = "Shoot", item = "Advanced Bracket", value = 0}, | |
{ menu = "Shoot", item = "Silent Picture", value = 0}, | |
{ menu = "Expo", item = "Auto ETTR", value = 0}, | |
{ menu = "Expo", item = "Dual ISO", value = 0}, | |
} | |
}, | |
{ | |
name = "ETTR", | |
menus= | |
{ | |
{ menu = "Shoot", item = "Advanced Bracket", value = 0}, | |
{ menu = "Shoot", item = "Silent Picture", value = 0}, | |
{ menu = "Expo", item = "Auto ETTR", value = 1}, | |
{ menu = "Expo", item = "Dual ISO", value = 0}, | |
} | |
}, | |
{ | |
name = "DUAL", | |
menus= | |
{ | |
{ menu = "Shoot", item = "Advanced Bracket", value = 0}, | |
{ menu = "Shoot", item = "Silent Picture", value = 0}, | |
{ menu = "Expo", item = "Auto ETTR", value = 0}, | |
{ menu = "Expo", item = "Dual ISO", value = 1}, | |
} | |
}, | |
{ | |
name = "BRAC", | |
menus= | |
{ | |
{ menu = "Shoot", item = "Advanced Bracket", value = 1}, | |
{ menu = "Shoot", item = "Silent Picture", value = 0}, | |
{ menu = "Expo", item = "Auto ETTR", value = 0}, | |
{ menu = "Expo", item = "Dual ISO", value = 0}, | |
} | |
}, | |
{ | |
name = "FRSP", | |
menus= | |
{ | |
{ menu = "Shoot", item = "Advanced Bracket", value = 0}, | |
{ menu = "Shoot", item = "Silent Picture", value = 1}, | |
{ menu = "Expo", item = "Auto ETTR", value = 0}, | |
{ menu = "Expo", item = "Dual ISO", value = 0}, | |
} | |
}, | |
{ | |
name = "ISO ", | |
menus= | |
{ | |
{ menu = "Shoot", item = "Advanced Bracket", value = 0}, | |
{ menu = "Shoot", item = "Silent Picture", value = 0}, | |
{ menu = "Expo", item = "Auto ETTR", value = 0}, | |
{ menu = "Expo", item = "Dual ISO", value = 0}, | |
} | |
} | |
} | |
-- You can add other ML 'menu states' by extending the above list or change what each toggled state does by adding or subtracting menu references | |
event.keypress = function(key) | |
if keymenu.submenu["Enabled?"].value == "No" then -- Toggler does nothing and shows no menu states | |
return true | |
else -- Toggler active, and can be enabled and disabled by toggling the Toggler button | |
if key == toggler then enabled = not enabled return false end -- Enable/disable Toggler | |
if enabled then -- look to see what to do | |
if key == KEY.LEFT then | |
toggled = -1 | |
return false | |
elseif key == KEY.RIGHT then | |
toggled = 1 | |
return false | |
-- Note the following is necessary to account for some 'Lua strangeness', where, from my experience, the 5D3 and 50D return different codes when the | |
-- multi functional switch is unpressed | |
elseif (key == KEY.UNPRESS_UDLR or key == KEY.UNPRESS_DP) and not iso_toggled then -- toggled left or right | |
iso = false | |
toggler_play = toggler_play + toggled | |
toggled = 0 | |
if toggler_play > #toggler_presets then toggler_play = 1 end | |
if toggler_play < 1 then toggler_play = #toggler_presets end | |
for i,v in ipairs(toggler_presets[toggler_play].menus) do | |
menu.set(v.menu,v.item,v.value) | |
end | |
if toggler_presets[toggler_play].name == "FRSP" then frsp = true else frsp = false end -- check if FRSP set to ON in this toggle | |
if toggler_presets[toggler_play].name == "ISO " then iso = true else iso = false end -- check if ISO set to ON in this toggle | |
if frsp then -- check shutter values following toggle and FRSP requested | |
if camera.shutter.value < 0.2 or camera.shutter.value > 14 then | |
frsp_ok = false -- outside FRSP range | |
menu.set("Shoot","Silent Picture",0) | |
else | |
frsp_ok = true -- Good to go with FRSP | |
menu.set("Shoot","Silent Picture",1) | |
end | |
end | |
return false | |
elseif key == KEY.UP or key == KEY.UP_RIGHT or key == KEY.UP_LEFT then | |
if iso then -- change iso | |
iso_delta = 0.333 | |
iso_toggled = true | |
toggled = 0 | |
else | |
iso_delta = 0 | |
iso_toggled = false | |
toggled = 0 | |
end | |
return false | |
elseif key == KEY.DOWN or key == KEY.DOWN_RIGHT or key == KEY.DOWN_LEFT then | |
if iso then -- change iso | |
iso_delta = -0.333 | |
iso_toggled = true | |
toggled = 0 | |
else | |
iso_delta = 0 | |
iso_toggled = false | |
toggled = 0 | |
end | |
return false | |
-- Same comment as above | |
elseif (key == KEY.UNPRESS_UDLR or key == KEY.UNPRESS_DP) and iso_toggled then -- ISO increased or decresed | |
iso_toggled = false | |
iso_apex = camera.iso.apex + iso_delta | |
if iso_apex < 5 then iso_apex = 5 end | |
camera.iso.apex = iso_apex | |
return false | |
else | |
iso_delta = 0 | |
toggled = 0 | |
return true | |
end | |
end | |
end | |
end | |
lv.info | |
{ | |
name = "Info 1", | |
priority = 100, | |
value = "", | |
update = function(this) | |
this.background = COLOR.BLUE | |
this.foreground = COLOR.YELLOW | |
if keymenu.submenu["Enabled?"].value == "Yes" and enabled then | |
if frsp then -- FRSP requested then need to feedback FRSP shutter speed is OK or not | |
if not frsp_ok then this.foreground = COLOR.RED end | |
end | |
this.value = toggler_presets[toggler_play].name | |
else | |
this.value = "" | |
end | |
end | |
} | |
keymenu = menu.new | |
{ | |
parent = "Shoot", | |
name = "Toggler", | |
help = "Toggle through various ML options", | |
depends_on = DEPENDS_ON.LIVEVIEW, | |
submenu = | |
{ | |
{ | |
name = "Enabled?", | |
help = "Switches the script on/off", | |
choices = {"No","Yes"}, | |
icon_type = ICON_TYPE.BOOL, | |
value = "Yes", -- ensures script loaded and active on camera start | |
select = function(this) | |
if this.value == "Yes" then | |
this.value = "No" | |
else | |
this.value = "Yes" | |
end | |
-- Reset Toggler if enabled state changed | |
menu.set("Shoot","Silent Picture",0) | |
menu.set("Shoot","Advanced Bracket",0) | |
menu.set("Expo","Auto ETTR",0) | |
menu.set("Expo","Dual ISO",0) | |
toggler_play = 1 | |
frsp = false | |
iso = false | |
iso_delta = 0 | |
end | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment