Setting focus from scripts or menus - page 27 - General Discussion and Assistance - CHDK Forum

Setting focus from scripts or menus

  • 556 Replies
  • 137911 Views
*

Offline reyalp

  • ******
  • 13454
Re: Setting focus from scripts or menus : please run this script and report back
« Reply #260 on: 22 / February / 2014, 17:39:26 »
Advertisements
The values for CAM_SD_OVER_ENABLE_METHOD are :
Code: [Select]
   0=none
   1=set_aflock() 
   2=Press_SW1_and_MF 
   3=SS.Create&SS.MFOn 
   4=SS.Create&PT_MFOn 
   5=RegisterShootSeqEvent&PT_MFOn
   6=RegisterShootSeqEvent&MFOn
3-6 should probably have the On/Off eventprocs in stubs, and not call the registration functions. We may still need to select the correct *MFOn variant if multiple exist on the same camera but only one works.

We also discussed movie mode a bit. The initial plan is just to allow sd override to be attempted if in movie mode. We can revisit this once the still mode code is sorted out.
Don't forget what the H stands for.

Re: Setting focus from scripts or menus : proposed changes to shooting.c
« Reply #261 on: 23 / February / 2014, 11:55:07 »
Well,  I think we have a good start on step 1 - fixing up the routines in shooting.c.  I'm pretty excited - props to reyalp for walking through this with me on IRC.  It's turned out to be a lot cleaner than I thought it would be.

Here's the new version of shooting_can_focus() :

Code: [Select]
short shooting_can_focus()
{
    if( camera_info.state.mode_video == 1) return 1;           // FIXME : default to MF enabled in video mode for now
#ifdef PROPCASE_CONTINUOUS_AF
    if (shooting_get_prop(PROPCASE_CONTINUOUS_AF)) return 0;   // don't focus in continuous AF mode
#endif
#ifdef PROPCASE_SERVO_AF
    if (shooting_get_prop(PROPCASE_SERVO_AF)) return 0;        // don't focus in servo AF mode
#endif
#ifdef CAM_SD_OVER_IN_AF
    if (    (shooting_get_prop(PROPCASE_AF_LOCK)==0)           // allow focus when in AF mode (i.e AFL or MF not enabled)?
         && (shooting_get_prop(PROPCASE_FOCUS_MODE)==0 )) return 1;
#endif
#ifdef CAM_SD_OVER_IN_AFL
    if (shooting_get_prop(PROPCASE_AF_LOCK)==1 ) return 1;     // allow focus if AFL enabled and camera can focus that way?
#endif
#ifdef CAM_SD_OVER_IN_MF
    if (shooting_get_prop(PROPCASE_FOCUS_MODE)==1 ) return 1;  // allow focus if MF enabled and camera can focus that way?
#endif
    return 0;
}
where we have this in camera.h :

Code: [Select]
    #define CAM_HAS_MANUAL_FOCUS            1   // Camera has native manual focus mode (disables MF shortcut feature)
    #define CAM_CAN_SD_OVERRIDE             1   // Camera allowed to do subject distance override
    #undef  CAM_SD_OVER_IN_AF                   // Camera allows SD override if MF & AFL not set
    #undef  CAM_SD_OVER_IN_AFL                  // Camera allows SD override when AFL is set
    #undef  CAM_SD_OVER_IN_MF                   // Camera allows SD override when MF is set 
    #undef  CAM_SD_OVER_ENABLE_METHOD           // Method used to enable camera SD override.

The attached patch file implements the new code and I've tested it with my G10 and A1200   I also tweaked the underlying code for set_aflock() to set/reset PROPCASE_AF_LOCK when its called.  Support for CAM_SD_OVER_ENABLE_METHOD  is on the "todo" list still.

Before I make the necessary changes to all 123 platform_camera.h files,  it would be good for someone else to take a look at this.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 13454
Re: Setting focus from scripts or menus : please run this script and report back
« Reply #262 on: 23 / February / 2014, 16:17:34 »
This looks like a good start :)

The camera.h defaults seem confusing to me
Code: [Select]
+    #define CAM_CAN_SD_OVERRIDE             1   // Camera allowed to do subject distance override
+    #undef  CAM_SD_OVER_IN_AF                   // Camera allows SD override if MF & AFL not set
+    #undef  CAM_SD_OVER_IN_AFL                  // Camera allows SD override when AFL is set
+    #undef  CAM_SD_OVER_IN_MF                   // Camera allows SD override when MF is set 
CAM_CAN_SD_OVERRIDE seems like it should just become ( CAM_SD_OVER_IN_AF || CAM_SD_OVER_IN_AFL || CAM_SD_OVER_IN_MF)

For CAM_SD_OVER_ENABLE_METHOD I'd suggest symbolic names, if(CAM_SD_OVER_ENABLE_METHOD == SD_OVERRIDE_METHOD_AFLOCK) is going to be much easier to follow than  if(CAM_SD_OVER_ENABLE_METHOD == 2).

As we discussed on IRC, we may want a special define for untested / unknown cams.
Don't forget what the H stands for.

Re: Setting focus from scripts or menus : please run this script and report back
« Reply #263 on: 23 / February / 2014, 16:33:44 »
CAM_CAN_SD_OVERRIDE seems like it should just become ( CAM_SD_OVER_IN_AF || CAM_SD_OVER_IN_AFL || CAM_SD_OVER_IN_MF)
It's a holdover from the current code.  And if you grep it,  you find that it's perhaps most useful as #undef CAM_CAN_SD_OVERRIDE for cams that do not support SD override at all.  Replacing it with the logical OR of the other three conditions looks kind of messy there.
Quote
For CAM_SD_OVER_ENABLE_METHOD I'd suggest symbolic names, if(CAM_SD_OVER_ENABLE_METHOD == SD_OVERRIDE_METHOD_AFLOCK) is going to be much easier to follow than  if(CAM_SD_OVER_ENABLE_METHOD == 2).
Agreed - I expected that we would end up there when I mentioned  that "Support for CAM_SD_OVER_ENABLE_METHOD  is on the "todo" list still".    After the last couple of lengthy forum threads about new script functions and their names I planned to leave that to last  ;)

