Read about our upcoming Code of Conduct on this issue

Commit 1a75388b authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Lua: lv.vidmode (current video mode, as string)

API tests included

--HG--
branch : lua_fix
parent 608755552ec2
...@@ -50,6 +50,14 @@ static int luaCB_lv_index(lua_State * L) ...@@ -50,6 +50,14 @@ static int luaCB_lv_index(lua_State * L)
else if (lv && lv_disp_mode) lua_pushinteger(L, 1); else if (lv && lv_disp_mode) lua_pushinteger(L, 1);
else lua_pushboolean(L, 0); else lua_pushboolean(L, 0);
} }
/// Get the name of current LiveView video mode.
///
/// Examples: MV-1080, MV-720, MVC-1080, REC-1080, ZOOM-X5, PH-LV, PH-QR, PLAY-PH, PLAY-MV...
//@tfield string vidmode
else if(!strcmp(key, "vidmode"))
{
lua_pushstring(L, get_video_mode_name(0));
}
else lua_rawget(L, 1); else lua_rawget(L, 1);
return 1; return 1;
} }
......
...@@ -951,6 +951,8 @@ function test_camera_take_pics() ...@@ -951,6 +951,8 @@ function test_camera_take_pics()
end end
function test_lv() function test_lv()
request_mode(MODE.M, "M")
printf("Testing module 'lv'...\n") printf("Testing module 'lv'...\n")
if lv.enabled then if lv.enabled then
printf("LiveView is running; stopping...\n") printf("LiveView is running; stopping...\n")
...@@ -959,10 +961,14 @@ function test_lv() ...@@ -959,10 +961,14 @@ function test_lv()
msleep(2000) msleep(2000)
end end
assert(not lv.enabled)
assert(lv.vidmode == "PH-NOLV")
printf("Starting LiveView...\n") printf("Starting LiveView...\n")
lv.start() lv.start()
assert(lv.enabled, "LiveView did not start") assert(lv.enabled, "LiveView did not start")
assert(not lens.autofocusing) assert(not lens.autofocusing)
assert(lv.vidmode == "PH-LV")
msleep(2000) msleep(2000)
...@@ -1005,6 +1011,13 @@ function test_lv() ...@@ -1005,6 +1011,13 @@ function test_lv()
printf("Setting zoom to x%d...\n", z) printf("Setting zoom to x%d...\n", z)
lv.zoom = z lv.zoom = z
assert(lv.zoom == z, "Could not set zoom in LiveView ") assert(lv.zoom == z, "Could not set zoom in LiveView ")
if z == 5 then
assert(lv.vidmode == "ZOOM-X5");
elseif z == 10 then
assert(lv.vidmode == "ZOOM-X10");
else
assert(lv.vidmode == "PH-LV")
end
lv.wait(5) lv.wait(5)
end end
...@@ -1013,6 +1026,7 @@ function test_lv() ...@@ -1013,6 +1026,7 @@ function test_lv()
assert(lv.enabled, "LiveView stopped") assert(lv.enabled, "LiveView stopped")
assert(lv.paused, "LiveView could not be paused") assert(lv.paused, "LiveView could not be paused")
assert(not lens.autofocusing) assert(not lens.autofocusing)
assert(lv.vidmode == "PAUSED-LV");
msleep(2000) msleep(2000)
...@@ -1021,6 +1035,7 @@ function test_lv() ...@@ -1021,6 +1035,7 @@ function test_lv()
assert(lv.enabled, "LiveView stopped") assert(lv.enabled, "LiveView stopped")
assert(not lv.paused, "LiveView could not be resumed") assert(not lv.paused, "LiveView could not be resumed")
assert(not lens.autofocusing) assert(not lens.autofocusing)
assert(lv.vidmode == "PH-LV");
msleep(2000) msleep(2000)
...@@ -1031,6 +1046,7 @@ function test_lv() ...@@ -1031,6 +1046,7 @@ function test_lv()
assert(not lv.paused, "LiveView is disabled, can't be paused") assert(not lv.paused, "LiveView is disabled, can't be paused")
assert(not lv.running, "LiveView is disabled, can't be running") assert(not lv.running, "LiveView is disabled, can't be running")
assert(not lens.autofocusing) assert(not lens.autofocusing)
assert(lv.vidmode == "PH-NOLV")
msleep(1000) msleep(1000)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment