Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: garry23 on November 06, 2018, 12:47:32 PM

Title: Hope someone can help with this Lua problem I'm having
Post by: garry23 on November 06, 2018, 12:47:32 PM
I've got a new project going that will, hopefully, allow me to wireless control ML states via a Lua script.

I have a means of talking to my 5D3 and changing some settings, eg WB and metering mode, which I'm using to 'do other things'.

The sample script below simply allows me to wirelessly trigger ETTR, as I've set ETTR to SET.

I'm not in LV mode as my wireless device needs to not (sic) be in LV mode.

If I press SET from the camera SET button, all is well, ie the ETTR comes on, does its stuff and LV switches off.

If I use the script (this is a proof of principle, thus lean) I keep getting the same behaviour.

The script looks out for the state change I'm after via the WB value (here just one is used to demo things).

The user then triggers that state change or function via the metering_mode being switch between two state.

Things work up to a point.

The ETTR gets triggered OK but then does a second ETTR and remain LV mode.

I've tried review on and off, and the get the same result.

Can anyone suggest the error of my ways?

Cheers

Garry


wb_value = -1
change = false
previous_meter_value = 0

function property.WB_MODE_LV:handler(value)
     wb_value = value
end

function property.METERING_MODE:handler(value)
     if (previous_meter_value == 3 and value == 5) then -- if previous metering value was 3 and the current one is 5
        change = true
        previous_meter_value = 0 -- clear variable
    else
        change = false
        previous_meter_value = value -- remember current metering value
    end
end

function watch(arg)
    if change == true then
        change = false -- in other words
        if wb_value == 1 then
            key.press(KEY.SET) -- ETTR configured for SET trigger
        end
    end
    return true
end

event.shoot_task = watch
Title: Re: Hope someone can help with this Lua problem I'm having
Post by: garry23 on November 06, 2018, 03:05:26 PM
Worked something out  ;)