Canon Camera Hackers Manual page 150

Camera hackers manual berthold daum
Table of Contents

Advertisement

Accurate time lapse
The Accurate Time Lapse script first defines a few parameters. n specifies
the total number of shots to be taken. The delay between the shots is
computed as (((m*60)+s)*10+t)*100 from the parameters m (minutes), s
(seconds), and t (tenth of a second). The result is the total delay in millisec-
onds.
Two more parameters allow control of focusing and display. If parame-
ter f is set to 1, the camera will focus only once and then leave the focus
unchanged. Otherwise, the autofocus process will be performed before
each shot. If parameter d is set to 0, the display is darkened to save battery
life.
--[[
@title Accurate time lapse
@param n Number of frames
@default n 10
@param m Delay min
@default m 5
@param s Delay sec
@default s 0
@param t Delay 1/10 sec
@default t 0
@param f Focus 0 Each 1 Start
@default f 0
@param d Display 0 off 1 on
@default d 1
--]]
In Lua, functions must be defined before they are invoked. So, we start with
function definition first. Because there is no built-in command to set the
display mode, we need to select it by simulated key presses. Since we cannot
be sure about the initial state, we simply check after each key press to see
whether we have reached the desired state. This is done with the function
get_prop() that retrieves the respective property case (section 5.6). Instead
of a numeric property ID, we use the constant props.DISPLAY_MODE. The
table props is defined in library propcase.lua, which is part of the CHDK
installation and which we have loaded with require("propcase"). The
advantage of this technique is that it is platform-independent. The numeric
Property Case IDs, in contrast, are different for each operating system. The
sleep() function pauses the script for 100 msec to give the camera some
time to do its work.
The definition of function idiv() and the pcall() expression provide
compatibility with the PC-based debug environment (section 5.8). idiv()
performs an integer division. Under the CHDK, the results of idiv() are
identical to those obtained with the operator /; but in a floating-point
5.7 Example scripts
141

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents