Need help with getting a script to use the click wheel on the camera - Script Writing - CHDK Forum  

Need help with getting a script to use the click wheel on the camera

  • 20 Replies
  • 4290 Views
Advertisements
Hi, I am currently trying to get the old HDR stack script to work with the powershot SX230hs and nay other camera with similar controls

While it is not ideal, it is more reliable than the bracketing in continuous mode and the HDR script that comes with CHDK.

The changes that are needed is the click commands eg click "right"

i need them to perform the action of turning the clickwheel to the right or left.


Code for the .bas

Code: [Select]
@title M Mode HDR Stack
@param a Number of steps
@default a 2
@param b Step size (1/3EV)
@default b 3
@param c Number of Shots
@default c 5

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

sleep 1000

print "Preparing..."

for n=1 to a*b
    click "left"
next n

for s=1 to a*2
    print "Shoot", s, "of", a*2+1
    for r=1 to c
      shoot
    next r
    for n=1 to b
        click "right"
    next n
next s

print "Shoot", a*2+1, "of", a*2+1
for r=1 to c
  shoot
next r

print "Finalizing..."
for n=1 to a*b
    click "left"
next n

end



For most shooting conditions, if the required actions are done in all but bright sunlight, the lens will remain at F3.1

Compared to the built in bracketing and the built in HDR script, putting the camera in P mode then turning the click wheel to to adjust the exposure provides significantly better HDR images when merged using photoshop. It is also just as fast as the bracketing functions that CHDK comes with.

I am pretty much new to scripting for CHDK and the reference page does not provide examples for each command (for some it describes and gives an example code for performing 1 action but for the wheel commands, it offers no information

http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page
« Last Edit: 13 / October / 2012, 16:45:22 by Razor512 »

Re: Need help with getting a script to use the click wheel on the camera
« Reply #1 on: 13 / October / 2012, 16:08:05 »
You really don't need to start a new thread for each new thought you have about this same subject.  It will be a lot easier for others to follow if you stay in one thread.

Typically a script that presses buttons tends to be less reliable than one that sets internal values like the built-in HDR script.

Would you like me to extend the built-in script for you or tell you how to hack the one you posted above ?


Ported :   A1200    SD940   G10    Powershot N    G16

Re: Need help with getting a script to use the click wheel on the camera
« Reply #2 on: 13 / October / 2012, 16:41:51 »
sry for making multiple related topics, I was thinking of posting it in one of the other HDR script topics but they seemed dedicated to the HDR helper script, and the other topic where I mentioned it was in the SX230 hs porting thread and was not sure if that would be a good place to ask a scripting question.

The built in HDR script works well but it is limited to 3 images and all others that I have found do not seem to work so I was thinking of going really basic by having one that just does the button commands.

If the built in HDR script allowed me to expand the number of exposures it did then that would be ideal, I am just worried that it will be harder to modify that script since it has a single function and had no options to change anything.

The HDR script that came with CHDK for the SX230HS is

Code: [Select]
--[[
@title High Dynamic Range
--]]

print("1) normal")
  shoot()

  set_aflock(1)
  p=get_av96()
  s=get_sv96()
  t=get_tv96()

print("2) bright")
  set_tv96_direct(t-192)
  set_sv96(s)
  set_av96(p)
  shoot()

print("3) dark")
  set_tv96_direct(t+192)
  set_sv96(s)
  set_av96(p)
  shoot()

set_aflock(0)
print("...done")

« Last Edit: 13 / October / 2012, 16:59:23 by Razor512 »

Re: Need help with getting a script to use the click wheel on the camera
« Reply #3 on: 13 / October / 2012, 17:21:07 »
The HDR script that came with CHDK for the SX230HS is
It seems I've seen that script before .. ;)

Try this (save as hdrshoot.lua )

Code: [Select]
--[[
@title HDR Fast Shooter
@param n Number of Steps
@default n 5
@param s tV step size
@default s 96
--]]

function fastshoot(a1,s1,t1)
   set_av96(a1)
   set_sv96(s1)
   set_tv96_direct(t1)
   press("shoot_full_only")
   repeat
      sleep(50)
   until get_shooting() == true
   release("shoot_full_only")
   repeat
      sleep(50)
   until get_shooting() == false
end

set_console_layout(10, 0, 40, 14)
print("Started...")

if ( get_mode() == false ) then
  sleep(1000)
  set_record(1)
  while ( get_mode() == false) do
      sleep(100)
  end
end

sleep(1000)

press("shoot_half")
repeat
    sleep(50)
until get_shooting() == true
release("shoot_half")
repeat
    sleep(50)
until get_shooting() == false

set_aflock(1)

av=get_av96()
sv=get_sv96()
tv=get_tv96()
print( "av96=", av, "sv96=", sv, "tv95=", tv )

tv96val=tv-n*s/2

for i=1, n, 1 do
    print("step=", i, "tv96=", tv96val)
    fastshoot(av,sv,tv96val)
    tv96val = tv96val+s
end

set_aflock(0)

print("...done")
 

I've only had a few minutes to test but its seems to do the job.  Use an odd number of steps to get symmetrical exposures around what Canon thinks is the "correct" exposure.

Exposure steps are in apex96 units - information about that can be found here :

http://en.wikipedia.org/wiki/APEX_system#
http://dougkerr.net/Pumpkin/articles/APEX.pdf

Update :  changed the shoot_full click to use shoot_full_only
« Last Edit: 14 / October / 2012, 11:56:47 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Need help with getting a script to use the click wheel on the camera
« Reply #4 on: 13 / October / 2012, 18:40:46 »
thanks, It seems to be working great so far. One of the best exposure bracketing scripts yet :)

