Author Topic: Lua Scripting (lua.mo)  (Read 56477 times)

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 9561
  • 5D Mark Free
Re: Lua Scripting (lua.mo)
« Reply #250 on: March 13, 2017, 10:02:01 AM »
I've got it running by inserting this at the beginning of first loop in your move() function:

Code: [Select]
function move(direction)
  ...
  repeat
            msleep(500)
            lv.start()
            ....
            focus commands
            take_brackets()
  until ...
end

If LiveView is already on, lv.start() will do nothing.

If you are in image review mode, lv.start() will bring you back to LiveView (without waiting for the image review to finish).

If you call it while Canon firmware is already attempting to return to LiveView (e.g. immediately after taking a picture with image review off), you have a race condition. ML notices the camera is not in LiveView, so it queues a fake press on the LiveView button. Meanwhile, Canon code might enable LiveView. By the time the LiveView button press gets interpreted, the camera is likely already in LiveView, so the effect will be the opposite.

Hence the delay before attempting to start LiveView.

That's because camera.shoot() does not also wait until the camera returns to LiveView. It only waits until Canon firmware reports the picture has been taken (so you can take a second picture or change settings straight away). LiveView is a different task.

garry23

  • Hero Member
  • *****
  • Posts: 1074
Re: Lua Scripting (lua.mo)
« Reply #251 on: March 13, 2017, 01:42:05 PM »
@A1ex

Once again thanks for the insight.

I'll use the 'Lua Fix', and your insight/hints, as an opportunity to refactor/tidy-up my scripts.

Cheers!

Garry

garry23

  • Hero Member
  • *****
  • Posts: 1074
Re: Lua Scripting (lua.mo)
« Reply #252 on: March 13, 2017, 09:59:31 PM »
@A1ex

Looked at my script, following your insight, and used the following snippet in the end:

Code: [Select]
repeat
   msleep(200)
until lv.running

I used this 'upfront' and once, as you suggested. I also found I needed it after my shoot function, ie:

Code: [Select]
function my_shoot()
camera.shoot(false)
repeat
msleep(200)
until lv.running
end

I think you hinted at this.

One thought I had was whether it worth putting a bool check in camera.shoot and lens.focus that could be used by the scripter to tell ML Lua to wait for AF and LV or any other critical event/state, that you are aware of, but mortals like myself are not  :) ;)

Bottom line: once again thanks for all the background hardwork and for supporting 'idiots' like myself.

Cheers

Garry

garry23

  • Hero Member
  • *****
  • Posts: 1074
Re: Lua Scripting (lua.mo)
« Reply #253 on: March 16, 2017, 08:24:49 AM »
Carrying testing with the latest Lua fix experimental branch, but noticed no 50D version.

Is there a reason for this?

Cheers

Garry

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 9561
  • 5D Mark Free
Re: Lua Scripting (lua.mo)
« Reply #254 on: March 16, 2017, 08:30:25 AM »
Looks like it's a bug, and the experimental build page doesn't have a way to flag broken builds (it simply lists all the successful ones). Will fix later.

garry23

  • Hero Member
  • *****
  • Posts: 1074
Re: Lua Scripting (lua.mo)
« Reply #255 on: March 16, 2017, 08:43:50 AM »
 :) Cheers