I'm afraid this does not work because the sx40 has a native MF mode. We must switch into the MF mode for set_focus. This only works with Lua.
Here is a sample script (not tested):
@title bokeh
@param f focus [mm]
@default f 20
]]
function switchAF_MF()
post_levent_for_npt("PressSw1AndMF")
sleep(500)
end
-- first shot
shoot()
Tv=get_tv96()
Av=get_av96()
repeat sleep(10) until get_shooting() ~= true
-- second shot
switchAF_MF()
set_tv96_direct(Tv)
set_av96_direct(Av)
set_focus(f)
shoot()
repeat sleep(10) until get_shooting() ~= true
switchAF_MF()
print("done")
Probably there is yet another problem with the minimum distance. See platform_camera.h for the SX40.
#define CAMERA_MIN_DIST 95 // Override min subject distance
msl
edit: script corrected, thx ww.