here's an update on this... you know how you can't put something down once you get started on it... I got some interesting results so I thought I would share them. Here's an updated script:
--[[
@title Delay Loop Test
@param a time delay (S)
@default a 2
--]]
old_max_count,old_max_ms=set_yield(1000,2000) --allow more instructions before yield, add more time
w=1000000
for Q=1,100 do --loop to run program 100 times because I don't know how to do labels or jump or goto in lua
set_led(3,1)
collectgarbage (collect) --perform full garbage collection cycle so there shouldn't be anything further to do for a while
collectgarbage (stop) --stops garbage collection while I run my script
print("Calibrating Delay Loop")
t=get_tick_count() --get start count
for y=1,w do --run delay loop
end
s=get_tick_count() --get stop count
u=s-t --time elapsed is stop-start
v=w*1000/u --how many loops per second
l=a*v --how many loops for specified time delay
print (t," Start Tics")
print (s," Stop Tics")
print (u," mS Per ",w)
print (v," Loops Per S")
print (l," Loops for ",a,"S")
set_led(3,0)
set_led(4,1)
for y=1,l do --test delay
end
set_led(4,0)
l=2*v --wait 2 seconds before starting over so I can read the screen
for y=1,l do
end
collectgarbage (restart) --restart garbage collection
end
set_yield(old_max_count,old_max_ms) --put yield back the way it was
I put some randomly larger values in for yield, and then I ran the garbage collection cycle, then stopped garbage collection. the results of this are quite amazing! with my previous script, it took about 4 seconds to do my 1million loops, This script does the same 1million loops in 1.2seconds!!! and not only that, if I run it in playback mode on the camera, it takes 1200ms every single time I run it.. running it over 30 times in a row! the previous program never got the same exact number three times in a row.
If I am in record mode, it is slightly slower and it does vary slightly... nowhere near like it was before, where it seemed all over the place... now it seems to be between 1390ms and 1400ms for the 1million test loops.
So maybe the motion detection part of it still wort work, but it looks like the delay is stable enough in playback mode.. so I could perhaps use the external light beam sensor triggering the usb port... we'll have to see. I need that cable to come in so I can trigger my dslr, then I will see if I can get repeatable results