Commit 33e96301 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Lua: lv.overlays (status of Canon/ML overlays in LiveView)

API test included

--HG--
branch : lua_fix
parent 36f1a4c763b7
......@@ -42,6 +42,14 @@ static int luaCB_lv_index(lua_State * L)
/// Get/set LiveView zoom factor (1, 5, 10).
// @tfield bool zoom
else if(!strcmp(key, "zoom")) lua_pushinteger(L, lv_dispsize);
/// Get the status of LiveView overlays (false = disabled, 1 = Canon, 2 = ML)
// @tfield int overlays
else if(!strcmp(key, "overlays"))
{
if (zebra_should_run()) lua_pushinteger(L, 2);
else if (lv && lv_disp_mode) lua_pushinteger(L, 1);
else lua_pushboolean(L, 0);
}
else lua_rawget(L, 1);
return 1;
}
......@@ -381,6 +389,7 @@ static const char * lua_lv_fields[] =
"paused",
"running",
"zoom",
"overlays",
NULL
};
......
......@@ -9,6 +9,10 @@ test_log = nil
function printf(s,...)
test_log:writef(s,...)
if not console.visible then
display.notify_box(s:format(...), 5000)
end
end
function request_mode(mode, mode_str)
......@@ -961,7 +965,42 @@ function test_lv()
assert(not lens.autofocusing)
msleep(2000)
-- lv.overlays status
local function print_overlays_status()
-- 1 = Canon overlays, 2 = ML overlays (when global draw is on), false = no overlays enabled
-- using false instead of 0 to allow using in a conditional expression: if lv.overlays then ...
printf("Overlays: %s\n", lv.overlays == 1 and "Canon" or lv.overlays == 2 and "ML" or "disabled");
end
console.hide(); assert(not console.visible)
local old_gdr = menu.get("Overlay", "Global Draw")
for i=1,10 do
key.press(KEY.INFO)
msleep(200); print_overlays_status()
msleep(1000)
if lv.overlays ~= 1 then
-- Canon overlays disabled?
-- Enable ML overlays
assert(menu.set("Overlay", "Global Draw", "ON"))
msleep(200); print_overlays_status()
assert(lv.overlays == 2)
msleep(1000)
-- Disable ML overlays
assert(menu.set("Overlay", "Global Draw", "OFF"))
msleep(200); print_overlays_status()
assert(lv.overlays == false)
msleep(1000)
end
end
-- restore original Global Draw setting
assert(menu.set("Overlay", "Global Draw", old_gdr))
assert(menu.get("Overlay", "Global Draw") == old_gdr)
msleep(200); print_overlays_status()
console.show(); assert(console.visible)
msleep(2000)
for i,z in pairs{1, 5, 10, 5, 1, 10, 1} do
printf("Setting zoom to x%d...\n", z)
lv.zoom = z
......
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