Canon Camera Hackers Manual page 87

Camera hackers manual berthold daum
Table of Contents

Advertisement

78
C H A P T E R 5
Scripting
be executed immediately by pressing the shutter button. Pressing the shut-
ter button another time will interrupt the script execution immediately.
The next time you turn on the camera and the CHDK is activated, the
selected script will be loaded automatically. To execute it, it is sufficient to
switch to the <ALT> mode and press the shutter button. It is even possible
to run a script automatically at start-up. This is enabled by setting the entry
Autostart in the script menu to On. However, you should do this only with
well-tested scripts—otherwise, you could run into an error every time you
turn on the camera.
The Autostart feature can be used to initialize the camera with custom
settings when it is switched on. For example, in automatic mode, my little
SD1100 IS always switches the flash to AUTO. (In manual mode, it remem-
bers the flash mode of the previous session.) The camera offers no option
to always start with the flash switched off. This is unfortunate—I like avail-
able light shots much more than shots with the built-in flash. Sometimes,
in low-light conditions, I forget to switch the flash off—the flash fires, and
the mood is gone.
Here, the CHDK can help. A tiny script performs the necessary key
presses to switch the flash off. By loading the script flashoff.lua and set-
ting the Autostart parameter to On, I can make sure that this script is exe-
cuted at start-up and that I always start with a disabled flash. Here is the
script, written in Lua:
--[[
@title Flash off
]]
while get_flash_mode() ~= 2 do
click("right")
click("right")
click("set")
sleep(10)
end
exit_alt()
It's dead simple (apart from the header, which we will discuss later). While
the function get_flash_mode() does not return the value 2 (this value in-
dicates that the flash is switched off, see section 5.5.5), the script continues
to bring up the camera's flash menu with a click on the
it clicks
RIGHT
with a click on FUNC/SET. At the end of this sequence is a sleep(10) in-
struction, sending the script to sleep for 10 milliseconds and allowing the
native camera tasks to do their work.
The final instruction is necessary because otherwise the script would
leave the camera in <ALT> mode where no shooting is possible. Of course,
again to change the flash mode and confirms the change
RIGHT
button. Then

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents