Changeset 1570 for trunk


Ignore:
Timestamp:
01/16/12 09:46:33 (16 months ago)
Author:
philmoz
Message:

Add support for cameras that allow subject distance overrides greater than the current max value of 65535.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/gui.c

    r1569 r1570  
    183183static const char* gui_tv_override_value_enum(int change, int arg); 
    184184static const char* gui_tv_enum_type_enum(int change, int arg); 
    185 static const char* gui_subj_dist_override_value_enum(int change, int arg); 
    186 static const char* gui_subj_dist_override_koef_enum(int change, int arg); 
     185const char* gui_subj_dist_override_value_enum(int change, int arg); 
     186const char* gui_subj_dist_override_koef_enum(int change, int arg); 
    187187/* 
    188188static const char* gui_tv_exposure_order_enum(int change, int arg); 
     
    232232const char* gui_USB_switch_types[] = { "None","OnePush", "TwoPush", "CA-1", "P Width", "P Count" }; 
    233233const char* gui_USB_control_modes[] = { "None", "Normal", "Quick", "Burst", "Bracket","Zoom", "Video","gWIRE","Script" };  
    234  
     234   
    235235 
    236236static CMenuItem remote_submenu_items[] = { 
     
    12141214 
    12151215const char* gui_subj_dist_override_value_enum(int change, int arg) { 
    1216         static const int koef[] = {0, 1,10,100,1000}; 
    1217     static char buf[8]; 
    1218     conf.subj_dist_override_value+=(change*koef[conf.subj_dist_override_koef]); 
    1219     if (conf.subj_dist_override_value<0) 
    1220         conf.subj_dist_override_value=MAX_DIST; 
    1221     else if (conf.subj_dist_override_value>MAX_DIST) 
    1222         conf.subj_dist_override_value=0; 
    1223     sprintf(buf, "%d", (int)conf.subj_dist_override_value); 
     1216        int koef = shooting_get_subject_distance_override_koef(); 
     1217    static char buf[9]; 
     1218    if (koef == -1) 
     1219    { 
     1220        // If 'Infinity' selected in the 'koef' setting then set SD to the infinity value 
     1221        // technically the same as MAX_DIST when it's sent to the firmware function  
     1222        // in the camera; but used here to alter the CHDK OSD display. 
     1223        conf.subj_dist_override_value = INFINITY_DIST; 
     1224    } 
     1225    else 
     1226    { 
     1227        // Increment / decrement the SD value, wrapping around from MIN_DIST to MAX_DIST 
     1228        conf.subj_dist_override_value += (change*koef); 
     1229        if (conf.subj_dist_override_value < MIN_DIST) 
     1230            conf.subj_dist_override_value = MAX_DIST; 
     1231        else if (conf.subj_dist_override_value > MAX_DIST) 
     1232            conf.subj_dist_override_value = MIN_DIST; 
     1233    } 
     1234    if (conf.subj_dist_override_value == INFINITY_DIST) 
     1235        strcpy(buf,"Inf."); 
     1236    else 
     1237        sprintf(buf, "%d", (int)conf.subj_dist_override_value); 
    12241238    return buf; 
    12251239} 
     
    12271241 
    12281242const char* gui_subj_dist_override_koef_enum(int change, int arg) { 
    1229         return gui_change_simple_enum(&conf.subj_dist_override_koef,change,gui_override_koef_modes,sizeof(gui_override_koef_modes)/sizeof(gui_override_koef_modes[0])); 
     1243    // Define the adjustment factor values for the subject distance override 
     1244#if MAX_DIST > 1000000      // Superzoom - e.g. SX30, SX40 
     1245    static const char* modes[] = { "Off", "1", "10", "100", "1000", "10K", "100K", "1M", "Inf." }; 
     1246#elif MAX_DIST > 100000     // G12, IXUS310 
     1247    static const char* modes[] = { "Off", "1", "10", "100", "1000", "10K", "100K", "Inf." }; 
     1248#else                       // Original values (MAX_DIST = 65535) 
     1249    static const char* modes[] = { "Off", "1", "10", "100", "1000" }; 
     1250#endif 
     1251        const char *rv = gui_change_simple_enum(&conf.subj_dist_override_koef,change,modes,sizeof(modes)/sizeof(modes[0])); 
     1252    // If we've selected 'Infinity' focus then set the SD override value 
     1253    // Otherwise if we had previously selected 'Infinity' then reset back to MAX_DIST 
     1254    if (shooting_get_subject_distance_override_koef() == -1) 
     1255        conf.subj_dist_override_value = INFINITY_DIST; 
     1256    else if (conf.subj_dist_override_value == INFINITY_DIST) 
     1257        conf.subj_dist_override_value = MAX_DIST; 
     1258    return rv; 
    12301259} 
    12311260 
     
    16651694    gui_subj_dist_override_koef_enum(direction,0); 
    16661695#if !CAM_HAS_MANUAL_FOCUS 
    1667     if (conf.subj_dist_override_koef==0) conf.subj_dist_override_koef=1; 
     1696    if (conf.subj_dist_override_koef==0) gui_subj_dist_override_koef_enum(direction,0); 
    16681697#endif 
    16691698    shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW); 
     
    17051734            shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW); 
    17061735#else 
    1707             if (conf.subj_dist_override_koef==4) 
    1708                 gui_subj_dist_override_koef_enum(-3,0); 
    1709             else 
    1710                 gui_subj_dist_override_koef_enum(1,0); 
     1736            gui_subj_dist_override_koef_enum(1,0); 
    17111737#endif 
    17121738        } 
  • trunk/core/gui_osd.c

    r1569 r1570  
    601601            gui_print_osd_state_string_chr("AUTOISO:", ((conf.autoiso_enable==1)?"ON":"OFF")); 
    602602    if ((conf.subj_dist_override_value && conf.subj_dist_override_koef && shooting_can_focus() && !(conf.override_disable==1)) || ((gui_get_mode()==GUI_MODE_ALT) && shooting_get_common_focus_mode())  || gui_mode==GUI_MODE_OSD)   { 
    603         gui_print_osd_state_string_int("SD:",shooting_get_subject_distance_override_value()); 
     603        extern const char* gui_subj_dist_override_value_enum(int change, int arg); 
     604        extern const char* gui_subj_dist_override_koef_enum(int change, int arg); 
     605        gui_print_osd_state_string_chr("SD:",gui_subj_dist_override_value_enum(0,0)); 
    604606        if (gui_mode==GUI_MODE_ALT)   
    605                   gui_print_osd_state_string_int("FACTOR:",shooting_get_subject_distance_override_koef());       
     607                  gui_print_osd_state_string_chr("FACTOR:",gui_subj_dist_override_koef_enum(0,0)); 
    606608      } 
    607609    if ((conf.iso_override_value && conf.iso_override_koef && !(conf.override_disable==1))       || gui_mode==GUI_MODE_OSD) 
  • trunk/core/luascript.c

    r1569 r1570  
    581581    else shooting_set_focus(to, SET_LATER); 
    582582#else 
    583     if (mode_video) shooting_set_focus(to, SET_NOW); 
     583    if (shooting_get_common_focus_mode() || mode_video) shooting_set_focus(to, SET_NOW); 
    584584    else shooting_set_focus(to, SET_LATER);     
    585585#endif     
  • trunk/include/camera.h

    r1527 r1570  
    189189 
    190190#define CAM_USB_EVENTID         0x902           // Levent ID for USB control. Changed to 0x202 in DryOS R49 so needs to be overridable. 
     191 
     192#undef CAM_NEED_SET_ZOOM_DELAY                  // Define to add a delay after setting the zoom position before resetting the focus position in shooting_set_zoom 
     193 
     194#define CAMERA_MIN_DIST         0               // Define min distance that can be set in _MoveFocusLensToDistance (allow override - e.g. G12 min dist = 1) 
     195#define CAMERA_MAX_DIST         65535           // Define max distance that can be set in _MoveFocusLensToDistance (allow override for superzooms - SX30/SX40) 
    191196 
    192197//---------------------------------------------------------- 
  • trunk/include/platform.h

    r1569 r1570  
    3333#endif 
    3434 
    35 #define MAX_DIST 65535 
    36 #define MAX_DIST_HYPER_FOCAL 999999 
     35#define MIN_DIST                CAMERA_MIN_DIST     // Defined in camera.h (can be overridden in platform_camera.h) 
     36#define MAX_DIST                CAMERA_MAX_DIST     // Defined in camera.h (can be overridden in platform_camera.h) 
     37#define INFINITY_DIST           0xFFFFFFFF          // Value to send to firmware to select 'infinity' focus 
     38#define MAX_DIST_HYPER_FOCAL    999999 
    3739 
    3840//******************** 
  • trunk/platform/g12/platform_camera.h

    r1555 r1570  
    125125//      #define REMOTE_SYNC_STATUS_LED  0xC0xxyyyy              // specifies an LED that turns on while camera waits for USB remote to sync 
    126126 
     127    #undef CAMERA_MIN_DIST 
     128    #define CAMERA_MIN_DIST                 68      // Override min subject distance 
     129    #undef CAMERA_MAX_DIST 
     130    #define CAMERA_MAX_DIST                 258065  // Override max subject distance 
     131 
    127132//---------------------------------------------------------- 
    128133 
  • trunk/platform/generic/shooting.c

    r1568 r1570  
    764764    return 1; 
    765765 #endif 
    766   return (shooting_get_focus_mode() || MODE_IS_VIDEO(m)); 
     766  return (shooting_get_common_focus_mode() || MODE_IS_VIDEO(m)); 
    767767#elif !CAM_CAN_SD_OVERRIDE 
    768768  return MODE_IS_VIDEO(m); 
     
    938938    dist = shooting_get_focus(); 
    939939    lens_set_zoom_point(v); 
     940#if defined(CAM_NEED_SET_ZOOM_DELAY) 
     941    msleep(CAM_NEED_SET_ZOOM_DELAY); 
     942#endif 
    940943    shooting_set_focus(dist, SET_NOW); 
    941944  } 
     
    964967        if ((is_now) && shooting_can_focus()) { 
    965968          if (conf.dof_dist_from_lens) s+=shooting_get_lens_to_focal_plane_width(); 
    966           if ((!conf.dof_subj_dist_as_near_limit) && (s>0)) lens_set_focus_pos((s<MAX_DIST)?s:MAX_DIST); 
     969          if (!conf.dof_subj_dist_as_near_limit) lens_set_focus_pos(s); 
    967970          else { 
    968971        int near=shooting_get_near_limit_f(s,shooting_get_min_real_aperture(),get_focal_length(lens_get_zoom_point())); 
    969         if (near>0) lens_set_focus_pos((near<MAX_DIST)?near:MAX_DIST); 
     972        if (near>0) lens_set_focus_pos(near); 
    970973          } 
    971974        } 
     
    10841087int shooting_get_subject_distance_override_koef() 
    10851088{ 
    1086   static const short koef[] = {0, 1,10,100,1000}; 
     1089    // Define the adjustment factor values for the subject distance override 
     1090#if MAX_DIST > 1000000      // Superzoom - e.g. SX30, SX40 
     1091  static const int koef[] = {0,1,10,100,1000,10000,100000,1000000,-1}; 
     1092#elif MAX_DIST > 100000     // G12, IXUS310 
     1093  static const int koef[] = {0,1,10,100,1000,10000,100000,-1}; 
     1094#else                       // Original values (MAX_DIST = 65535) 
     1095  static const int koef[] = {0,1,10,100,1000}; 
     1096#endif 
    10871097  return koef[(conf.subj_dist_override_koef)]; 
    1088  
    10891098} 
    10901099 
  • trunk/platform/generic/wrappers.c

    r1569 r1570  
    182182                zoom_status=ZOOM_OPTICAL_MAX; 
    183183 
    184   #if defined(CAMERA_g12)|| defined(CAMERA_g10)  
     184  #if defined(CAMERA_g12)|| defined(CAMERA_g10) 
    185185            _SetPropertyCase(PROPCASE_OPTICAL_ZOOM_POSITION, &newpt, sizeof(newpt)); 
    186186  #endif 
     
    212212void lens_set_focus_pos(long newpos) 
    213213{ 
    214         _MoveFocusLensToDistance((short*)&newpos); 
    215         //while (focus_busy); 
    216         while ((shooting_is_flash_ready()!=1) || (focus_busy)); 
     214    if (newpos >= MAX_DIST) newpos = INFINITY_DIST; // Set to infinity value that will work on all cameras 
     215    _MoveFocusLensToDistance((short*)&newpos); 
     216        while ((shooting_is_flash_ready()!=1) || (focus_busy)) msleep(10); 
    217217        newpos = _GetFocusLensSubjectDistance(); 
    218218        _SetPropertyCase(PROPCASE_SUBJECT_DIST1, &newpos, sizeof(newpos)); 
  • trunk/platform/ixus310_elph500hs/platform_camera.h

    r1555 r1570  
    127127 
    128128//      #define REMOTE_SYNC_STATUS_LED  0xC0xxyyyy              // specifies an LED that turns on while camera waits for USB remote to sync 
    129          
     129 
     130    #undef CAMERA_MIN_DIST 
     131    #define CAMERA_MIN_DIST                 71      // Override min subject distance 
     132    #undef CAMERA_MAX_DIST 
     133    #define CAMERA_MAX_DIST                 125392  // Override max subject distance 
     134 
    130135//---------------------------------------------------------- 
    131136 
  • trunk/platform/sx30/platform_camera.h

    r1555 r1570  
    124124 
    125125//      #define REMOTE_SYNC_STATUS_LED  0xC0xxyyyy              // specifies an LED that turns on while camera waits for USB remote to sync 
    126          
     126 
     127    #define CAM_NEED_SET_ZOOM_DELAY         300     // SX30 needs a short delay after setting the zoom before resetting focus in shooting_set_zoom() 
     128 
     129    #undef CAMERA_MIN_DIST 
     130    #define CAMERA_MIN_DIST                 95      // Override min subject distance 
     131    #undef CAMERA_MAX_DIST 
     132    #define CAMERA_MAX_DIST                 9090910 // Override max subject distance 
     133 
    127134//---------------------------------------------------------- 
  • trunk/platform/sx40hs/platform_camera.h

    r1555 r1570  
    133133  
    134134//      #define REMOTE_SYNC_STATUS_LED  0xC0xxyyyy              // specifies an LED that turns on while camera waits for USB remote to sync 
    135   
     135 
     136    #undef CAMERA_MIN_DIST 
     137    #define CAMERA_MIN_DIST                 95      // Override min subject distance 
     138    #undef CAMERA_MAX_DIST 
     139    #define CAMERA_MAX_DIST                 9523810 // Override max subject distance 
     140     
    136141//---------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.