Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
magic-lantern
magic-lantern
Commits
d276af57433b
Commit
5c3fcb58
authored
Mar 27, 2016
by
alex@thinkpad
Browse files
api_test.lua: tests for lens.focus
--HG-- branch : lua_fix
parent
82dec5aa65ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/api_test.lua
View file @
d276af57
...
...
@@ -436,6 +436,68 @@ function test_lv()
printf
(
""
)
end
function
test_lens_focus
()
if
lens
.
name
==
""
then
printf
(
"This test requires an electronic lens."
)
assert
(
not
lens
.
af
,
"manual lenses can't autofocus"
)
return
end
if
not
lens
.
af
then
printf
(
"Please enable autofocus."
)
printf
(
"(or, remove the lens from the camera to skip this test)"
)
while
not
lens
.
af
and
lens
.
name
~=
""
do
console
.
show
()
msleep
(
1000
)
end
end
if
not
lv
.
running
then
lv
.
start
()
assert
(
lv
.
running
)
end
if
lens
.
af
then
printf
(
"Focus distance: %s"
,
lens
.
focus_distance
)
-- note: focus direction is not consistent
-- some lenses will focus to infinity, others to macro
printf
(
"Focusing backward..."
)
while
lens
.
focus
(
-
1
,
3
,
true
)
do
end
printf
(
"Focus distance: %s"
,
lens
.
focus_distance
)
for
i
,
step
in
pairs
{
3
,
2
,
1
}
do
printf
(
"Focusing forward with step size %d..."
,
step
)
local
steps_front
=
0
while
lens
.
focus
(
1
,
step
,
true
)
do
console
.
write
(
"."
)
steps_front
=
steps_front
+
1
end
printf
(
""
)
printf
(
"Focus distance: %s"
,
lens
.
focus_distance
)
msleep
(
500
)
printf
(
"Focusing backward with step size %d..."
,
step
)
local
steps_back
=
0
while
lens
.
focus
(
-
1
,
step
,
true
)
do
console
.
write
(
"."
)
steps_back
=
steps_back
+
1
end
printf
(
""
)
printf
(
"Focus distance: %s"
,
lens
.
focus_distance
)
msleep
(
500
)
printf
(
"Focus range: %s steps forward, %s steps backward. "
,
steps_front
,
steps_back
)
end
printf
(
"Focus test completed."
)
else
printf
(
"Focus test skipped."
)
end
printf
(
""
)
end
function
api_tests
()
menu
.
close
()
console
.
clear
()
...
...
@@ -448,6 +510,7 @@ function api_tests()
printf
(
"Module tests..."
)
test_camera_exposure
()
test_lv
()
test_lens_focus
()
printf
(
"Done!"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment