set focus to 2 feet and take a shot in lua - Script Writing - CHDK Forum supplierdeeply

set focus to 2 feet and take a shot in lua

  • 5 Replies
  • 2939 Views
*

Offline dvip

  • ****
  • 451
set focus to 2 feet and take a shot in lua
« on: 05 / December / 2011, 00:30:44 »
Advertisements
I am trying to write a simple lua script to set focus to
lets say 2 feet and take a shot. The script will:
 

set focus to 2 feet
take a shot

set focus to 5 feet
take a shot

set focus to 10 feet
take a shot

Only need 3 shots.
Any way to do this in a simple way in lua?


Re: set focus to 2 feet and take a shot in lua
« Reply #1 on: 05 / December / 2011, 03:28:04 »
Well, you almost did it, just translate these sentences into uBasic or Lua:)
Read this: http://chdk.wikia.com/wiki/Scripts and references. Also read code of this script: http://chdk.wikia.com/wiki/UBASIC/Scripts:_Focus_Bracketing_with_set_focus_and_get_focus

In general you have to use:

set_focus(100)  --where 100 is in milimeters (as far as I remember)
shoot  -- this command will shoot

You probably have to be in MF mode to avoid camera of auto refocus.


The other way:

set_focus(100)
click("shoot")


This is alittle bit different.

And remember, that Lua script has to have '.lua' extension. uBasic can have whatever.
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

*

Offline dvip

  • ****
  • 451
Re: set focus to 2 feet and take a shot in lua
« Reply #2 on: 05 / December / 2011, 10:24:09 »
Hi outslider,

Thanks for the tips.
I wasn't sure what to enter for a 2 , 5, 10 feet distance in set_focus(?).
I wonder if there is a table with distances, or reference for set_focus() in lua.


*

Offline whim

  • ******
  • 2013
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: set focus to 2 feet and take a shot in lua
« Reply #3 on: 05 / December / 2011, 10:36:12 »
@dvip

Google is your friend, "unit conversion" led me here
It calculates 1 foot to be 304.8 millimeter

hth,

wim


*

Offline dvip

  • ****
  • 451
Re: set focus to 2 feet and take a shot in lua
« Reply #4 on: 05 / December / 2011, 10:57:27 »
@wim,

Thanks for the tip.

I was also thinking that this can be done if the script enters M focusing and then with some clicks I can select the distance.

I was hoping to do it with a single function like I do it when I set focus to infinity: set_prop(6, 3) -- set to infinity

« Last Edit: 05 / December / 2011, 17:01:43 by dvip »

*

Offline dvip

  • ****
  • 451
Re: set focus to 2 feet and take a shot in lua
« Reply #5 on: 06 / December / 2011, 19:45:18 »

set_prop(6, 4) -- sets manual focus, I am not sure if it is needed

set_focus(955) -- about 2 feet
set_aflock(1)
sleep(500)
shoot()
set_aflock(0)


Do I need set_aflock(1) here or will set_focus(955) do the same and keep the focus there?


 

Related Topics