Skip to content

Instantly share code, notes, and snippets.

@pigeonhill
Last active June 7, 2017 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigeonhill/016e12d86e2a91dcc11ee7818e7848a2 to your computer and use it in GitHub Desktop.
Save pigeonhill/016e12d86e2a91dcc11ee7818e7848a2 to your computer and use it in GitHub Desktop.
Toggler for cameras with limited buttons
--[[
Still photography toggler script.
This is a stripped down version of the full Toggler, recognising the the lack of buttons to toggle with some cameras.
It will run on other ML enabled cameras.
Toggles through preset ML settings using the PLAY button.
Make sure ML menus are preset to the your toggled states.
Version 1
Garry George August 2016
http://photography.grayheron.net/
--]]
-- Declare some global variables
toggler_play = 1
toggler = KEY.PLAY -- Can be changed to other buttons if available
frsp = false
frsp_ok = false
function property.SHUTTER:handler(value) -- Check if shutter value changed between toggles
if scriptmenu.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 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", -- ETTR mode
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", -- DUAL 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 = 1},
}
},
{
name = "D+ET", -- DUAL + 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 = 1},
}
},
{
name = "BRAC", -- Auto Bracketing
menus=
{
{ menu = "Shoot", item = "Advanced Bracket", value = 1},
{ menu = "Shoot", item = "Silent Picture", value = 0},
{ menu = "Expo", item = "Auto ETTR", value = 0},
{ menu = "Auto ETTR", item = "Shadow SNR limit", value = 0},
{ menu = "Expo", item = "Dual ISO", value = 0},
}
},
{
name = "FRSP", -- Full Res Silent Picture
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},
}
},
}
-- You can add other ML 'menu states' by adding to oe extending the above list
mykeypress = function(key)
if key == toggler and lv.enabled then
toggler_play = toggler_play + 1
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 in this toggle
if frsp then -- check shutter value
if camera.shutter.value < 0.2 or camera.shutter.value > 14 then
frsp_ok = false -- outside FRSP range
display.notify_box("Check your shutter speed", 3000)
menu.set("Shoot","Silent Picture",0)
end
end
return false
else
return true
end
end
lv.info
{
name = "Toggler Info",
priority = 100,
value = "",
update = function(this)
this.background = COLOR.BLUE
this.foreground = COLOR.YELLOW
if scriptmenu.submenu["Enabled?"].value == "Yes" then
if frsp and not frsp_ok then this.foreground = COLOR.RED end
this.value = toggler_presets[toggler_play].name
else
this.value = ""
end
end
}
scriptmenu = menu.new
{
parent = "Shoot",
name = "Toggler",
help = "Toggle through various preset ML options",
submenu =
{
{
name = "Enabled?",
help = "Switches the script's on/off state when in LV mode",
choices = {"No","Yes"},
depends_on = DEPENDS_ON.LIVEVIEW,
icon_type = ICON_TYPE.BOOL,
value = "No", -- ensures script not loaded on camera start
select = function(this)
if this.value == "Yes" then
this.value = "No"
event.keypress = nil
else
this.value = "Yes"
event.keypress = mykeypress
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
end
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment