5.7 Example scripts
157
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
Содержание Camera
Страница 1: ......
Страница 2: ...The Canon Camera Hackers Manual ...
Страница 3: ......
Страница 4: ...Berthold Daum The Canon Camera Hackers Manual Teach Your Camera New Tricks ...
Страница 19: ...10 CH APTER 2 Cameras and Operating Systems ...
Страница 25: ...16 CH APTER 3 ...
Страница 85: ...76 CH APTER 4 Teach Your Camera New Tricks ...
Страница 213: ...204 CH APTER 6 ...
Страница 253: ...244 AP PENDIX ...