Skip to content

Instantly share code, notes, and snippets.

@pigeonhill
Last active March 24, 2019 07:36
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/7974b876c4fbf6de1b7ab1c3f64e77e6 to your computer and use it in GitHub Desktop.
Save pigeonhill/7974b876c4fbf6de1b7ab1c3f64e77e6 to your computer and use it in GitHub Desktop.
Simple ML script to cycle through different ML menu states
--[[
Cycler
[PLAY]+[Anykey, eg half shutter press] = null/reset [PLAY]
[PLAY]+{various button_delays}+[PLAY] = additional functionality as displayed in top bar
Note: functionally is temporally enhanced after pressing [PLAY], by waiting to see additional options appear then pressing [PLAY] to select
Version 0.42
Garry George March 2019
http://photography.grayheron.net/
--]]
config = 1 -- cam start configuration state
max_config = 6 -- adjust if you add additional states
button = KEY.PLAY -- or KEY.INFO or KEY.MENU etc
cycled = false
timer = dryos.ms_clock
timer_running = false
direction = 1
bookmark_apex = 10 -- Apex shutter value for (dark) bookmark, could be 11 or 12 etc. Note script auto resets the shutter after a bookmark image
current_shutter = camera.shutter.apex
del = {1000, 3000, 5000} -- Provide four time-based options in ms, ie 0-del[1], del[1]-del[2], del[2]-del[3], >del[3]
time_now = 0
count = dryos.shooting_card.file_number
-- start by nulling out menu items to control
menu.set("Expo","Auto ETTR",0)
menu.set("Shoot","Advanced Bracket",0)
menu.set("Expo","Dual ISO",0)
menu.set("Overlay","Magic Zoom",0)
menu.set("Overlay","Waveform",0)
-- add additional menu state changes here + adjust max_config value
function property.SHUTTER:handler(value) -- keep track of current shutter value for bookmark reset
if camera.shutter.apex ~= bookmark_apex then current_shutter = camera.shutter.apex end
end
function reset(k)
if cycled then
if config == 1 then -- reset everything
menu.set("Expo","Auto ETTR",0)
menu.set("Shoot","Advanced Bracket",0)
menu.set("Expo","Dual ISO",0)
menu.set("Overlay","Magic Zoom",0)
menu.set("Overlay","Waveform",0)
display.clear()
elseif config == 2 then -- switch to ETTR
menu.set("Shoot","Advanced Bracket",0)
menu.set("Expo","Auto ETTR",1)
elseif config == 3 then -- switch to bracketing
menu.set("Expo","Auto ETTR",0)
menu.set("Overlay","Magic Zoom",0)
menu.set("Shoot","Advanced Bracket",1)
elseif config == 4 then -- switch to Magic Zoom
menu.set("Shoot","Advanced Bracket",0)
menu.set("Expo","Dual ISO",0)
menu.set("Overlay","Magic Zoom",1)
elseif config == 5 then -- switch to Dual ISO
menu.set("Overlay","Magic Zoom",0)
menu.set("Overlay","Waveform",0)
display.clear()
menu.set("Expo","Dual ISO",1)
elseif config == 6 then -- switch to Waveform
menu.set("Expo","Dual ISO",0)
menu.set("Overlay","Waveform",1)
-- add other state changes here
-- elseif config == 7 etc
end
cycled = false
end
end
function test4reset(k)
if dryos.shooting_card.file_number ~= count then -- check after image captured
if camera.shutter.apex == bookmark_apex then camera.shutter.apex = current_shutter end -- reset shutter after bookmark taken
count = dryos.shooting_card.file_number
end
if k == button then
if timer_running then -- second press of [PLAY] in sequence
timer_running = false
if time_now - timer > del[3] then -- normal button action
cycled = false
return true
elseif (time_now - timer > del[2]) and (time_now - timer < del[3]) then -- reverse direction
cycled = false
direction = -direction
return false
elseif time_now - timer > del[1] then -- (re)set/toogle bookmark_apex
cycled = false
count = dryos.shooting_card.file_number
if camera.shutter.apex == bookmark_apex then
camera.shutter.apex = current_shutter
else
camera.shutter.apex = bookmark_apex
end
return false
else
config = config + direction
if config > max_config then config = 1 end
if config < 1 then config = max_config end
cycled = true
return false
end
else -- first press of [PLAY] in potential sequence
timer = dryos.ms_clock
timer_running = true
cycled = false
return false
end
end
cycled = false
timer_running = false
return true
end
lv.info
{
name = "Cycler State",
value = "",
priority = 100,
update = function(this)
time_now = dryos.ms_clock
this.background = COLOR.WHITE
if direction == 1 then this.foreground = COLOR.BLACK else this.foreground = COLOR.RED end
if timer_running and (time_now - timer > del[2]) and (time_now - timer < del[3]) then
this.foreground = COLOR.BLACK
this.value = "<<>>"
elseif timer_running and (time_now - timer > del[1]) and (time_now - timer < del[2]) then
this.foreground = COLOR.BLACK
this.value = "BOOK"
elseif timer_running and (time_now - timer > del[3]) then
this.foreground = COLOR.BLACK
this.value = "PLAY"
else
if config == 1 then
this.value = "NULL"
elseif config == 2 then
this.value = "ETTR"
elseif config == 3 then
this.value = "AUTO"
elseif config == 4 then
this.value = "ZOOM"
elseif config == 5 then
this.value = "DISO"
elseif config == 6 then
this.value = "WAVE"
-- add additional info here, ie four capital letters for consistancy
end
end
end
}
event.shoot_task = reset
event.keypress = test4reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment