5.2 uBasic
81
rem DigitalMacro
o = get_display_mode
d = 1
gosub "display"
p = 0
e = -32248
gosub "mode"
Then we start to set up the camera. First, we save the current display state
into variable
o
, so that when leaving the script we can reset the previous
state. We assign the desired display state (
No Info
= 1) to variable
d
. The
subroutine
display
will click the
DISP
button until that state is reached.
Because
uBasic
subroutines do not support variables and don’t return val-
ues, we must transfer data between subroutine and caller via variables.
To switch the camera mode, we will work a little bit differently. The
variable
p
will count the number of
RIGHT
clicks to reach the
DigitalMacro
mode. We initialize it with 0. Then we assign –32248 to variable
e
. This
value represents the
DigitalMacro
mode (section 5.6). The subroutine
mode
will pick up that value; press
FUNC/SET
,
RIGHT
,
FUNC/SET
repeatedly until
this mode is reached. Both subroutines (
display
and
mode
) are discussed
below. It’s important to know that by simulating key presses, we can reach
any camera function via a script that we can reach manually. It’s good
practice not to make assumptions about the initial state of the camera,
and to restore the initial state when the script ends.
rem set zoom level
q = get_zoom
gosub "zoom"
gosub "focus"
Next, the initial zoom level is saved into variable
q
, and the desired zoom
level (stored in variable
s
) is set in subroutine zoom. Afterwards, subroutine
focus
is called to focus the camera to the subject matter.
cls
rem Event loop until MENU pressed
do
wait_click
if is_pressed "zoom_in"
then gosub "zomin"
if is_pressed "zoom_out"
then gosub "zomout"
if is_pressed "shoot_half"
then gosub "focus"
until is_pressed "menu"
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 ...