Quote
As we discussed on IRC, we may want a special define for untested / unknown cams.
IIRC, that discussion was in the context of adding something to UI to indicate that the camera needs testing / SD override is disabled.  Something to encourage the user to help out with the testing by posting results to the forum so that his/her camera can be properly enabled.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Setting focus from scripts or menus : please run this script and report back
« Reply #264 on: 23 / February / 2014, 17:15:41 »
Ixus230/elph310hs if you still need it.

*

Offline reyalp

  • ******
  • 13454
Re: Setting focus from scripts or menus : please run this script and report back
« Reply #265 on: 23 / February / 2014, 17:20:41 »
CAM_CAN_SD_OVERRIDE seems like it should just become ( CAM_SD_OVER_IN_AF || CAM_SD_OVER_IN_AFL || CAM_SD_OVER_IN_MF)
It's a holdover from the current code.  And if you grep it,  you find that it's perhaps most useful as #undef CAM_CAN_SD_OVERRIDE for cams that do not support SD override at all.  Replacing it with the logical OR of the other three conditions looks kind of messy there.
I am not fond of defines that can be setup to have contradictory values, and I am even less fond of setting the defaults to be that way...

What does it mean to define  CAM_CAN_SD_OVERRIDE and not define any CAM_SD_OVER_IN*?
What does it mean to undefine CAM_CAN_SD_OVERRIDE but define some of the CAM_SD_OVER_IN*?

If different parts of the code check different combinations, this will continue the kind of mess we have now.

If you want to keep it to avoid dealing with the things that check #ifdef CAM_CAN_SD_OVERRIDE right now (very reasonable), make it conditionally confined in camera.h *below* the platform include,
Code: [Select]
#if defined(CAM_SD_OVER_IN_AF) || defined(CAM_SD_OVER_IN_AF) || (CAM_SD_OVER_IN_MF)
#define CAM_CAN_SD_OVERRIDE
#else
#undef CAM_CAN_SD_OVERRIDE
#endif

You could set up #error checks for contradictory values instead, but I think this is worse, because it still puts redundant values in platform_camera.h

Quote
Quote
As we discussed on IRC, we may want a special define for untested / unknown cams.
IIRC, that discussion was in the context of adding something to UI to indicate that the camera needs testing / SD override is disabled.  Something to encourage the user to help out with the testing by posting results to the forum so that his/her camera can be properly enabled.
Yes, what I was getting at is if you are going to go through all the platform_camera.h files, and already have a list, it might be worth defining it now.

edit:
And thanks again for working on this. I may be a picky SOB, but I really, really appreciate all the work you have put into this :)
Don't forget what the H stands for.

Re: Setting focus from scripts or menus : please run this script and report back
« Reply #266 on: 23 / February / 2014, 17:30:50 »
and the G11

Re: Setting focus from scripts or menus : please run this script and report back
« Reply #267 on: 23 / February / 2014, 17:53:21 »
ixus125/elph110hs

crashed on set_aflock() and PT_MFOn


Re: Setting focus from scripts or menus : please run this script and report back
« Reply #268 on: 23 / February / 2014, 18:13:27 »
If you want to keep it to avoid dealing with the things that check #ifdef CAM_CAN_SD_OVERRIDE right now (very reasonable), make it conditionally confined in camera.h *below* the platform include,
Code: [Select]
#if defined(CAM_SD_OVER_IN_AF) || defined(CAM_SD_OVER_IN_AF) || defined (CAM_SD_OVER_IN_MF)
#define CAM_CAN_SD_OVERRIDE 1
#else
#undef CAM_CAN_SD_OVERRIDE
#endif
FTFY.    But it's a bit messy as it needs to go into every platform_camera.h rather than camera.h (the C preprocessor is a one-pass thing IIRC).

But looking at the code,  there are only two cameras that #undef CAM_CAN_SD_OVERRIDE.  If we just remove the value completely,  and don't define any CAN_CAN_OVERRIDE_IN_*'s for those two cameras, then I think that's probably okay.

Quote
Yes, what I was getting at is if you are going to go through all the platform_camera.h files, and already have a list, it might be worth defining it now.
I'll add a #define CAM_CAN_SD_OVERRIDE_UNKNOWN_STATUS 1 to the platform_camera.h for the 36 34 cameras we don't have test results for yet. 

We can talk about adding an annoying popup thingy later.

Do you have a preference between guessing the right values for the three #defines,  or just enabling all three,  or disabling all three?

Quote
edit: And thanks again for working on this. I may be a picky SOB, but I really, really appreciate all the work you have put into this
Picky?  You don't even enforce white space and bracketing conventions.  How can you consider yourself to be picky?  :P
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 13454
Re: Setting focus from scripts or menus : please run this script and report back
« Reply #269 on: 23 / February / 2014, 18:30:41 »
FTFY.    But it's a bit messy as it needs to go into every platform_camera.h rather than camera.h (the C preprocessor is a one-pass thing IIRC).
No. It would work fine if you put it below the platform_camera.h include in camera.h (platform_camera.h should NEVER be included on it's own)
Don't forget what the H stands for.

 

Related Topics