CHDK Wiki
(Added more code)
Line 43: Line 43:
 
g=g*b/6+g
 
g=g*b/6+g
 
next i
 
next i
  +
return
  +
</pre>
  +
  +
A few more additions to the code:
  +
  +
'''Script Code''' (save as "focusrange.bas" to your /SCRIPTS/ folder)
  +
<pre>
  +
rem arne182
  +
@title FocusRange
  +
@param a Number of +steps
  +
@default a 3
  +
@param b Number of -steps
  +
@default b 3
  +
@param c Focus range in cm
  +
@default c 10
  +
@param d Infinity included, yes = 1
  +
@default d 0
  +
  +
if a<0 then let a=0
  +
if b<0 then let b=0
  +
if c<1 then let c=1
  +
if c>50 then let c=1
  +
  +
sleep 500
  +
get_focus f
  +
if f<0 then let f=65530
  +
if f<69 then let b=0
  +
if f>17590 then let a=0
  +
  +
  +
for s=-b to a
  +
g=f+s*c*10/(a+b)
  +
set_focus g
  +
sleep 100
  +
get_focus g
  +
print "Shoot", s, "(", g, ")"
  +
shoot
  +
next s
  +
if d=1 then gosub "infinity"
  +
  +
set_focus f
  +
  +
end
  +
  +
:infinity
  +
g = 65530
  +
print "Shoot infinity", "(", g, ")"
  +
set_focus g
  +
sleep 100
  +
shoot
 
return
 
return
 
</pre>
 
</pre>

Revision as of 20:46, 5 November 2011

Focus Bracketing with set_focus and get_focus

Written for/on: Powershot A630, CHDK Build 125 or later required.
Also works on: Powershot SX10 IS

This is a new focus bracketing script. It uses set_focus to set the focus and is faster and more reliable than other scripts.

Script Code (save as "focus2.bas" to your /SCRIPTS/ folder)

rem Author Bubendorf
@title Focus2
@param a Number of ±steps 
@default a 2
@param b Step size [x6]
@default b 6

if a<1 then let a=2
if b<1 then let b=1

sleep 500
get_focus f

for s=-a to a
  g=f
  if s<0 then gosub "negative"
  if s>0 then gosub "positive"
  print "Shoot", s, "(", g, ")"
  set_focus g
  shoot
next s
set_focus f

end

:negative
  for i=s to -1
   g=6*g/(b+6)
  next i
return

:positive
  for i=1 to s
   g=g*b/6+g
  next i
return

A few more additions to the code:

Script Code (save as "focusrange.bas" to your /SCRIPTS/ folder)

rem arne182
@title FocusRange
@param a Number of +steps 
@default a 3
@param b Number of -steps
@default b 3
@param c Focus range in cm
@default c 10
@param d Infinity included, yes = 1
@default d 0

if a<0 then let a=0
if b<0 then let b=0
if c<1 then let c=1
if c>50 then let c=1

sleep 500
get_focus f
if f<0 then let f=65530
if f<69 then let b=0
if f>17590 then let a=0


for s=-b to a
  g=f+s*c*10/(a+b)
  set_focus g
  sleep 100
  get_focus g
  print "Shoot", s, "(", g, ")"
  shoot
next s
  if d=1 then gosub "infinity"

set_focus f

end

:infinity
  g = 65530
  print "Shoot infinity", "(", g, ")"
  set_focus g
  sleep 100
  shoot
return