CHDK 1.3 adds "hooks" which allow Lua scripts pause the shooting process when certain point are reached.
CHDK 1.3 is the unstable development branch, so this interface is subject to change. Please use the development thread http://chdk.setepontos.com/index.php?topic=11081.msg108530#msg108530 for feedback and bug reports.
There are currently 3 hooks defined (in order of execution)
Executes in shooting_expo_param_override, after CHDK overrides are applied. Can be used to adjust exposure settings after the camera has calculated it's own values. This hook only executes once per half press cycle, so if shooting in continuous mode, it will only be reached once before the continuous burst starts.
Executes very shortly before the shutter would open, in wait_until_remote_button_is_released (prior to the actual remote check). Can used to control the start of the exposure, to synchronize with an external process or to make continuous mode shoot at a specific interval.
Adjusting exposure, focus and zoom parameters here is not recommended. Exposure parameters will generally not take effect for the current shot. Zoom or focus may work, but the camera would not normally expect them to be manipulated at this point.
Executes in raw_process, after shot_histogram has built the raw histogram and DNG exif has been captured, but before any raw or DNG file has been written. It can be used to adjust the exposure for a following shot in continuous mode. In the future, the ability to directly read and write the raw buffer will be added.
Each of the hook is available in Lua as a table which contains a standard set of functions:
Enables the hook, so it will block the shooting process for up to timeout milliseconds. 0 disables the hook. Hooks are cleared when a script ends. They are not cleared between shots.
If timeout milliseconds pass without a call from continue, the shooting process will proceed as if continue had been called.
returns true when the shooting process is stopped in the hook.
Allows the shooting process to continue from the hook point.
Returns a count of how many times the hook has been reached for this script. This allows you to tell if a particular point has been reached without actually blocking the process.
Setting ISO in hook_preshoot may not work correctly on some cameras (those that require shooting_expo_iso_override in the capt_seq code)
A few ports may call shooting_expo_param_override more than once. On these ports, hook_preshoot will also be called more than once per shot.
A few ports may be missing wait_until_remote_button_is_released. On these ports, hook_shutter will not be reached.
There is no simple way to tell if a hook timed out.
Lua code may wait indefinitely for a hook that never becomes ready (for example, if shooting failed to start), unless it implements it's own timeout.