Is that script layout feasble ?

  • 0 Replies
  • 1169 Views
*

Offline Lebeau

  • ***
  • 187
Is that script layout feasble ?
« on: 21 / February / 2012, 14:43:25 »
Advertisements
I have a SX230 with dedicated video button.

I want to create a Lua script to take a video where focus start from a point and finish to another point.

I write this Lua script layout would like to convert it to "executable" Lua script.

Code: [Select]
... initial variables ...

-- get final object position
print ( "Manually focus to final object and click" )
wait_click ()
to_focus = get_focus ()
to_near = get_near_limit ()
to_far = get_far_limit ()

-- get initial object position
print ( "Manually focus to initial object and click" )
wait_click ()
from_focus = get_focus ()
from_near = get_near_limit ()
from_far = get_far_limit ()

-- determine focus swap orientation
if to_focus < from_focus then
to_focus = to_far_limit
from_focus = from_near_limit
step_factor = -1
else
to_focus = to_near_limit
from_focus = from_far_limit
step_factor = +1
end

-- set focus and start video
set_focus ( from_focus )
set_video_mode ( record )

sleep ( launch_delay )

repeat
focus_granularity = 1 + ( get_far_limit () - get_near_limit () ) / focus_step
from_focus = from_focus + ( step_factor * focus_granularity )
-- adjust focus
set_focus ( from_focus )
sleep ( focus_interval )
until abs( from_focus - to_focus ) <= focus_granularity
-- while focus change is lower than granularity

sleep (launch_delay )
set_video_mode ( stop )

Am I wrong ? Could it be better ?

 

Related Topics