Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting API suggestions => Topic started by: garry23 on November 04, 2017, 12:10:32 PM

Title: [WIP - lens.autofocusing, ...] Lua Property access
Post by: garry23 on November 04, 2017, 12:10:32 PM
@A1ex or anyone

I'm trying to make use of a long halfshutter and need to differentiate it from a LV AF action.

I thought I could use the Lua property handler, eg accessing LV_FOCUS_STATE or another LV_FOCUS property, ie to handle the AF condition.

But the LV_FOCUS property handler always seems to return 0.

Does this mean it is not yet exposed in Lua?

Cheers

Garry
Title: Re: Lua Property access
Post by: a1ex on November 04, 2017, 04:12:15 PM
It's PROP_LV_FOCUS_STATUS; value is 3 during autofocus (hopefully on all models) and 1 or 2 (depending on model) when idle.

What about adding a boolean field named lens.focusing ?

(sorry for being slow with Lua requests - it's just not something I use often, although I do see its value for the ML project)
Title: Re: Lua Property access
Post by: garry23 on November 04, 2017, 04:36:31 PM
@a1ex

You never have to apologize! Not with all the work you do and with all the knowledge you have.

I tried that prop and only got 0 returned on my EOSM.

Here is the test code:

my_key = 0

function check_requests()
        display.notify_box(tostring(my_key),2000)
        return true
end

function property.LV_FOCUS_STATUS:handler(value)
     my_key = value
end

event.shoot_task = check_requests
Title: Re: Lua Property access
Post by: a1ex on November 04, 2017, 06:46:01 PM
The script works fine on 5D3, and likely on all other models that pass api_test.lua. EOS M is probably not one of them...
Title: Re: Lua Property access
Post by: garry23 on November 04, 2017, 06:49:45 PM
@a1ex

OK, I'll test tomorrow on the 5D3.

I need a way (tonight if possible) to test if image is being taken, via Lua.

Is there another way?

Cheers

Garry
Title: Re: Lua Property access
Post by: a1ex on November 04, 2017, 07:55:55 PM
To test if an image is being taken, in order to do something during a long exposure? Or to do something after the image was taken?

The former is not exposed to Lua, but is doable. The latter is easier - see e.g. in api_test.lua (https://bitbucket.org/hudson/magic-lantern/src/edbf5ee/scripts/api_test.lua?fileviewer=file-view-default#api_test.lua-835): dryos.shooting_card.file_number gets incremented after a picture is taken.
Title: Re: Lua Property access
Post by: garry23 on November 04, 2017, 09:16:49 PM
@a1ex

Yes it's the long exposure test.

It would be great to be able to test if image taking started and image taking finished.

Cheers

Garry