Need script help - Script Writing - CHDK Forum supplierdeeply

Need script help

  • 3 Replies
  • 2476 Views
Need script help
« on: 16 / February / 2012, 16:57:37 »
Advertisements
I am new to chdk and know next to nothing when it comes to writing scripts. I have gotten the few scripts I plan to use on a regular basis already installed. I'm curious if there is a way to toggle raw from a script.

Below is a nice universal bracketing script I got from chdk-de. If I wanted to add the raw toggle to the script paramaters, how would I change the scripts? I know I can use the SET_RAW param, but not sure how to code that into a param that can be changed off and on at will. I plan on adding this code to all of my scripts so I need something at the very beginning that would be easy for me to add to other scripts.

--[[
@title Universal Bracketing
@param a Step size [x*1/3Ev][Tv]
@default a 3
@param b Number of values
@default b 5
@param c Delay in
@default c 1
@param d images per value
@default d 1
@param e fixed Focus [0=off][1=on]
@default e 1
@param f Mode [0=Ev]  [1=Tv]
@default f 0
@param g Log [-1=off][x=File-No.]
@default g 0
]]
 
function shooting()
   press "shoot_half"
   repeat
   until get_shooting() == true
   if e == 1 then set_aflock(1) end              
   if f == 1 then     
      if get_propset() == 2 then
         set_prop(262,TV)
      else
         set_prop(69,TV)
      end
   else
      set_ev(EV)
   end
   press "shoot_full"
   release "shoot_full"
   release "shoot_half"
    repeat
     until get_shooting() ~= true
end
 
function multi_shooting(count)
  if count>1 then print("Record 1 of",count) end
  shooting()
  if count>1 then
    for n=2,count do
      print("Record",n,"of",count)
      shooting()
    end
  end
end

function print_Tv()
   tv_output = {"64s","50s","40s","32s","25s","20s","15s","13s","10s","8s","6s",
   "5s","4s","3.2s","2.5s","2s","1.6s","1.3s","1s","0.8s","0.6s","0.5s","0.4s",
   "0.3s","1/4s","1/5s","1/6s","1/8s","1/10s","1/13s","1/15s","1/20s","1/25s",
   "1/30s","1/40s","1/50s","1/60s","1/80s","1/100s","1/125s","1/160s","1/200s",
   "1/250s","1/320s","1/400s","1/500s","1/640s","1/800s","1/1000s","1/1250s",
   "1/1600s","1/2000s","1/2500s","1/3200s","1/4000s","1/5000s","1/6400s",
   "1/8000s","1/10000s"}
   print_tv = "Tv="..tv_output[tv+19]
end

function EV_hdr()
   x=0
   for s=1,b do
      if x>0 then x=-1 else x=1 end
      EV = Ev_is + (s/2*x) * a * 32
      z=EV/32/3
      if z<0 then zz=z*-1 else zz=z end
      if x == -1 then
         zzz = "-"..zz..","
      else
         zzz = zz..","
      end
      cls()
      print("Picture",s,"of",b,"with",zzz..(EV*10/32/3-z*10)*x,"Ev")
    multi_shooting(d)
  end
end
 
function TV_hdr()
   x=0
   for s=1,b do
      if x>0 then x=-1 else x=1 end
      TV = Tv_is + (s/2*x) * a * 32
      tv = TV / 32
      cls()
      print_Tv()
      print("Picture",s,"of",b,print_tv)
    multi_shooting(d)
  end
end

--start script
 
if a<1 then a=1 end
if b<3 then b=3 end
if c<0 then c=0 end
if d<1 then d=1 end
if e<0 or e>1 then e=0 end
if f<0 or f>1 then f=0 end
 
time01 = get_tick_count()

press("shoot_half")
repeat
        until get_shooting() == true
release("shoot_half")

Ev_is  = get_ev()
Tv_is  = get_tv96()
tv     = Tv_is / 32
flash  = get_flash_mode()
EV     = 0
TV     = 0

if flash ~= 2 then
   print("flash off!")
   sleep(3000)
   exit_alt()
   sleep(2000)
end

if c>0 then
  print("Wait",c,"Seconds(n)")
  sleep(c*1000)
end

if g>-1 then print_screen(100+g) end
 
if f==0 then
  EV_hdr()
else
  TV_hdr()
end
 
set_ev(Ev_is)
set_tv96(Tv_is)
cls()
time02 = get_tick_count()
time03 = (time02 - time01)/1000
print(b*d,"Recording in",time03,"Seconds.")
print(os.date("am %d.%m.%y um %X"))
print("Created.")
if g>-1 then print_screen(-10000) end
if e == 1 then set_aflock(0) end
« Last Edit: 16 / February / 2012, 17:06:34 by GreedyRogue »

Re: Need script help
« Reply #1 on: 28 / April / 2012, 11:20:29 »
Take a look at this :  http://chdk.wikia.com/wiki/Script_commands#set_config_value

The index for the save_raw value is 2,  so these commands should enable and disable RAW from a script

Code: [Select]
set_config_value(2,0)  -- disable saving RAW

set_config_value(2,1)  -- enable saving RAW
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14114
Re: Need script help
« Reply #2 on: 28 / April / 2012, 16:38:14 »
or use set_raw
Don't forget what the H stands for.

Re: Need script help
« Reply #3 on: 28 / April / 2012, 16:47:04 »
or use set_raw
One more reason I was working on my comprehensive list of all Lua and uBASIC functions today :)
Ported :   A1200    SD940   G10    Powershot N    G16


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal