186
C H A P T E R 5
Scripting
5.7.6 Configuration switching
The CHDK features an incredible number of different configuration param-
eters. Under shooting conditions, it is not always easy to keep an overview
of which parameters are configured with which value. Wouldn’t it be great
if we could create some custom configurations—let’s say for casual shoot-
ing, HDR work, panorama shooting, and kite aerial photography—and later
simply switch between them? We have already seen something similar for
the parameters of a script that we can save as a numbered parameter set
and recall later (section 5.1).
The following script does exactly that. It uses the fact that all CHDK
configuration parameters are stored in a single file,
CHDK/CCHDK.CFG
. When
you invoke the script, it allows you to create a copy of this file, if the file has
changed since the last copy was made. It also allows you to select one of
the copies and make it the current configuration. After a restart of the
camera, the selected configuration becomes the active configuration. Of
course, every time the configuration is switched, a backup of the former
configuration is made—just to be safe.
The script is written in
Lua
because it needs the file management and
I/O functions of
Lua
. It maintains a small
INI
file (
CHDK/CONFSW.INI
) to re-
member the currently active configuration and a counter for the saved
configurations. These are all stored in folder
CHDK/CONFIGS
. As in the previ-
ous examples, the
pcall()
expression provides compatibility with a PC-
based debug environment (section 5.8).
--[[
@title Switch CHDK configuration
--]]
root = "A/CHDK"
pcall(function()
require("chdklib")
root = "TEST"
end
)
configs = root.."/CONFIGS"
ininame = root.."/CONFSW.INI"
current_config =
root.."/CCHDK.CFG"
The INI file is created with the help of function
write_ini()
. This function
accepts the parameters
name
with the name of the current configuration
Summary of Contents for Camera
Page 1: ......
Page 2: ...The Canon Camera Hackers Manual ...
Page 3: ......
Page 4: ...Berthold Daum The Canon Camera Hackers Manual Teach Your Camera New Tricks ...
Page 19: ...10 CH APTER 2 Cameras and Operating Systems ...
Page 25: ...16 CH APTER 3 ...
Page 85: ...76 CH APTER 4 Teach Your Camera New Tricks ...
Page 213: ...204 CH APTER 6 ...
Page 253: ...244 AP PENDIX ...