Re: Need help with getting a script to use the click wheel on the camera
« Reply #5 on: 13 / October / 2012, 19:15:24 »
thanks, It seems to be working great so far. One of the best exposure bracketing scripts yet :)
I kind if like this one myself too.

The changes that are needed is the click commands eg click "right"  i need them to perform the action of turning the clickwheel to the right or left.
AFAIK,  to simulate rotating the wheel,  you just use  click "up"  and  click "down".   But you can also just put the command wheel_right or wheel_left on a single line if you like.

Quote
For most shooting conditions, if the required actions are done in all but bright sunlight, the lens will remain at F3.1
Actually,  only the top-end Canon P&S cameras have a variable aperature these days.  For all the rest, the f-stop is fixed.

Quote
I am pretty much new to scripting for CHDK and the reference page does not provide examples for each command (for some it describes and gives an example code for performing 1 action but for the wheel commands, it offers no information
We are always looking for volunteers to help keep our documentation current.  Feel free to join in !
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Need help with getting a script to use the click wheel on the camera
« Reply #6 on: 13 / October / 2012, 20:24:36 »
I recorded a video of the script running on my camera (in case anyone wanted to see it in action)

I have not tried it on any other cameras yet but for the SX230 HS, it is working extremely well and stably.

Video demo of a new HDR script for CHDK running on a powershot SX230 HS

Re: Need help with getting a script to use the click wheel on the camera
« Reply #7 on: 13 / October / 2012, 21:18:06 »
I recorded a video of the script running on my camera (in case anyone wanted to see it in action)
Nice & simple. 

I wonder if that 's the first time anyone has taken a picture of their computer keyboard using CHDK ?  :haha
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Need help with getting a script to use the click wheel on the camera
« Reply #8 on: 14 / October / 2012, 11:57:17 »
Note :  I updated the script a bit.  It might even shoot a bit faster now.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Need help with getting a script to use the click wheel on the camera
« Reply #9 on: 21 / October / 2012, 16:28:27 »
Note :  I updated the script a bit.  It might even shoot a bit faster now.
Posted a new version of this here :
http://chdk.wikia.com/wiki/HDR_Fast_Shooter

This latest one runs 30% faster.
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics