Wednesday, June 1, 2016

Toggler Update

A simple post today, to let you know that my Toggler ML script has been refactored and tidied up.

All the Toggler does is allow you to switch on/off certain ML menus, in a cyclic way:
  • OFF -- All the following are switched off
  • ETTR = ETTR on
  • DUAL = Dual-ISO on
  • BRAC = Auto-Bracketing on
  • FRSP = Full Res Silent Picture on
In the case of the FRSP Toggler checks to ensure you are in the FRSP 'shutter' range, ie about 0.25 to 15 seconds.

Simply opening the Toggler menu resets all the above to off and puts Toggler in the OFF state if it is enabled or not, ie if Toggler is enabled all the above ML menus set are set to off when the Toggler menu is displayed.

As usual I welcome feedback.

--[[    
    Still photography toggler script
    Version 1.6 (should work on all ML enabled cameras with the Lua module)
    Garry George June 2016
    http://photography.grayheron.net/
    Toggler script for ML settings.
    Toggle through ML settings using the selected option, ie a button you rarely use.
    Must be in LV.
--]]

-- Declare some variables
toggler_play = 1
toggler = 0
frsp = false
frsp_ok = false

-- Change toggler value to your choice of button, eg KEY.RATE, KEY.UP, KEY.INFO or KEY.PLAY.
-- See http://davidmilligan.github.io/ml-lua/modules/constants.html for key constants
-- Default is KEY.RATE for non-EOSM cameras. EOSM self selects upper toggle on main dial as the EOSM doesn't have many buttons!
if camera.model_short == "EOSM" then toggler = KEY.UP else toggler = KEY.RATE end -- Change RATE to your choice                                                                                                           

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 = "Expo", item = "Auto ETTR", value = 1},
        }
    },
    {
        name = "DUAL",
        menus=
        {
            { 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 = "Expo", item = "Dual ISO", value = 0},
        }
    },
    {
        name = "FRSP",
        menus=
        {
            { menu = "Shoot", item = "Silent Picture", value = 1},
            { menu = "Shoot", item = "Advanced Bracket", value = 0},

        }
    }
}
-- You can add other ML 'menu states' above

event.keypress = function(key)
    if keymenu.submenu["Enabled?"].value == "No" then
        return true  -- Toggler does nothing and shows no menu states
    elseif key == toggler  then -- act on a toggle
        toggler_play = toggler_play + 1
        frsp = false -- assume FRSP not selected
        if toggler_play > #toggler_presets then toggler_play = 1 end
        for i,v in ipairs(toggler_presets[toggler_play].menus) do
            menu.set(v.menu,v.item,v.value)
            if v.item == "Silent Picture" and v.value == 1 then frsp = true end -- check if FRSP set to ON in this toggle
        end
        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
    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" 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 = {"Yes","No"},
            update = function(this) -- set all Toggler menus to their off state
                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   
--                menu.close()
            end
        }
    }
}

8 comments:

  1. Hi, From Above 'A simple post today'
    As a stills photo man I would love to from what I can understand in the above jumble of words be able to turn on/off DISO without having to keep going into the main menu of ML along with some other aspects but! and I am being honest here, I do not understand any of it above, it is for a none tech person like myself going into a foreign country and not being able to speak the language. Not being rude to you as you obviously put in a lot of work on your blog and ML menus just over my head.
    Thanks
    Russ

    ReplyDelete
    Replies
    1. Russ

      As long as you have the latest ML on your camera, all you need to do is enable the Lua module, then copy the above script into a flat, text doc and add a .lua extension.

      Add the file into the Lua script folder (you might wish to delete other scripts or add a "_" before those scripts' filenames (so they wont load).

      The Toggler script will then appear in the shoot ML menu.

      You can then Toggle away.

      Not set your ETTR, Dual, Auto-Bracket and FRSP settings, ie Toggler 'just' switches the ML feature on or off.

      Let me know how you go.

      Delete
  2. Thank you for trying to help Garry but will stick with what I have as I have no idea what I would be doing even reading the above reply.
    Russ

    ReplyDelete
    Replies
    1. Russ

      That's up to you, however, if you have ML running and are using Dual-ISO, then the putting the above script on your camera is easy.

      As I say, it's up to you. Let me know if I can help in the future.

      Cheers

      Garry

      Delete
  3. Hi Garry

    First of all I wanted to thank you for such an informative blog and for making your LUA scripts available. Unfortunately, I am having a few problems on my EOSM:

    I download and unzip the Toggler EOSM script, put it in the ML/scripts folder on my SD card (after moving the default scripts to a subdirectory so that they don't load). LUA module is enabled and the camera turned on. I get some debug information that indicates that the Toggler script has loaded. With the ML menu system loaded the INFO button appears to act as the Q button which appears to be expected behaviour having examined the script, so far so good.

    The problem occurs when I try and activate the Toggler. From the comments/code in the script I deduce that I press [PLAY] and then the [MENU] button. Nothing happens.

    Looking at the code:

    .
    .
    button_1 = KEY.INFO -- imode switch and set
    button_2 = KEY.PLAY -- used to go forwards in imode
    .
    .
    .
    elseif (k == button_1 and last_key_pressed == button_2) then -- go into imode
    .
    .

    It looked like it might be [PLAY] and then [INFO] but alas that does not work either.

    In an attempt to do some problem determination I tried loading the Explicit [Q] buttom on EOSM (tester in me spotted the spelling mistake on your website "buttom").

    Load the ML menu by pressing [TRASH] and then press the [INFO] button and the HELP system tries to load. Press it again and get a Test4Q lua cbr error. I don't know if that helps?

    I have downloaded the latest ML nightly build for the EOSM. Is the LUA support in someway different of am I just misunderstanding how the scripts work? I am sorry if that is the case.

    Many thanks,

    Ross Lister

    ReplyDelete
    Replies
    1. Ross

      This post is a little out of date: try downloading the Toggler EOSM from the right. I just tried it and it works. It also has the sim-Q in the script, ie SET works as Sim in ML menu mode.

      The script's help text up front should be clear enough to get it going.

      If you have any issues let me know.

      Cheers

      Garry

      Delete
  4. Hi Garry

    Thanks for the prompt response.

    I believe that was the one that I was using but will try it again.

    ReplyDelete