Author Topic: FRSP access from Lua  (Read 1621 times)

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1700
FRSP access from Lua
« on: December 16, 2016, 06:44:25 PM »
I hope some other 'scripter' has an answer for this question: how do I trigger FRSP within a Lua script?

I did succeed in doing this via the intervalometer, but bluntly it is very flaky.

'All' I wish to do is trigger a FRSP, repeatedly, from with Lua.

Cheers

Garry

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12173
  • Maintenance mode
Re: FRSP access from Lua
« Reply #1 on: December 16, 2016, 06:51:03 PM »
On the lua_fix branch, enabling silent picture from menu (any kind, not just full-res) and calling camera.shoot() as usual should do the trick.

Not tested though.

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1700
Re: FRSP access from Lua
« Reply #2 on: December 16, 2016, 08:31:55 PM »
@a1ex

Thanks for the tip off :-)

I'm using this https://bitbucket.org/daniel_fort/magic-lantern/downloads/magiclantern-manual_lens_info.2016Dec05.5D3113.zip which I think includes the Lua fix.

Here is my test code, the relevant function is go, however things don't seem to be working as expected:

Code: [Select]
--[[
LE simulation via Bracketing, using shutterless, Full Res Silent Picture
Creates brackets for post processing a simulated LE exposure
User must set FRSP mode, ie DNG or MLV and also wheather to use Dual-ISO
Base exposure must be between 0.25-14 secs
Version 0.8
*******************************************************************************************************
*   *
* If you reference this script, please consider acknowledging me: http://photography.grayheron.net/   *
*   *
*******************************************************************************************************
--]]

LE_brackets = 0

function my_shoot()
-- Grab an image
camera.shoot(false)
end


function go() -- and run the script
    local LE_count = 0
if camera.shutter.value < 0.25 or camera.shutter.value > 14 then -- not fit for FRSP use
menu.set("Shoot","Silent Picture",0)
beep (3, 200 , 500)  -- display warning message
display.notify_box("Adjust your shutter time: 0.25-14 secs", 5000)
else -- alright to use FRSP
menu.set("Shoot","Silent Picture",1)
        msleep(tonumber(LEmenu.submenu["Delay"].value) * 1000)
    repeat
        LE_count = LE_count + 1
    my_shoot()
        until LE_count == LE_brackets
menu.set("Shoot","Silent Picture",0)
LV.resume()
end
end

LEmenu = menu.new
{
    parent = "Shoot",
    name = "LE Simulator",
    help = "Only uses FRSP",
depends_on = DEPENDS_ON.LIVEVIEW,
    submenu =
{
{
name = "Run Script",
help = "Does what it says after pressing SET",
depends_on = DEPENDS_ON.LIVEVIEW,
select = function(this) task.create(go) end,
},
{
name = "LE Time?",
help = "Simulated LE time in seconds",
min = 0,
max = 600,
icon_type = ICON_TYPE.BOOL,
select = function(this,delta)
this.value = this.value + delta
if this.value > this.max then
this.value = this.min
elseif this.value < this.min then
this.value = this.max
end
end,
warning = function(this)
if LEmenu.submenu["LE Time?"].value ~= 0 then
LE_brackets = math.ceil(LEmenu.submenu["LE Time?"].value/camera.shutter.value)
if LE_brackets == 0 then
return "LE bracket taking switched off"
else
return "Note: "..tostring(LE_brackets).." brackets will be taken"
end
end
end
               },
{
name = "Delay",
help = "Delays script start by stated number of secs",
choices = {"2","5","0"},
},{
name = "Bookends?",
help = "Places a dark frame at start and end of focus bracket set",
choices = {"no","yes"},
}
}
}

The script doesn't always run, I sometimes see strange characters in my menu and, more importantly, LV doesn't resume.

Of course it could all be down to me scripting...then again it be be a bug in the branch.

Not sure if you or David can spot anything?

Cheers

Garry

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1700
Re: FRSP access from Lua
« Reply #3 on: December 16, 2016, 08:47:19 PM »
I'm an IDIOT!!!!!!!!!!!

lv.resume() not LV.resume()

:-)

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12173
  • Maintenance mode
Re: FRSP access from Lua
« Reply #4 on: December 16, 2016, 09:27:54 PM »
That works, but only if image review is turned off. That's because I'm switching to QuickReview mode in order to trigger the overlays for preview (zebras, histogram and so on), so the camera is no longer in the plain LiveView paused mode. For some reason, it doesn't want to come back from this state with the usual method (even if I'd expect it to).

This appears to cover both cases:
Code: [Select]
function go() -- minimal example
    menu.close()
    my_shoot()
    key.press(KEY.HALFSHUTTER)
    msleep(100)
    key.press(KEY.UNPRESS_HALFSHUTTER)
end

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1700
Re: FRSP access from Lua
« Reply #5 on: December 17, 2016, 08:36:38 AM »
@A1ex

Thanks that little trick of yours seems to have done the trick  :)

Cheers

Garry