Canon Camera Hackers Manual page 166

Camera hackers manual berthold daum
Table of Contents

Advertisement

elseif is_pressed("right") then
i = i + 1
if i > #files then i = 1 end
end
end
If a file was selected, we can now read the file and parse each line. But be-
fore we do so, we save the current display mode in order to restore it when
the script has finished. We also capture the current time in the variable
start_ticks. This will be the reference point for the Mission Elapsed Time.
The file is opened in read-only mode. The following for loop steps
through all the lines and invokes parse() on each of them. The return val-
ues are assigned to the variables foc, met, n, i1, i2, and disp. Depending on
whether a variable was supplied with a value or not (nil), the correspond-
ing steps are executed.
Before we take a picture with shoot(), we wait until the computed
event time (the start time plus the MET read from the file). If the user has
pressed the
DISP
key to cancel, the loop is exited. After a shot, a log entry is
created and printed to the display.
The sleep_until(), shoot(), and printing functions are contained in
an inner loop which handles the time series defined by the current sched-
ule line. For a single shot, n is 1, so this loop does not repeat. Otherwise, a
new event time is computed. If n is greater than 2, we have more than one
interval and must consider the possibility of sliding intervals, which we
compute from i1 and i2.
Finally, we close the schedule file, restore the display state, and—just in
case—release the autofocus lock:
if i then
old_display_mode =
get_prop(props.DISPLAY_MODE)
start_ticks = get_tick_count()
frame = 1
file = io.open (
schedules.."/"..files[i], "r")
for line in file:lines() do
local foc, met, n, i1,
i2, disp = parse(line)
if foc then
focus(foc)
end
if disp then
set_display_mode(disp)
end
5.7 Example scripts
157

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents