Author Topic: Help with MF + one shot AF for EOS M  (Read 594 times)

Jip-Hop

  • Freshman
  • **
  • Posts: 91
Help with MF + one shot AF for EOS M
« on: July 05, 2019, 01:40:54 PM »
I'm trying to make a script which will allow me to manually focus all the time, or one shot autofocus by half pressing the shutter button.
It's for my EOS M with native EF-M lenses.

I thought I'd just set the camera to MF mode in Canon menu, and trigger a lens.autofocus() from LUA and it would autofocus.
But clearly calling lens.autofocus() in MF mode doesn't work.

So I'm stuck and see two ways out.
I could switch temporarily from MF to AF mode when half pressing the shutter, call lens.autofocus() and switch back to MF.
But in the API I don't see any way to switch these modes.
I did read there's a dangerous option to set Canon properties, but didn't find the API to do so (and frankly I don't know if I dare to risk soft bricking the camera xD).

Another option would be to detect turning the focus ring when staying AF mode.
And then implement manual focusing in LUA, but seems like more work and I'd rather rely on the Canon MF implementation.

I thought this was going to be an easy fix xD

By the way, there's the AF+MF mode.
But MF is only allowed after an autofocus operation while the half shutter is still pressed.
So that's not true MF if you ask me.
Perhaps I could trick the camera in staying in the post-AF state, which would allow MF, and start a new AF operation on half shutter press?

Code: [Select]
-- AF KEY in MF mode 

-- Half press shutter button to autofocus if in manual focus mode

function try_af()
    local focus_lock = lens.autofocus();
    if focus_lock == true then
        display.notify_box("LOCKED ON");
    else
        display.notify_box("NO LOCK");
    end
end

event.keypress = function(key)
    if key == KEY.HALFSHUTTER then

        -- TODO: check if there's no chipped lens
        -- In that case toggle magic zoom for manual focus
        -- Maybe use CHIPPED_LENS constant?

        -- Handle key as usual in AF mode
        if lens.af == true then
            return true;
        end

        task.create(try_af);

        return false;
    end
end