Save zoom used - General Help and Assistance on using CHDK stable releases - CHDK Forum supplierdeeply

Save zoom used

  • 9 Replies
  • 2010 Views
Save zoom used
« on: 30 / July / 2012, 11:32:22 »
Advertisements
Dear collages,

I'm new in using the CHDK (but for example I have done an external fighter from a USB wire). I have a question: is it possible to save the zoom that I'm using, and when I would restart the camera have the same? I have a Canon PowerShot SX130. Thank you very much.

Re: Save zoom used
« Reply #1 on: 30 / July / 2012, 11:45:50 »
Hi :) You can run a script at startup by setting the "Autostart" option in the scripting menu. This script could look something like this:

Code: (lua) [Select]
--[[
@title Set Zoom
@param a Level
@default a 0
]]

if get_zoom() ~= a then

   set_zoom_speed(100)
   set_zoom(a)
   while get_zoom() ~= a do
      sleep(10)
   end

end

exit_alt()


This could be modified to save the current zoom found and use this rather than a parameter to set the zoom at startup.

EDIT: This was a quickly written script so some error prevention and refining may be needed.
« Last Edit: 30 / July / 2012, 12:07:06 by dbldash »

Re: Save zoom used
« Reply #2 on: 31 / July / 2012, 06:17:42 »
Dear dbldash,

Thank you very much. But one question (I`m new in this): how can i use this script? What I do is to focus the object with a zoom, and this is the zoom that I want to save, because when I restart the camera, I want to have this zoom to take the photos.

One more question. Where can I download a tutorial of lua and ubasic programmation?

Regards,

Juan José

Re: Save zoom used
« Reply #3 on: 31 / July / 2012, 06:47:18 »
Sorry, one more thing,

It is not necessary to get the zoom automatically: it could be done by loading the script (for example: load the script to save the zoom that I'm using and then load the same script (or another script) with the zoom safe). Thank you very much.


Re: Save zoom used
« Reply #4 on: 31 / July / 2012, 08:27:29 »
What I do is to focus the object with a zoom, and this is the zoom that I want to save, because when I restart the camera, I want to have this zoom to take the photos.

Sorry, I didn't write this functionality into the script above. This script should fix that:

Code: (lua) [Select]
--[[
@title Set Zoom
]]

print_screen(1)

if not autostarted() then

   file, msg, no = io.open("A/CHDK/ZOOMSETT.TXT", "w")

   if not file then
      print("Error " .. no .. ": " .. msg)
   else
      ret, msg, no = file:write(get_zoom())
      if not ret then
         print("Error " .. no .. ": " .. msg)
      else
         print("Zoom setting = " .. get_zoom())
      end
   end

   print("Press any key to end")
   wait_click()

else

   sleep(100)
   set_record(1)
   while not get_mode() do
      sleep(10)
   end
   sleep(200)

   file, msg, no = io.open("A/CHDK/ZOOMSETT.TXT", "r")

   if not file then
      print("Error " .. no .. ": " .. msg)
   else
      a, msg, no = file:read("*n")
      if not a then
         print("Error " .. no .. ": " .. msg)
      end
   end

   if get_zoom() ~= a then
 
      set_zoom_speed(100)
      sleep(100)
      set_zoom(a)
      while get_zoom() ~= a do
         sleep(10)
      end
 
   end

end
 
exit_alt()

To use this script, save it as zoomset.lua somewhere on your memory card (probably in CHDK/SCRIPTS directory), go into ALT mode, then press SET and load the script. Set Autostart to On. Then exit ALT mode and set the zoom to what you want it to be on startup. Enter ALT mode again and press the shutter to run the script. On the screen it should say the number the zoom preference has been set to (stored in a text file in the root of the memory card).

Turn off the camera, then start it up in record mode - on my SX10 this is done by pressing and holding the on button until it boots up, but on your SX130 this could be different. I have included some code in the script which should switch from play to record made anyway but this doesn't work for some reason on my camera (I'll try to figure this out at some point) (UPDATE: Turns out the sleep values are just not long enough - increasing the first from 100 to 500 works for me, so it is now not necessary to power the camera on in record mode). Then, all being well the camera should zoom to the specified level and then exit ALT mode automatically.

Sorry, that may have been a bit convoluted, hopefully you can understand it! For a tutorial of lua you can go to the lua website (http://www.lua.org) but it is rather dry, so more useful for reference. It's also not specific to CHDK. This page may be good as a starter for that: http://chdk.wikia.com/wiki/CHDK_scripting. I'll try to find some other resources if I have time.

Hope that works - it works on my SX10 but there sometimes are camera-specific glitches. Anyway, good luck :)
« Last Edit: 31 / July / 2012, 11:16:20 by dbldash »

Re: Save zoom used
« Reply #5 on: 31 / July / 2012, 13:03:30 »
Thank you very much. I will try it this night and I'll tell you if it runs ok.

Regards,

Juan José

Re: Save zoom used
« Reply #6 on: 12 / August / 2012, 09:24:34 »
How did it go?

Re: Save zoom used
« Reply #7 on: 05 / November / 2012, 16:59:21 »
Hey dbldash,

I tried your lua script on my sx 130 and it works perfectly!  Thank you. 
BTW, I've set up my chdk to boot automatically when I start up the camera, which puts it into play mode anyway.  When I exit play mode by toggling "alt" off and then hitting the shutter button, that's when your script executes.

Thanks again.  Good work!


Re: Save zoom used
« Reply #8 on: 05 / November / 2012, 19:54:57 »
BTW, I've set up my chdk to boot automatically when I start up the camera, which puts it into play mode anyway. 
If you power up by holding the On/Off button down until the lens opens,  you can start in shooting mode.

Quote
When I exit play mode by toggling "alt" off and then hitting the shutter button, that's when your script executes.
What you are actually doing is toggling "ALT" on at that point - ALT mode means CHDK menu system and script are enabled.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Save zoom used
« Reply #9 on: 06 / November / 2012, 09:39:57 »
Waterwingz

Thanks for your comments!

Your first suggestion is quite helpful;  I didn't know how to go right away to record mode, probably making my second observation (below) a moot point.

Regarding your other suggestion, I believe that because the lua script is set to "Autostart", the camera is indeed in "ALT" mode after startup.  The problem is getting from "play" to "record," which is why I have to toggle out of "alt" first.

At any rate, as I mentioned, starting the camera directly in record mode will cause this problem to go away (hopefully)

By the way, I appreciate how clearly you've described the workings of the multiple camera sync in CHDK.  Thanks for all your hard work!

Harold

 

Related Topics