I am feeding 3 different pulses to the camera, 20, 50 , 70ms.
The three work fine, reliable.
That is, until I uncomment the call "Shoot()" function - once it takes a photo, the pulse width feature goes bananas, detecting any of the modes randomly.
Two questions:
Is there something fishy with the "Shoot" function ?
Is LUA, or a bug within the script overloading the cameras CPU, (in case pulse width feature is software-based) ?
--[[
@title USB Tester
@param m Mode
@default m 0
@values m State Width Pulses Count Key
--]]
function printf(...)
local tic = get_day_seconds()
print (string.format("%02d:%02d:%02d %s", tic/3600, tic%3600/60, tic%60, ...))
end
function StartStopVideo()
local rec, vid = get_mode()
local vid_button = get_video_button()
if rec == true and vid == true and vid_button == 0 then
press("shoot_full")
sleep(300)
release("shoot_full")
elseif rec == true and vid_button == 1 then
click("video")
end
end
function Shoot()
press("shoot_half")
repeat sleep(50) until get_shooting() == true
press("shoot_full")
sleep(500)
release("shoot_full")
repeat sleep(50) until get_shooting() == false
release("shoot_half")
end
mode = m
set_console_layout(1, 1, 44, 10) --console position x1,y1,x2,y2
last=2 -- 1=low 2=med 3=high
print("PWM remote")
set_config_value(121,1) -- make sure USB remote is enabled
scount=0
usb_state=-1
rkey=0
repeat
sleep(50)
x=get_usb_power(0)
--[[
if ( x == 0) --nothing new since last time
then
if (last==1)
then
printf("REPEAT, width ="..(x*10).." mSec")
--Shoot() --repeat until switch centered
sleep(50)
end
end
--]]
if ( x > 1 and x < 3 ) --looking for 20ms "low/shoot"
-- if ( x > 1 and x < 3 and last ~= 1) --looking for 20ms "low/shoot"
then
last=1
printf("shooting, "..(x*10).." mSec")
Shoot()
end
-- if ( x > 6 and x < 8 and last ~= 2) --looking for 70ms "neutral/center"
if ( x > 6 and x < 8 ) --looking for 70ms "neutral/center"
then
last=2
printf("center, "..(x*10).." mSec")
end
if ( x > 3 and x < 6 ) --looking for 50ms "high/mode"
-- if ( x > 3 and x < 6 and last ~= 3) --looking for 50ms "high/mode"
then
last=3
printf("mode, ="..(x*10).." mSec")
--StartStopVideo()
end
until is_pressed("menu")
set_config_value(121,0) -- make sure USB remote is disabled