Button version of Cycler
--[[ | |
Cycler B(utton version) | |
[PLAY] = A hijacked button that (repeatedly pressing) allows you to cycle through various options that this button can do: change ML state to the next one, use [PlAY] normally, shoot a bookmark image | |
Straight after [PLAY] | |
[Half_Shutter_Press] = reverse state change cycle direction (black = to the right, red = anitclocto the left) | |
[MENU] = select/run option | |
[anykey] other than [PLAY] or [MENU] when cycling = normal action plus resets cycle and show the ML state you are in | |
Options and ML states are shown in RHS of the ML top bar | |
The script can be switched off in the ML Shoot menu | |
Version 1.241 | |
Garry George April 2019 | |
http://photography.grayheron.net/ | |
--]] | |
config_ref = 1 -- start cam in nulled out state, see reset function below | |
config_states = {"NULL", "ETTR","AUTO","ZOOM","DISO","WAVE"} -- add/change as required but make sure you manage changes in function reset | |
button = KEY.PLAY -- could use KEY.INFO or KEY.MENU etc, but best not to use KEY.SET | |
select_button = KEY.MENU -- could use KEY.INFO or KEY.PLAY etc, but best not to use KEY.SET | |
cycled = true -- ensures ML states nulled out on cam start | |
selected = false | |
button_pressed = false | |
direction = 1 -- used to cycle ML states 'clockwise' or 'anticlockwise' | |
bookmark_apex = 11 -- APEX shutter value for (dark) bookmark, could be 10 or 12 etc. Note script auto resets the shutter after a bookmark image | |
current_shutter = camera.shutter.apex | |
options = {"CYCL","PLAY","BOOK"} -- add more or change, but ensure you reflect changes below in function reset | |
option = 1 | |
use_normally = false | |
last_key = 0 | |
option_1_vis = false | |
switched_off = false | |
CON = {"ON","OFF"} | |
function reset(m) | |
if switched_off then return true end | |
if selected then | |
selected = false | |
button_pressed = false -- reset [button] | |
if option == 1 then -- cycle ML states | |
config_ref = config_ref + direction | |
if config_ref > #config_states then config_ref = 1 end | |
if config_ref < 1 then config_ref = #config_states end | |
cycled = true | |
elseif option == 2 then -- normal button action | |
use_normally = true | |
option = 1 -- reset button to cycle | |
key.press(button) | |
elseif option == 3 then -- take a bookmark image | |
current_shutter = camera.shutter.apex | |
camera.shutter.apex = bookmark_apex | |
camera.shoot() | |
camera.shutter.apex = current_shutter | |
option = 1 -- reset button to cycle | |
end | |
end | |
if cycled then -- change ML state: adapt this framework as required | |
if config_ref == 1 then -- reset (null out) everything (note put menus to be managed here and manage state changes below, ie cycling in both directions) | |
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_ref == 2 then -- switch to ETTR | |
menu.set("Shoot","Advanced Bracket",0) | |
menu.set("Expo","Auto ETTR",1) | |
elseif config_ref == 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_ref == 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_ref == 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_ref == 6 then -- switch to Waveform | |
menu.set("Expo","Dual ISO",0) | |
menu.set("Overlay","Waveform",1) | |
-- add other state changes here, plus add to config_states table | |
-- elseif config_ref == 7 etc | |
end | |
cycled = false | |
end | |
end | |
function testkeys(kk) | |
if switched_off then return true end | |
if (kk == KEY.UNPRESS_HALFSHUTTER) and last_key == KEY.HALFSHUTTER and option_1_vis then -- reset and change direction of ML state changes | |
direction = -direction | |
last_key = kk | |
return true | |
end | |
if kk == button then | |
if use_normally then | |
use_normally = false | |
button_pressed = false -- reset [button] | |
option = 1 -- reset button to cycle option | |
last_key = kk | |
return true | |
end | |
if (not button_pressed) then -- first push of cycler button in this sequence | |
button_pressed = true | |
return false | |
else -- cycle through options | |
button_pressed = true | |
option = option + 1 | |
if option > #options then option = 1 end | |
return false | |
end | |
end | |
if kk == select_button and button_pressed then | |
selected = true | |
button_pressed = false -- reset [button] | |
return false | |
end | |
last_key = kk | |
return true | |
end | |
lv.info | |
{ | |
name = "Cycler State", | |
value = "", | |
priority = 100, | |
update = function(this) | |
if switched_off then | |
this.value = "" | |
return true | |
end | |
this.background = COLOR.WHITE | |
this.foreground = COLOR.BLACK | |
option_1_vis = false | |
if not button_pressed then | |
this.value = config_states[config_ref] | |
else | |
if option == 1 then | |
option_1_vis = true | |
if direction == -1 and option == 1 then this.foreground = COLOR.RED end | |
local last = config_ref - 1 | |
if last < 1 then last = #config_states end | |
local next = config_ref + 1 | |
if next > #config_states then next = 1 end | |
this.value = config_states[last].."/"..config_states[config_ref].."/"..config_states[next] | |
else | |
option_1_vis = false | |
this.value = options[option] | |
end | |
end | |
end | |
} | |
Cycler_Menu = menu.new | |
{ | |
parent = "Shoot", | |
name = "Cycler", | |
help = "Helps to control ML state changes", | |
depends_on = DEPENDS_ON.LIVEVIEW, | |
choices = CON, | |
update = function(this) | |
if this.value == "ON" then switched_off = false else switched_off = true end | |
end, | |
} | |
event.shoot_task = reset | |
event.keypress = testkeys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment