upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER - General Discussion and Assistance - CHDK Forum

upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER

  • 10 Replies
  • 6571 Views
Advertisements

tl;dr> a patch to the set_xv96() commands so that they work correctly before or after a half press.


One quirk of setting exposure values manually from a script using the set_xv96() commands is that these commands must be issued prior to a half press :

Code: [Select]
tv=560
set_tv96_direct( tv+96 )
press("shoot_half")
repeat  sleep(50) until (get_shooting() == true )
press("shoot_full_only")
sleep(100)
release("shoot_full")
However,  if you are trying to set exposures manually, you probably want to know the current exposure setting.  But the apex96 values are not set until after a "half-press" is issued.   So the above script must be converted to look something like this :

Code: [Select]
press("shoot_half")
repeat  sleep(50) until (get_shooting() == true )
release("shoot_half")
tv=get_tv96()
set_tv96_direct( tv+96 )
press("shoot_half")
repeat  sleep(50) until (get_shooting() == true )
press("shoot_full_only")
sleep(100)
release("shoot_full")
Notice that there is a shoot-half , release,  shoot-half,  shoot-full,  release sequence - an extra half-press sequence that adds about 1 second to how long it takes to make a shot.  While there is a crude way to overcome this using set_param() after the half-press,  it would seem better to have the set_xv96() commands able to handle this on their own.

To understand this,  you need to know that what happens internally, based on SET_NOW & SET_LATER parameters,  is that the various set_xv96() commands are actually buffered internally and not issued until after a  "half-press" is issued inside the shoot() command.  The half press sets exposure params and the delay is necessary so that the override values are only set after the half-press sequence completes.

In conversation with reyalp on the CHDK IRC channel,  he suggested three ways to get around this :

1) Add SET_NOW and SET_LATER parameters to the set_xv96() commands.
2) Create new versions of set_xv96() that either set_now or set_later.
3) Modify the Lua & uBASIC code to automatically detect whether a set_now or set_later is needed.

As it turns out, the cleanest way to deal with this issue seems to be the third options.  By checking the status of the shooting process using the shooting_in_process() function,  the code can decide whether to use SET_NOW or SET_LATER.    I've attaches a patch that implements this for both uBASIC & Lua - it almost seems too easy.  Lua and uBASIC test scripts attached too.

Note : lapser went much farther with the set_xv96() function in his continous shooting timelapse patches.  I'd really rather not discuss those here - that's a seperate question that is only relevent in continuous mode and will no doubt take much conversation prior any part of it being added to the trunk.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #1 on: 10 / October / 2013, 15:35:25 »
Updated patch file that adds autodetect of set_now / set_later for set_nd_filter() with revised test scripts.

Patch now includes the following functions :
  • set_av96()
  • set_av96_direct()
  • set_tv96()
  • set_tv_96_direct()
  • set_sv96()
  • set_nd_filter()


And one additional update to my original post - I believe that this patch is 100% backwards compatible for Lua & uBASIC scripts.
« Last Edit: 10 / October / 2013, 15:39:59 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #2 on: 10 / October / 2013, 19:03:49 »
Thanks for doing this. I hope this ends up in the trunk. I added this capability to my time lapse build awhile back, and it's worked well. This was the original discussion:
http://chdk.setepontos.com/index.php?topic=9110.0

It's a little easier to create a "when()" function and substitute "when()" for "SET_LATER" in the relevant set_xx96() functions. Basically, you just search for "SET_LATER" in luascript.c and replace it with "when()". Here's the code I used in my builds:
Code: [Select]
//when() function allows scripts to set exposure (tv,sv,av,nd) values with half shoot
//  pressed that take effect immediately. Without when() function, changes won't
//  take place until the NEXT half_shoot. This requires double metering of each
//  shot, which slows down rate (by half) for multiple shots.
static int when()
{
  if(shooting_in_progress())return SET_NOW;
  return SET_LATER;
}

static int luaCB_set_av96_direct( lua_State* L )
{
  shooting_set_av96_direct( luaL_checknumber( L, 1 ), when() );
//  shooting_set_av96_direct( luaL_checknumber( L, 1 ), SET_LATER );
  return 0;
}

static int luaCB_set_av96( lua_State* L )
{
  shooting_set_av96( luaL_checknumber( L, 1 ), when() );
//  shooting_set_av96( luaL_checknumber( L, 1 ), SET_LATER );
  return 0;
}

static int luaCB_set_iso_real( lua_State* L )
{
  shooting_set_iso_real( luaL_checknumber( L, 1 ), when());
  return 0;
}

//search for SET_LATER and replace with when()

As you alluded to, when the when() function proposal didn't get into the trunk, I decided to write a single function to set everything. This won't be needed if your patch gets into the trunk. Good luck!
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #3 on: 10 / October / 2013, 19:13:05 »
It's a little easier to create a "when()" function and substitute "when()" for "SET_LATER" in the relevant set_xx96() functions. Basically, you just search for "SET_LATER" in luascript.c and replace it with "when()".

Actually,  I changed things a bit in my second patch to make it a little more elegent and efficient :

Code: [Select]
shooting_set_tv96( param, shooting_in_progress()? SET_NOW : SET_LATER ); But thanks for giving me another idea - check for other code using SET_LATER.  Sure enough,  I missed set_iso_real().   Updated patch attached.
« Last Edit: 10 / October / 2013, 20:00:50 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #4 on: 10 / October / 2013, 20:47:04 »
Code: [Select]
shooting_set_tv96( param, shooting_in_progress()? SET_NOW : SET_LATER ); That works too, and it's a little more clear than the when() function.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #5 on: 11 / October / 2013, 18:23:15 »
And one additional update to my original post - I believe that this patch is 100% backwards compatible for Lua & uBASIC scripts.

I think this is a good change and I will add it to SVN soon; but I don't think it is 100% compatible with all existing scripts.

A script might rely on the old behaviour to set the overrides for the next shot by calling the functions after the shutter half press.

For example I think this logic will work with the current code; but will fail in the new code:
- half press shutter
- get current values and calculate new values
- call override functions (sets up for next shot)
- release shutter
- call shoot

I have no idea if there are any scripts that do this, and if they do they can be easily fixed.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #6 on: 11 / October / 2013, 18:33:24 »
I think this is a good change and I will add it to SVN soon;
Thanks Phil. 

I've hit a wall with two of my new "power user" scripts. I can get past the "set_now" issue for tv,av,&sv using set_prop().   But the ND filter code does not work that way so I'm stuck.

Quote
but I don't think it is 100% compatible with all existing scripts.
Yea - I was going to say 99.9% compatible but decided not to equivocate.

Quote
A script might rely on the old behaviour to set the overrides for the next shot by calling the functions after the shutter half press.
For example I think this logic will work with the current code; but will fail in the new code:
- half press shutter
- get current values and calculate new values
- call override functions (sets up for next shot)
- release shutter
- call shoot
I have no idea if there are any scripts that do this, and if they do they can be easily fixed.
I'd venture to suggest that if they did that,  it would be as a "work around" to getting shooting going as quickly as possible while adjusting exposure on the fly?   Who knows?  In all likelihood,  the script would actually still continue to work, but the exposure control would be better.  Either way,  I doubt we will hear anything about this.

Update : just reread this   :-[  and I see now why that script would break using the new code.  Easy enough to fix as you say but its possible.

I don't suppose I can raise any support for back porting this into 1.2 ?



« Last Edit: 11 / October / 2013, 18:53:24 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #7 on: 11 / October / 2013, 20:38:32 »
For example I think this logic will work with the current code; but will fail in the new code:
- half press shutter
- get current values and calculate new values
- call override functions (sets up for next shot)
- release shutter
- call shoot

I have no idea if there are any scripts that do this, and if they do they can be easily fixed.

I thought about that possibility when I initially brought this up and came to the same conclusion. But to be completely compatible, I think this idea might work:

Code: [Select]
static int luaCB_set_av96_direct( lua_State* L )
{
  if(shooting_in_progress())shooting_set_av96_direct( luaL_checknumber( L, 1 ), SET_NOW);
  shooting_set_av96_direct( luaL_checknumber( L, 1 ), SET_LATER );
  return 0;
}
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #8 on: 11 / October / 2013, 22:31:10 »
I don't suppose I can raise any support for back porting this into 1.2 ?

I don't have a problem with putting it in 1.2.

If no one else objects I'll add it tomorrow.

Edit: Added to release-1.2 (revision 3153)

Phil.
« Last Edit: 12 / October / 2013, 18:06:35 by philmoz »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline lapser

  • *****
  • 1093
Re: upgrades to set_tv96(), set_av96(), set_sv96() for SET_NOW & SET_LATER
« Reply #9 on: 12 / October / 2013, 02:42:17 »
If no one else objects I'll add it tomorrow.
Great! Once it's in the trunk, I'll update my time lapse script to use the new functions in continuous mode and get rid of the set_exp96() function in my builds. I'll let you know how it works. Thanks again, waterwingz.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics


SimplePortal © 2008-2014, SimplePortal