SET_NOW option for set_tv96_direct() - General Discussion and Assistance - CHDK Forum supplierdeeply

SET_NOW option for set_tv96_direct()

  • 5 Replies
  • 1951 Views
*

Offline lapser

  • *****
  • 1093
SET_NOW option for set_tv96_direct()
« on: 14 / December / 2012, 02:25:45 »
Advertisements
set_tv96_direct(value), and the similar functions for sv and av, all call their corresponding CHDK functions with the "SET_LATER" flag. The shutter speed change only takes effect with the next half shoot.

But if you want to calculate and set a new TV based on the BV value from half_shoot, you have to release and re-press half_shoot to get it to take effect.

There is a work around I've been using in Lua that sets the property cases for TV. But the easier way to do it would be to have the option to use the "SET_NOW" flag with set_tv96_direct(value).

So I propose adding an optional parameter to the Lua functions set_tv96_direct(value[, when]). Without the extra parameter, it would default to SET_LATER. If "when" is 1, it would use SET_NOW.

This would eliminate the need to use property cases in Lua. Setting SV with property cases is more complicated. I figured out a way to do it that works, but it would be better to use the CHDK function with the SET_NOW flag.

An optional parameter would be the safest and most compatible way to do it. It wouldn't break any old scripts.

Another idea is to use SET_NOW if get_shooting() is true, and SET_LATER if it isn't. It sound like it would work. What am I missing?

I can write the code if I get the go ahead.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline reyalp

  • ******
  • 12214
Re: SET_NOW option for set_tv96_direct()
« Reply #1 on: 14 / December / 2012, 03:33:50 »
Since set_now just sets the propcase, this needs to happen in a particular point in the shooting process, it seems to me exposing at as an option to set_tv96_direct would just add confusion without much value.
Quote
Another idea is to use SET_NOW if get_shooting() is true, and SET_LATER if it isn't. It sound like it would work. What am I missing?
This would make more sense, although one thing to watch out for is when get_shooting goes back to false.
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: SET_NOW option for set_tv96_direct()
« Reply #2 on: 14 / December / 2012, 08:33:36 »
Since set_now just sets the propcase, this needs to happen in a particular point in the shooting process, it seems to me exposing at as an option to set_tv96_direct would just add confusion without much value.
Yes, it would be too confusing. The proper way to do it would be with 3 new functions:
set_tv96_now(value)
set_av96_now(value)
set_sv96_now(value)

Yes, you can set the prop_cases, but only in Lua, and it adds some complexity to the Lua program. Furthermore, setting the sv_96 isn't just setting the propcases. If you look at the function in shooting.c, there's some calculations involved that are very difficult to figure out in lua.
Quote
Another idea is to use SET_NOW if get_shooting() is true, and SET_LATER if it isn't. It sound like it would work. What am I missing?
Quote
This would make more sense, although one thing to watch out for is when get_shooting goes back to false.
Yes, I like this solution the best because there would be a minimal change in the code and no new functions or options. However, it would change the way the functions operate  If a script uses set_tv96_direct during half_shoot, i.e. get_shooting() is true, it probably thinks it is happening immediately, although it won't really take effect until another half_shoot. Scripts that are aware of this may be releasing half_shoot and then taking the shot. Are you saying that the values in the prop_cases would be lost if this happens? If so, you'd need the new functions to keep from breaking old scripts.

Another way to do it would be to just add one new function:

set_now()

After calling this single function, all calls to any of the set_tv, set_av, or set_sv functions would use SET_NOW instead of SET_LATER when get_shooting() is true. The instructions for set_now() would make it clear that the changes would only take effect if you take the shot before releasing half shoot.

It would be very easy to program. Just replace all the references to SET_LATER with when() and add this to luascript.c
Code: [Select]
static int now_flag=0;
static int when()
{
  if(now_flag&&shooting_in_progress())return SET_NOW;
  return SET_LATER;
}
extern void set_later() //called in script.c before script starts
{
  now_flag=0;
}
//also need new lua function set_now() that just does: now_flag==1;
I see no need for a set_later() Lua function. set_now() would last until the script terminates. set_later() would be called by script.c before starting a new script. This idea has my vote for now. How does it sound to you?
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline lapser

  • *****
  • 1093
Re: SET_NOW option for set_tv96_direct()
« Reply #3 on: 14 / December / 2012, 09:32:06 »
Here are the proposed code changes. It looks like I can reset the now_flag in lua_script_start() instead of adding a function to call from script.c. Also, I named the function "set_now_flag()" instead of  "set_now()." My reaction to "set_now()" was, "set_what_now()?"
Code: [Select]
static int now_flag=0;
static int when()
{
  if(now_flag&&shooting_in_progress())return SET_NOW;
  return SET_LATER;
}
...
int lua_script_start( char const* script, int ptp )
{
  now_flag=0; //set_tv,sv,av default to SET_LATER
...
static int luaCB_set_now_flag( lua_State* L )
{
  now_flag = luaL_checknumber( L, 1 ) != 0;
  //set_now_flag(1) means all calls to set_tv,sv,av functions take place immediately if shooting_in_progress()
  return 0;
}

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

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

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

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

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

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

static int luaCB_set_nd_filter( lua_State* L )
{
  shooting_set_nd_filter_state( luaL_checknumber( L, 1 ), when());
  return 0;
}
...
    FUNC(set_now_flag)
[edit] I just tested the above routines with my time lapse script and set_tv96_direct(tv). It worked fine, just like with propcases, as expected. I need to test it with set_sv96(sv) to see if that also works as expected.
« Last Edit: 14 / December / 2012, 13:45:53 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


*

Online philmoz

  • *****
  • 3137
    • Photos
Re: SET_NOW option for set_tv96_direct()
« Reply #4 on: 14 / December / 2012, 15:34:36 »
Here are the proposed code changes. It looks like I can reset the now_flag in lua_script_start() instead of adding a function to call from script.c. Also, I named the function "set_now_flag()" instead of  "set_now()." My reaction to "set_now()" was, "set_what_now()?"
Code: [Select]
static int now_flag=0;
static int when()
{
  if(now_flag&&shooting_in_progress())return SET_NOW;
  return SET_LATER;
}
...
int lua_script_start( char const* script, int ptp )
{
  now_flag=0; //set_tv,sv,av default to SET_LATER
...
static int luaCB_set_now_flag( lua_State* L )
{
  now_flag = luaL_checknumber( L, 1 ) != 0;
  //set_now_flag(1) means all calls to set_tv,sv,av functions take place immediately if shooting_in_progress()
  return 0;
}

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

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

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

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

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

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

static int luaCB_set_nd_filter( lua_State* L )
{
  shooting_set_nd_filter_state( luaL_checknumber( L, 1 ), when());
  return 0;
}
...
    FUNC(set_now_flag)
[edit] I just tested the above routines with my time lapse script and set_tv96_direct(tv). It worked fine, just like with propcases, as expected. I need to test it with set_sv96(sv) to see if that also works as expected.

Maybe I'm missing something obvious; but if this only applies if trying to set values when the shutter is half pressed why not just test that?

Release-1.1
Code: [Select]
static int when()
{
  if(kbd_is_key_pressed(KEY_SHOOT_HALF))return SET_NOW;
  return SET_LATER;
}

Trunk
Code: [Select]
static int when()
{
  if(camera_info.state.is_shutter_half_press)return SET_NOW;
  return SET_LATER;
}

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)

*

Offline lapser

  • *****
  • 1093
Re: SET_NOW option for set_tv96_direct()
« Reply #5 on: 14 / December / 2012, 17:17:15 »
Maybe I'm missing something obvious; but if this only applies if trying to set values when the shutter is half pressed why not just test that?
The only reason for a set_now flag would be compatibility for old scripts. If an old script did set_tv96 in half shoot expecting set_later, then released and pressed half_shoot again expecting the new values to be used, it wouldn't work. The camera would use it's own values. I think this is the whole purpose of set_later, i.e., to override the camera values when pressing half or full shoot. Make sense?

I think a similar problem would occur if you test for half_shoot instead of get_shooting(). After pressing half shoot, there is a delay before get_shooting() becomes true, while the camera is metering the shot. If you used set_now during this time, I think the values would be lost. CHDK has to store new values in the propcases AFTER the camera has stored its values, or the CHDK values will be lost.

Of course, the proper way to do it is to press half_shoot and wait for get_shooting(). No script that works should be calling set_tv96 in the time between half shoot and get_shooting(), so the two methods will probably give the same result. But testing get_shooting() looks to me to be the best way to do it. Also, I have it working that way on my camera now.

Without the flag, it might break some old scripts. But if they're doing it that way, breaking them would be doing them a favor. They could take out the now unnecessary 2nd half shoot and have a better script. Do you think old scripts not working would cause a problem if I leave out the set_now_flag?
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics