help needed for script - remote take picture / record video - Script Writing - CHDK Forum supplierdeeply

help needed for script - remote take picture / record video

  • 5 Replies
  • 4979 Views
help needed for script - remote take picture / record video
« on: 29 / September / 2011, 12:54:29 »
Advertisements
Hi

Could someone write for me a (simple?) script that does the following:

a. if USB remote button is not pressed, it takes individual photos, one after the other, continuously - should check exposure etc for each shot.

b. if USB remote button is pressed, start recording video, until USB remote button is released again (then back to a).

Some help with this would be most appreciated!

Edit: SD1000/IXUS 70

thanks
Nic
« Last Edit: 29 / September / 2011, 18:11:38 by nicnet »

Re: help needed for script - remote take picture / record video
« Reply #1 on: 03 / October / 2011, 23:33:24 »
Here's a script that does exactly what you want. 

Works perfectly on my G10.  But not so well in my SD940. 

The USB remote code in CHDK is temperamental  and different camera ports react differently.  There have been several recent postings about issues with USB Remote.  I'm looking into it but have no idea yet what it will take to fix it.

Meanwhile,  see if this works for you ?  Requires the latest release of CHDK by the way.   This is LUA script - save it with the extension .lua  - for example usbvideo.lua.

Code: [Select]
--[[
@title USB Movie & Still
@param a Shot Delay (sec)
@default a 30
]]

capturemode=require("capmode")

set_console_layout(10, 0, 40, 14)

print("started ...")

if not capturemode.valid("VIDEO_STD") then
print "Invalid mode: VIDEO_STD"
else
if not capturemode.valid("P") then
print "Invalid mode: P"
else

if (get_config_value(121) == 0 ) then
set_config_value(121, 1)
print("Enabling USB Remote")
end

tstamp = get_tick_count()
photo=1

repeat
if get_tick_count() > tstamp then
print("shoot picture ", photo)
tstamp = get_tick_count() + a*1000
shoot()
photo=photo+1
end

   wait_click(100)
   if is_pressed("remote") then
print("switching to video")
capturemode.set("VIDEO_STD")
sleep(100)
press("shoot_full")
sleep(500)
release("shoot_full")
repeat wait_click(100) until not is_pressed("remote")
print("exiting video")
press("shoot_full")
sleep(500)
release("shoot_full")
sleep(200)
capturemode.set("P")
tstamp = get_tick_count()
    end

sleep(200)

until false

end
end

UPDATE : added a note about this being a LUA script.
« Last Edit: 04 / October / 2011, 10:03:45 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: help needed for script - remote take picture / record video
« Reply #2 on: 04 / October / 2011, 09:42:01 »
Hi waterwingz

I tried your script (thanks!),
but errors reported - it came up with a parse error on set_console_layout(10, 0, 40, 14)

I am REALLY new to this, so perhaps doing something wrong.
I saved the file as rc1.bas, and ran it on my sd1000 (ixus 70), after upgrading chdk - 0.9.9-1352.

Any suggestions?

Re: help needed for script - remote take picture / record video
« Reply #3 on: 04 / October / 2011, 09:47:34 »
Save it as something.lua

.lua ending is important, since it's a LUA script, not uBASIC;)

PS. You can recognize if a script is in LUA language - parameters given to commands are in parenthesis. For example script command in uBASIC:

Code: [Select]
print "Hello World!"
sleep 1000

and in LUA:

Code: [Select]
print("Hello World!")
sleep(1000)

That's not only difference (and not most important).

Every script that has .lua ending will be run by LUA parser. Every other file (.bas; .txt; .whatever) will run as uBASIC.
« Last Edit: 04 / October / 2011, 09:52:23 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


Re: help needed for script - remote take picture / record video
« Reply #4 on: 04 / October / 2011, 10:09:34 »
Actually,  I find that the easiest clue about it being a LUA script is usually the first line of the script.  Look for the comment block being delimited by  --[[   rather than  REM  (used in uBASIC for comments).
Ported :   A1200    SD940   G10    Powershot N    G16

Re: help needed for script - remote take picture / record video
« Reply #5 on: 16 / October / 2011, 11:36:14 »
Wow - what a great forum (for assistance!).
Thanks for your advice - haven't had chance to re-test yet, due to personal reasons.
But will do soon.

And thanks again!

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal