5.7 Example scripts
139
PRESENTATION OF NEGATIVE VALUES IN
UBASIC
When reading properties with the
uBasic
command
get_prop
, negative val-
ues are represented as so-called 2-complements. Depending on the storage
size of the property (1 byte or 2 byte), either the value
2
16
+x
or
2
8
+x
is dis-
played.
Example: A value of 65500 is displayed. The real value is –36:
2
16
+(–36) = 65536–36 = 65500
.
In the table we have printed the property cases that can be
modified
by a
script in
bold
letters. All other properties are read-only, or modifying them
has not yet been tested. In general, however, it is better to change the
camera settings by simulating key presses (section 5.1). Changing camera
settings by setting property values can be sometimes problematic because
only part of the camera may be affected by a specific property case. For in-
stance, a property case may influence the camera optics while leaving the
user interface untouched.
This example is a property-based version of the script
flashoff.lua
from section 5.1:
--
flashof2.lua by Berthold Daum
--[[
@title Flash off
]]
props = require "propcase"
set_prop(props.SHOOTING,2)
exit_alt()
Here, the flash is switched off by assigning a value of 2 to property 143
(property 16 on DIGIC II). The script works all right—the flash is indeed
switched off. But the display does not reflect the new state. It still indicates
that the flash is in
AUTO
mode. When using the camera in unattended
mode (e.g., in an RC-controlled vehicle), nobody cares. But personally, I pre-
fer a display that truly reflects the state of the camera, so I would choose
the original version of the script as shown in section 5.1.
5.7
Example
scripts
Scripting is a popular topic on the CHDK web pages. Most of the scripts
deal with timers, bracketing, or motion detection. Timers are typically used
for operating the camera autonomously (e.g., from a kite or a balloon) or
Содержание 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 ...