« Reply #6 on: 06 / March / 2013, 14:10:09 »
Looks like I am stuck again. I found that when I add some actual code to my simple example above the restore() function don't work.
The script below will record a 10s video and then turn itself off by calling restore. This turns off recording and prints Restore point 1 and 2 as expected. However, when I terminate the script by pressing the shoot button I only see Restore point 1 and the recording doesn't stop. I have to come out of ALT mode and then press the video button to stop recording.
Any ideas where I am going wrong? I am running 1.2.0-2593 on an A810 version e.
--[[ @title restore --]]
function restore()
print("Restore point 1")
click("video")
print("Restore point 2")
end
t_start = get_tick_count()
click("video")
print("Recording started")
repeat
sleep(100)
until (get_tick_count() - t_start) > 10000
print("Script ended itself")
restore()
The current implementation doesn't support this.
Calling 'click' suspends the script while the button press and release are done in the the core CHDK code.
However this looks like 'restore' has exited to the script engine so it finishes interrupting the script execution (so click never gets a chance to run).
Not easy to fix, anything used in 'restore' that causes Lua to yield control back to CHDK will have this effect.
Phil.
Logged
CHDK ports:
sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
g12 (1.00c, 1.00e, 1.00f & 1.00g)
sx130is (1.01d & 1.01f)
ixus310hs (1.00a & 1.01a)
sx40hs (1.00d, 1.00g & 1.00i)
g1x (1.00e, 1.00f & 1.00g)
g5x (1.00c, 1.01a, 1.01b)
g7x2 (1.01a, 1.01b, 1.10b)