In order to set focus I am using set_aflock(0) . But this time when I zoom in or out , after zoom camera shuts itself down.To solve problem I am calling set_aflock(1) before zooming.This solves shut down problem but another problem is occuring.The first capture after zoom is not focusing but second shot is focusing.These are code snippets related to problem.
I don't know what camera you are using, but using
set_zoom( ) definitely causes problems on some cameras. I first ran into this almost four years ago and so far there has not been a definitive solution. See :
set_zoom problems in uBASIC & Lua scriptsFrom your description, it sounds like what I think I've seen before where moving the zoom confuses the focus mechanism (i.e the set_zoom call misses some sort of interlock with the focus controller) and the camera gives up and shuts down. When you lock the focus with set_aflock(1) the camera does not try to refocus and thus does not crash. It's curious that it actually tries to refocus after the first shot - I don't thing that's supposed to happen once you do a set_aflock(1).
There are a number of possible "fixes" that might help :
- Insert a sleep(4000) after each set_zoom( ) call to allow things to "settle"
- Do a "half shoot" press & release after each set_zoom( ) call to force a refocus
- Change the zoom parameter in platform_camera.h and rebuilt CHDK for your camera
#undef CAM_NEED_SET_ZOOM_DELAY // Define to add a delay after setting the zoom position before resetting the focus position in shooting_set_zoom
#undef CAM_USE_ALT_SET_ZOOM_POINT // Define to use the alternate code in lens_set_zoom_point()
#undef CAM_USE_ALT_PT_MoveOpticalZoomAt // Define to use the PT_MoveOpticalZoomAt() function in lens_set_zoom_point()
It would be good if you can produce a
ROMLOG.LOG to confirm what is causing the crash ( focus_lens_controller or something). In the CHDK menus, go to
Miscellaneous Stuff ->
Debug Parameters ->
Save ROM crash log and then attach the resulting file to a post here.
FYI : set_zoom_speed(x) only works of a few older cameras.