supplierdeeply

Restore original settings after (lua) script run?

  • 6 Replies
  • 573 Views
*

Offline bugbear

  • **
  • 57
  • A630
    • woodwork on geocities
Restore original settings after (lua) script run?
« on: 30 / April / 2018, 09:58:06 »
Advertisements
I have a script which does  "stacking" of both focus and exposure.

I use it to photograph the internals of engines or amplifiers (don't ask).

it runs fine, and does almost exactly what I want.

I normally run it in Manual mode, with the focus preset and locked. This is
(in effect) how I tell the script the starting conditions.

After the script has run, I wish the camera to be as it was before the script is run.

This means I can run the script repeatedly.

Sadly, my "restore" function doesn't work, and I don't understand why.
The code is pretty simple (although I did have a bit of a run-in with Lua's
"global variables by default" concept).

  Script, and a log run attached.

   BugBear

*

Offline reyalp

  • ******
  • 11543
Re: Restore original settings after (lua) script run?
« Reply #1 on: 30 / April / 2018, 13:25:15 »
Sadly, my "restore" function doesn't work, and I don't understand why.
The code is pretty simple (although I did have a bit of a run-in with Lua's
"global variables by default" concept).
In general, CHDK overrides set in script only apply while the script they were set in is running. So "restoring" tv and av should have no effect. If the camera is in manual mode, you can set the USER_TV and USER_AV values instead. These will persist until changed in the UI.

Focus depends on what mode the camera is in. If the camera is in MF or AF lock, calling set_focus moves the lens immediately, and the lens will remain in that position after the script ends. If the camera is in AF mode, then it behaves like the the exposure settings and any set override is cleared when the script ends.
Don't forget what the H stands for.

*

Offline bugbear

  • **
  • 57
  • A630
    • woodwork on geocities
Re: Restore original settings after (lua) script run?
« Reply #2 on: 01 / May / 2018, 10:42:32 »
My problem is that the script (despite my restore function) DOES alter the shutter speed "persistently"

Because I'm bracketing, and the script moves from slow to fast, the camera is thus left on a fast shutter speed.

(this does NOT show in the GUI).

If I run the script again, the script STARTS at the newly increased shutter speed, and (thus) increases it some more.

It is this behaviour I wish to stop.

   BugBear

*

Offline reyalp

  • ******
  • 11543
Re: Restore original settings after (lua) script run?
« Reply #3 on: 01 / May / 2018, 13:27:52 »
My problem is that the script (despite my restore function) DOES alter the shutter speed "persistently"
Your script gets the initial values from the propcases in gather. If the camera is in a manual mode, these will probably be set to whatever was used in the last shot, since they are only updated on half press. If you want to use the UI values in M mode, you could initialize from USER_TV and USER_AV instead, or do a half press to ensure the propcases are updated.

I think this should not happen in non-manual mode, because it does a half press, but I haven't tested it.
Don't forget what the H stands for.


*

Offline bugbear

  • **
  • 57
  • A630
    • woodwork on geocities
Re: Restore original settings after (lua) script run?
« Reply #4 on: 02 / May / 2018, 03:55:54 »
That sounds like it will lead to a solution - although the values I gather ARE the ones I want the first time the script is run, even with no half press.

Thank you!

My intention (as you may have guessed) is that if the 2 values that I need (shutter and focus) are LOCKED I don't do a needless half-press to get them set.


  BugBear

*

Offline bugbear

  • **
  • 57
  • A630
    • woodwork on geocities
Re: Restore original settings after (lua) script run?
« Reply #5 on: 02 / May / 2018, 05:53:08 »
(I only noticed this fault on repeated uses of my script because I was shooting
a focus stacked HDR panorama !!!)

 BugBear

*

Offline bugbear

  • **
  • 57
  • A630
    • woodwork on geocities
Re: Restore original settings after (lua) script run?
« Reply #6 on: 02 / May / 2018, 12:05:57 »
And (just to confirm) by using two different "gather" scripts, my script is now doing what I want;

function gather_m()
    local g = {}
    g.tv = get_user_tv96()
    g.av = get_user_av96()
    g.focus = get_focus()
    return g
end

function gather()
    local g = {}
    g.tv = get_tv96()
    g.av = get_av96()
    g.focus = get_focus()
    return g
end

   BugBear

 

Related Topics