Shutter Speed scipt - now in LUA - Completed and Working Scripts - CHDK Forum supplierdeeply

Shutter Speed scipt - now in LUA

  • 0 Replies
Shutter Speed scipt - now in LUA
« on: 24 / August / 2009, 15:23:57 »
*edit*  oops, slight error, should be fixed now

Hello all!
I have attempted to learn LUA and try rewriting my Shutter Speed scripts.  Here is my attempt at the standard, pre-set version.  I will be trying to rewrite the adjustable one as well in the near future as LUA scripts seem to run much quicker and will make it much more usable.

I have also added a pre-focus option.  Setting this to ON makes the camera prefocus before the first shot and then lock the focus for the remaining.

Please give the script a try if you're interested and let me know of any bugs or problems encountered.
It is a LUA script, so give it a .lua extension.

PS: Thanks for those who ported the SX10!  I recently acquired one of these to replace my older S2.

There are 8 parameters that can be set:
a - EV fraction (1/x EV) - specify the EV fraction, used for both Start/End and stepping (e.g. 3 = 1/3EV, 6 = 1/6EV, etc.)
b - Start Tv (1EV) - specify the starting EV in whole EVs (relates directly to shutter speed), 0=1sec, +slower speeds, higher exposure, -higher shutter speeds
c - Start Tv (1/xEV) - specify starting EV fraction (is appended to b to allow partial EV, must be from 0 to a)
d - No.Shots - Number of shots to be taken (>0, can be set to take one shot only)
e - Step Size (y/x EV) - how much to step up/down each exposure for each shot (can be 0 to lock shutter speed)
f  - Start Delay (s) - delay to start shooting
g - Delay between shots (s) - delay between consecutive shots
h - Pre-Focus - set pre-focus and focus lock (0=OFF, 1=ON)

When starting the script, the start and end shutter speeds will be calculated and presented on-screen (only start if 1 shot), the user then hits <set> to accept or any other key to cancel.
The script will then take the shots required.  For each shot, the shutter speed will be displayed, as well as the shutter value.


a = 3
b = -11
c = 2
d = 2
e = -1

2 shots to be taken, step size = -1/3EV (e/a)
start EV = -11 2/3
end EV = -12

Tv Start ~1/3243 s
Tv End ~1/4096 s

The shutter speeds should be fairly accurate
-11 2/3 (Tv = 1120) 1/3243 vs 1/3251 (+0.25%)
-12     (Tv = 1152) 1/4096 vs 1/4096 (+0.00%)

It hasn't been fully tested under all possible conditions, but should work fairly well from between +6 (64.00s) to -20 (1/1,048,576s) with an EV resolution of up to 1/96.

Code: [Select]
rem Author: barberofcivil
rem Tested on A570

@title Shutter Speed
@param a EV fraction (1/x EV)
@default a 3
@param b Start Tv (1EV)
@default b -11
@param c Start Tv (1/xEV)
@default c 0
@param d No.Shots
@default d 1
@param e Step Size (y/x EV)
@default e 1
@param f Start Delay (s)
@default f 0
@param g Delay between shots (s)
@default g 0
@param h Pre-focus: 0=OFF, 1=ON
@default h 1

if f<0 then f=0 end
if g<0 then g=0 end
if d<1 then d=1 end
if a<1 then a=1 end
if c>=a then c=a-1 end
if c<0 then c=0 end
if b<0 then c=-c end
if h<0 then h=0 end
if h>1 then h=1 end

function ShutterCalc (i)
  if k<0 then l=l-4*a end

if d==1 then print ("One shot to be taken") else print (d.." shots to be taken") end

if d==1 or e==0 then
  if e==0 and d>1 then print ("Tv locked (step=0)") end
  if o>=4 then print ("Tv: ~1/"..o.." s") else print ("Tv: ~"..r.."."..s..t.." s") end
  if o>=4 then print ("Tv Start: ~1/"..o.." s") else print ("Tv Start: ~"..r.."."..s..t.." s") end
  if o>=4 then print ("Tv End:   ~1/"..o.." s") else print ("Tv End:   ~"..r.."."..s..t.." s") end

print ("Click <set> to proceed")
print ("Any button to cancel")

if is_key("set") then
  print ("Proceeding...")
  while f>0 do
    print ("Starting in "..f.." s...")
    sleep (1000)
  if h==0 then
    print("Prefocus OFF")
  elseif h==1 then
    print("Prefocus ON")
    local focused = false
    local try = 1
    while not focused and try <= 5 do
      print("Pre-focus attempt " .. try)
      if get_prop(18) > 0 then
        focused = true
      try = try + 1
    if not focused then print "Unable to pre-focus" else  print "Pre-focus complete" end
  print ("Starting shots now...")
  for i=1,d,1 do
    print ("Shot "..i.." of "..d)
    if o>=4 then print ("Shutter ~1/"..o.." s") else print ("Shutter ~"..r.."."..s..t.." s") end
    print ("Shutter value: "..p)
    if p==0 then p=1 end
    sleep (1000*g)
  print ("Shots cancelled")
« Last Edit: 24 / August / 2009, 19:51:36 by barberofcivil »


Related Topics