OK, worked it out: I think?
That is unless someone tells me I can make it faster
function myshoot()
ecnt = get_exp_count()
press("shoot_full_only")
repeat
sleep(50)
until (get_shooting() == true)
release("shoot_full_only")
repeat
sleep(50)
until (get_shooting() == false)
end
It's a little hard to comment without knowing the context. I guess other code presses and holds shoot_half, and uses ecnt for something?
Or are you not pressing shoot_half at all? If that's the case, I definitely would suggest switching to the hold shoot_half, click shoot_full_only approach.
1) In general, you the wait for get_shooting to be true should be after pressing shoot_half, before pressing shoot_full_only. Pressing shoot_full_only before get_shooting becomes true uses the "quick press" code path in the canon code, which can make overrides and possibly other stuff unreliable.
2) You shouldn't assume that get_shooting() will go false while shoot_half is held.
3) To detect when it's ok to release shoot_full_only (i.e ensure it's been held long enough to trigger the shot), I'd suggest using the hook_shoot script shooting hook
https://chdk.fandom.com/wiki/Script_Shooting_Hooks#hook_shootSince you don't need shooting to wait in the hook, you can just use the count, something like
local prevcnt=hook_shoot.count()
press'shoot_full_only'
repeat sleep(10) until prevcnt ~= hook_shoot.count()
release'shoot_full_only'
hooktest.lua in the CHDK distribution and my
fixedint script are some examples of scripts that allow the hold shoot_half, click shoot_full approach.
If you are feeling sporty, you could try using continuous mode instead (also available in the scripts above), but changing focus may be more suspect.