Instantly share code, notes, and snippets.

Embed
What would you like to do?
Toggler Version B
--[[
Simple (no menu, ie runs in the background) script to help control ML states to your ML favorite states using your buttons of choice,
for example the MENU, PLAY & INFO buttons on the EOSM work well.
Note this is Version B, ie doing it a different way
To use the script simply note the following sequences on an EOSM (but you can change these for other cameras):
[MENU] = normal use of [MENU] if not in imode
[PLAY][PLAY] = normal use of [PLAY]
[PLAY][INFO] = enter toggler interactive imode
In imode [PLAY] and [MENU] will toggle back and forwards through your ML condition states giving you an on-screen message
In imode [INFO] will set that condition and leave interactive mode.
In imode pressing any other key, eg [SET] (not [MENU], [INFO] or [PLAY]) will leave interactive mode
Change/set the preset table below and the chunks of script to your liking, but note the need to keep track of ML states as you move between
toggled conditions, eg change functions reset() & display_message()
Version B1.14
Garry George December 2017
http://photography.grayheron.net/
--]]
last_key_pressed = 999
imode = false
config = 1
last_config = 1
-- Change the buttons to your choice, for example
-- B1 = PLAY and B2 = INFO on an 5D3, and B1 = INFO and B2 = PLAY on a EOSM
button_1 = KEY.INFO -- imode switch and set
button_2 = KEY.PLAY -- used to go forwards in imode
button_3 = KEY.MENU -- used to go backwards in imode
message_flag = false
change = false
-- The colours can be changed to your choice. See here - http://builds.magiclantern.fm/lua_api/modules/constants.html#COLOR
display_color = COLOR.BLACK
con = COLOR.GREEN1 -- 'On' state
coff = COLOR.RED -- 'Off' state
presets =
{
{
name = "Exit & Do Nothing",
color = COLOR.BLACK,
},
{
name = "Open ML menu",
color = COLOR.BLACK,
},
{
name = "FB ON/OFF",
color = COLOR.BLACK,
},
{
name = "FB Sacking ON/OFF",
color = COLOR.BLACK,
},
{
name = "Show Info",
color = COLOR.BLACK,
},
{
name = "Auto ETTR", -- Only Auto ETTR
color = COLOR.BLACK,
},
{
name = "Dual ISO", -- Only DUAL ISO
color = COLOR.BLACK,
},
{
name = "ML Auto Bracketing", -- Auto Bracketing
color = COLOR.BLACK,
},
-- add other presets here
}
function reset(k)
message_flag = false
if presets[k].name == "Exit & Do Nothing" then
-- do nothing
elseif presets[k].name == "Open ML menu" then
menu.open()
-- The following elseif chuncks simply control toggling of the menu state you have selected
-- I've done it this 'long winded' way so you can easily add/subtract from it'
elseif presets[k].name == "FB ON/OFF" then -- if FB not present, does nothing
if menu.get("Focus Bar","Display","") == "ON" then
menu.set("Focus Bar","Display","OFF")
presets[k].color = coff
else
menu.set("Focus Bar","Display","ON")
presets[k].color = con
end
elseif presets[k].name == "Show Info" then -- if FB not present, does nothing
menu.set("Focus Bar","update","ON") -- flag to alert the Focus Bar
if menu.get("Focus Bar","Show Info","") == "Simple" then
menu.set("Focus Bar","Show Info","Full")
presets[k].color = coff
else
menu.set("Focus Bar","Show Info","Simple")
presets[k].color = con
end
elseif presets[k].name == "FB Sacking ON/OFF" then -- if FB not present, does nothing
if menu.get("Focus Bar","Focus Stacking","") == "ON" then
menu.set("Focus Bar","Focus Stacking","OFF")
presets[k].color = coff
else
menu.set("Focus Bar","Focus Stacking","ON")
presets[k].color = con
end
elseif presets[k].name == "Dual ISO" then
if menu.get("Expo","Dual ISO",1) == 1 then
menu.set("Expo","Dual ISO",0)
presets[k].color = coff
else
menu.set("Expo","Dual ISO",1)
presets[k].color = con
end
elseif presets[k].name == "Auto ETTR" then
if menu.get("Expo","Auto ETTR",1) == 1 then
menu.set("Expo","Auto ETTR",0)
presets[k].color = coff
else
menu.set("Expo","Auto ETTR",1)
presets[k].color = con
end
elseif presets[k].name == "ML Auto Bracketing" then
if menu.get("Shoot","Advanced Bracket",1) == 1 then
menu.set("Shoot","Advanced Bracket",0)
presets[k].color = coff
else
menu.set("Shoot","Advanced Bracket",1)
presets[k].color = con
end
-- add others menus to toggle here
end
end
function test4reset(k)
-- check for imode in ML menu not showing
if not menu.visible and lv.running then -- ok to use
change = false
if imode then
if k == button_2 then -- move forward through presets
last_config = config
config = config + 1
if config > #presets then config = 1 end
message_flag = true
return false
end
if k == button_3 then -- move backwards through presets
last_config = config
config = config - 1
if config == 0 then config = #presets end
message_flag = true
return false
end
if k == button_1 then -- leave imode and reset ML menus as requested
imode = false
change = true
message_flag = true
return false
end
end
imode = false
if k == button_2 and last_key_pressed == button_2 then -- use key as normal
last_key_pressed = 999 -- reset
return true
elseif (k == button_1 and last_key_pressed == button_2) then -- go into imode
imode = true
last_key_pressed = 999
config = 1
message_flag = true
return false -- steal key press
elseif k == button_2 then -- first press of button_2 key in new sequence
last_key_pressed = button_2
imode = false
return false -- steal key press
else
imode = false
last_key_pressed = 999 -- reset
return true -- use all other keys in an unmodified way
end
else -- don't use script
message_flag = false
return true
end
end
function display_message(arg)
if message_flag then
local k = config
-- The following if-then section handles the display colours that show you the existing menu state, and the selected colour state on exiting Toggler
if presets[k].name == "FB ON/OFF" then
if menu.get("Focus Bar","Display","") == "ON" then presets[k].color = con else presets[k].color = coff end
elseif presets[k].name == "Dual ISO" then
if menu.get("Expo","Dual ISO",1) == 1 then presets[k].color = con else presets[k].color = coff end
elseif presets[k].name == "Auto ETTR" then
if menu.get("Expo","Auto ETTR",1) == 1 then presets[k].color = con else presets[k].color = coff end
elseif presets[k].name == "FB Sacking ON/OFF" then
if menu.get("Focus Bar","Focus Stacking","") == "ON" then presets[k].color = con else presets[k].color = coff end
elseif presets[k].name == "ML Auto Bracketing" then
if menu.get("Shoot","Advanced Bracket",1) == 1 then presets[k].color = con else presets[k].color = coff end
elseif presets[k].name == "Show Info" then
if menu.get("Focus Bar","Show Info","") == "Simple" then presets[k].color = con else presets[k].color = coff end
-- repeat above here to manage color changes (if you want to)
end
local qq = 0
local message = ""
if change then
message = presets[config].name
reset(config) -- toggle
qq = FONT.LARGE:width(message)/2
display.print(message,360-qq, 260,FONT.LARGE,presets[config].color,COLOR.WHITE)
msleep(1000)
display.print(message,360-qq, 260,FONT.LARGE,COLOR.TRANSPARENT,COLOR.TRANSPARENT)
change = false
else
message = presets[last_config].name
qq = FONT.LARGE:width(message)/2
display.print(message,360-qq, 260,FONT.LARGE,COLOR.TRANSPARENT,COLOR.TRANSPARENT)
message = presets[config].name
qq = FONT.LARGE:width(message)/2
display.print(message, 360-qq, 260,FONT.LARGE,presets[config].color,COLOR.WHITE)
message_flag = false
end
end
end
event.shoot_task = display_message
event.keypress = test4reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment