root/include/conf.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef CONF_H
   2 #define CONF_H
   3 
   4 // CHDK Config items interface
   5 
   6 // Note: used in modules and platform independent code. 
   7 // Do not add platform dependent stuff in here (#ifdef/#endif compile options or camera dependent values)
   8 
   9 //==========================================================
  10 
  11 #include "stdlib.h"
  12 #include "script.h"
  13 
  14 //==========================================================
  15 
  16 #define CONF_STR_LEN        100
  17 
  18 #define CONF_EMPTY          0
  19 // regular char-int-short value
  20 #define CONF_VALUE          1
  21 #define CONF_DEF_VALUE      1
  22 // pointer to function returning int
  23 #define CONF_FUNC_PTR       2
  24 // pointer to array of int
  25 #define CONF_INT_PTR        3
  26 // pointer to the string
  27 #define CONF_CHAR_PTR       4
  28 // OSD_pos
  29 #define CONF_OSD_POS        5
  30 // Pointer to struct containing item count, item size and pointer to items
  31 #define CONF_STRUCT_PTR     6
  32 
  33 typedef struct {
  34     unsigned short  x, y;
  35 } OSD_pos;
  36 
  37 typedef struct {
  38     unsigned short  x, y;
  39 } OSD_scale;
  40 
  41 typedef struct {
  42     int isNumb, isStr, isPInt, isPos;
  43     int numb;
  44     char* str;
  45     int* pInt;
  46     OSD_pos pos;
  47 } tConfigVal;
  48 
  49 // Struct to handle variable sized arrays of 'things' in config
  50 typedef struct {
  51     int             num_items;
  52     int             item_size;
  53     int             (*saved_size)();
  54     char*           (*save)(char *dst);
  55     int             (*load)(char *src);
  56 } tVarArrayConfig;
  57 
  58 // User Menu config structures
  59 typedef struct {
  60     int     var;            // index or hash of main menu item or script
  61     char    *script_file;   // name of script file
  62     char    *script_title;  // name of script (title from script)
  63 } tUserMenuItem;
  64 
  65 typedef struct {
  66     tVarArrayConfig cfg;
  67     tUserMenuItem   *items;
  68 } tUserMenuConfig;
  69 
  70 //==========================================================
  71 
  72 // Changes to the 'conf' structure may require an update to the CONF_VERSION definition
  73 // If add field to the end of structure minor api version should be increased.
  74 // If any other change (remove something, change order, add not to the end, change meaning), major api version should be increased
  75 // Don't make any of the entries conditionally compiled in - this will change the offsets between cameras causing problems with
  76 // making the modules camera/platform independent
  77 
  78 #define CONF_VERSION            {3,3}       // Version for Conf structure
  79 
  80 typedef struct
  81 {
  82     int save_raw;
  83     int save_raw_in_video;
  84     int save_raw_in_sports;
  85     int save_raw_in_burst;
  86     int save_raw_in_edgeoverlay;
  87     int save_raw_in_auto;
  88     int save_raw_in_ev_bracketing;
  89     int save_raw_in_timer;
  90     int raw_exceptions_warn;
  91     int raw_in_dir;
  92     int raw_prefix;
  93     int raw_ext;
  94     int raw_save_first_only; //for series shooting
  95     int raw_nr;
  96     int sub_batch_prefix; // output of batch subtracts
  97     int sub_batch_ext;
  98     int raw_cache;
  99     int dng_raw;
 100     int dng_version;    // User selectable DNG version (0=1.3, 1=1.1) - select 1.1 for CHDK to do bad pixel removal (requires creation of badpixel.bin)
 101     int raw_timer;
 102     int raw_dng_ext;
 103     int dng_usb_ext;
 104     int dng_crop_size;  // User selectable DNG crop size - 0 = JPEG size (as defined in platform_camera.h), 1 = Active Area, 2 = Full sensor
 105 
 106     int show_osd;
 107     int hide_osd;
 108     int show_osd_in_review;
 109     int rotate_osd;
 110     int script_shoot_delay;
 111     int show_histo;
 112     int script_allow_lua_native_calls;
 113     char script_file[CONF_STR_LEN];
 114 
 115     int show_dof;
 116     int batt_volts_max;
 117     int batt_volts_min;
 118     int batt_perc_show;
 119     int batt_volts_show;
 120     int batt_icon_show;
 121     int space_bar_show;
 122     int space_bar_size;
 123     int space_bar_width;
 124     int space_icon_show;
 125     int show_clock;
 126     int show_temp;
 127     int temperature_unit;
 128     int clock_format;
 129     int clock_indicator;
 130     int clock_halfpress;
 131     int space_perc_show;
 132     int space_mb_show;
 133     int show_partition_nr;
 134     int space_perc_warn;
 135     int space_mb_warn;
 136     int space_warn_type;
 137     int show_movie_time;
 138     int show_movie_refresh;
 139 
 140     int zoom_value;
 141 
 142     int show_state;
 143     int show_remaining_raw;
 144     int remaining_raw_treshold;
 145     int show_raw_state;
 146     int show_values;
 147     int show_values_in_video;
 148     int show_overexp;
 149     int show_hiddenfiles;
 150 
 151     int histo_mode;
 152     int histo_auto_ajust;
 153     int histo_ignore_boundary;
 154     int histo_layout;
 155     int histo_show_ev_grid;
 156 
 157     int zebra_draw;
 158     int zebra_mode;
 159     int zebra_restore_screen;
 160     int zebra_restore_osd;
 161     int zebra_over;
 162     int zebra_under;
 163     int zebra_draw_osd;
 164     int zebra_multichannel;
 165 
 166     OSD_pos histo_pos;
 167     OSD_pos dof_pos;
 168     OSD_pos batt_icon_pos;
 169     OSD_pos space_icon_pos;
 170     OSD_pos space_hor_pos;
 171     OSD_pos space_ver_pos;
 172     OSD_pos batt_txt_pos;
 173     OSD_pos space_txt_pos;
 174     OSD_pos mode_state_pos;
 175     OSD_pos mode_raw_pos;
 176     OSD_pos values_pos;
 177     OSD_pos clock_pos;
 178     OSD_pos mode_video_pos;
 179     OSD_pos mode_ev_pos;
 180     OSD_pos temp_pos;
 181     OSD_pos ev_video_pos;
 182     OSD_pos usb_info_pos;
 183     
 184     OSD_scale histo_scale;
 185     OSD_scale dof_scale;
 186     OSD_scale batt_icon_scale;
 187     OSD_scale space_icon_scale;
 188     OSD_scale space_hor_scale;
 189     OSD_scale space_ver_scale;
 190     OSD_scale batt_txt_scale;
 191     OSD_scale space_txt_scale;
 192     OSD_scale mode_state_scale;
 193     OSD_scale mode_raw_scale;
 194     OSD_scale values_scale;
 195     OSD_scale clock_scale;
 196     OSD_scale mode_video_scale;
 197     OSD_scale mode_ev_scale;
 198     OSD_scale temp_scale;
 199     OSD_scale ev_video_scale;
 200     OSD_scale usb_info_scale;
 201 
 202     // User adjustable colors
 203     confColor histo_color;
 204     confColor histo_color2;     // markers/border
 205     confColor osd_color;
 206     confColor osd_color_warn;
 207     confColor osd_color_override;
 208     confColor space_color;
 209     confColor menu_color;
 210     confColor menu_title_color;
 211     confColor menu_cursor_color;
 212     confColor menu_symbol_color;
 213     confColor reader_color;
 214     confColor zebra_color;      // under/over
 215     confColor grid_color;
 216     confColor edge_overlay_color;
 217 
 218     int menu_center;
 219     int menu_select_first_entry;
 220     int menu_symbol_enable;
 221 
 222     int font_cp;
 223     char menu_rbf_file[CONF_STR_LEN];
 224     char menu_symbol_rbf_file[CONF_STR_LEN];
 225 
 226     char lang_file[CONF_STR_LEN];
 227 
 228     char reader_file[CONF_STR_LEN];
 229     int  reader_pos;
 230     int  reader_autoscroll;
 231     int  reader_autoscroll_delay;
 232     char reader_rbf_file[100];
 233     int  reader_codepage;
 234     int  reader_wrap_by_words;
 235 
 236     int flashlight;
 237     int fast_ev;
 238     int fast_ev_step;
 239     int fast_image_quality;
 240     int fast_movie_control;
 241     int fast_movie_quality_control;
 242     int splash_show;
 243     int start_sound;
 244     int platformid;
 245 
 246     int use_zoom_mf;
 247     long alt_mode_button; //for S-series
 248     int alt_prevent_shutdown;
 249 
 250     int show_grid_lines;
 251     char grid_lines_file[CONF_STR_LEN];
 252     int grid_force_color;
 253     char grid_title[36];
 254 
 255     int video_mode;
 256     int video_quality;
 257     int video_bitrate;
 258 
 259     int tv_bracket_value;
 260     int av_bracket_value;
 261     int iso_bracket_value;
 262     int iso_bracket_koef;
 263     int subj_dist_bracket_value;
 264     int subj_dist_bracket_koef;
 265     int bracket_type;
 266     int bracketing_add_raw_suffix;
 267     int clear_bracket;
 268     int clear_video;
 269     int override_disable;       // Uses negative/obscure logic.
 270                                 // 0 = CHDK Tv/Av/ISO/SD overrides are enabled
 271                                 // 1 = Overrides are disabled
 272                                 // 2 = Overrides are enabled and the shortcut button to enable/disable them is disabled
 273                                 // Notes: Option 2 is depracated from version 1.2
 274                                 //        Disabling these overrides does not disable Auto ISO and Bracketing overrides (see next item)
 275     int override_disable_all;   // 0 = Auto ISO and Bracketing enabled, even if other overrides disabled above
 276                                 // 1 = Auto ISO and Bracketing enabled only when other overrides are enabled
 277 
 278     int tv_override_enabled;
 279     int tv_override_value;
 280     int tv_override_long_exp;
 281     int tv_override_short_exp;
 282     int tv_enum_type;           // 0 = Ev Step, 1 = Long Exposure (HH:MM:SS), 2 = Short Exposure (0.xxxxx)
 283     int av_override_enabled;
 284     int av_override_value;
 285 
 286     int nd_filter_state;
 287 
 288     int iso_override_value;
 289     int iso_override_koef;
 290     int subj_dist_override_value;
 291     int subj_dist_override_koef;
 292     int clear_override;
 293 
 294     int autoiso_enable;
 295     int autoiso_shutter_enum;
 296     int autoiso_user_factor;
 297     int autoiso_is_factor;
 298     int autoiso_max_iso_hi;
 299     int autoiso_max_iso_auto;
 300     int autoiso_min_iso;
 301     int autoiso2_shutter_enum;
 302     int autoiso2_max_iso_auto;
 303     //AutoISO2 precalced values
 304     float autoiso2_coef;        // C2=( iso2_max_auto_real - iso_max_auto_real) / ( tv_num[autoiso_shutter] - tv_numerator[autoiso2_shutter])
 305     int autoiso_max_iso_hi_real;    // converted from GUI (possible marketing) to real iso value
 306     int autoiso_max_iso_auto_real;
 307     int autoiso_min_iso_real;
 308     int autoiso2_max_iso_auto_real;
 309     int autoiso2_over;
 310     
 311     int overexp_threshold;
 312     int overexp_ev_enum;    // 0-off, 1=-1/3, ..
 313 
 314     int dof_subj_dist_as_near_limit;
 315     int dof_use_exif_subj_dist;
 316     int dof_subj_dist_in_misc;
 317     int dof_near_limit_in_misc;
 318     int dof_far_limit_in_misc;
 319     int dof_hyperfocal_in_misc;
 320     int dof_depth_in_misc;
 321 
 322     int values_show_in_review;
 323     int values_show_zoom;
 324     int values_show_real_aperture;
 325     int values_show_real_iso;
 326     int values_show_market_iso;
 327     int values_show_iso_only_in_autoiso_mode;
 328     int values_show_ev_seted;
 329     int values_show_ev_measured;
 330     int values_show_bv_measured;
 331     int values_show_bv_seted;
 332     int values_show_overexposure;
 333     int values_show_canon_overexposure;
 334     int values_show_luminance;
 335 
 336     int debug_shortcut_action;   // 0=none, 1=dump, 2=page display
 337     int debug_display;           // 0=none, 1=props, 2=flash param, 3=tasks
 338     int debug_propcase_page;     // save propcase page
 339     int debug_lua_restart_on_error; // 0=no, 1=yes
 340     int debug_misc_vals_show;    // 0=no, 1=yes
 341 
 342     int script_startup;          // remote autostart
 343     int remote_enable;           // remote enable
 344     int user_menu_enable;
 345     int user_menu_as_root;
 346     tUserMenuConfig user_menu_vars;
 347     int zoom_scale;
 348     int unlock_optical_zoom_for_video;
 349     int mute_on_zoom;
 350     int bad_pixel_removal;
 351     int video_af_key;
 352 
 353     char curve_file[CONF_STR_LEN];
 354     int curve_enable;
 355 
 356     int edge_overlay_enable;
 357     int edge_overlay_filter;
 358     int edge_overlay_thresh;
 359     int edge_overlay_zoom;              // shall zoom be set when *edg file is loaded?
 360     int edge_overlay_pano;              // whether a full press changes back to live mode
 361     int edge_overlay_pano_overlap;      // overlap in % in pano mode
 362     int edge_overlay_show;              // whether to show overlay even when no button is pressed
 363     int edge_overlay_play;              // whether edge overlay is switched on also for play mode
 364 
 365     int synch_enable;
 366     int ricoh_ca1_mode;
 367     int synch_delay_enable;
 368     int synch_delay_value;
 369 
 370     int script_param_set;
 371     int script_param_save;
 372 
 373     long mem_view_addr_init;
 374     int flash_sync_curtain;
 375     int flash_video_override;
 376     int flash_manual_override;
 377     int flash_video_override_power;
 378     int flash_enable_exp_comp;
 379     int flash_exp_comp;
 380 
 381     // Overrides to disable touchscreen U/I components (IXUS 310)
 382     int touchscreen_disable_video_controls;
 383     int touchscreen_disable_shortcut_controls;
 384 
 385         // Enable USB icon
 386     int usb_info_enable; 
 387 
 388         // gen 2 USB remote
 389         int remote_switch_type;
 390         int remote_control_mode;
 391 
 392     int ext_video_time;
 393     
 394     int remote_enable_scripts;  // usb remote activates scripts in <ALT> mode
 395     
 396     int zoom_assist_button_disable;    // used to disable the zoom assist button on SX30 & SX40 for people who keep accidentaly pressing it
 397 
 398     int gps_record;
 399     int gps_navi_show;
 400     int gps_navi_hide;
 401     int gps_compass_show;
 402     int gps_compass_hide;
 403     int gps_coordinates_show;
 404     int gps_height_show;
 405     int gps_waypoint_save;
 406     int gps_track_time;
 407     int gps_wait_for_signal;
 408     int gps_compass_time;
 409     int gps_navi_time;
 410     int gps_wait_for_signal_time;
 411     int gps_compass_smooth;
 412     int gps_batt;
 413     int gps_countdown;
 414     int gps_2D_3D_fix;
 415     int gps_countdown_blink;
 416     int gps_rec_play_set;
 417     int gps_play_dark_set;
 418     int gps_rec_play_time;
 419     int gps_play_dark_time;
 420     int gps_rec_play_set_1;
 421     int gps_play_dark_set_1;
 422     int gps_rec_play_time_1;
 423     int gps_play_dark_time_1;
 424     int gps_show_symbol;
 425 
 426     int gps_batt_warn;
 427     int gps_track_symbol;
 428     int gps_test_timezone;
 429     int gps_beep_warn;
 430     int gps_on_off;
 431 
 432     int tbox_char_map;          // Text input box language/char map
 433     int show_alt_helper;        // Show <ALT> mode help screen
 434     int show_alt_helper_delay;  // Delay before showing help screen
 435     
 436     long extra_button; // extra button for use in ALT mode, 0 when disabled
 437 
 438     int module_logging;
 439 
 440     int enable_shortcuts;     // enable keyboard shortcuts
 441 
 442     int console_show;           // 0 = ALT mode only, 1 = always
 443     int console_timeout;        // Delay after last update to stop showing console (seconds)
 444 
 445     int memdmp_start;           // start address for memory dump
 446     int memdmp_size;            // amount of memory to dump in bytes (0 for all RAM)
 447     
 448     int remote_input_channel;   // remote input channel,  0=USB, 1=A/D
 449     
 450     int hotshoe_override;       // flash hot shoe override (0=no override, 1='not occupied', 2='occupied')
 451 
 452     int allow_unsafe_io;        // Allow open/close/write to continue if fileio_semaphore times out (instead of returning error)
 453 
 454     int disable_lfn_parser_ui;     // 0 = use built-in opendir functions for long filenames in filebrowser on dryos,
 455                                    // 1 = only use firmware opendir
 456 
 457     int enable_raw_shortcut;    // enable RAW state toggle keyboard shortcut, 0=no, 1=yes, 2=yes with RAW OSD enabled
 458 
 459     int osd_platformid; // platform ID in OSD cfg file
 460 
 461     int save_raw_in_canon_raw; // disable raw when Canon raw enabled
 462 
 463 } Conf;
 464 
 465 extern Conf conf;
 466 
 467 //==========================================================
 468 
 469 // Some macros to simplify the code
 470 
 471 // True if TV/AV/ISO/SD overrides are enabled, false if disabled (excludes Auto ISO and bracketing overrides which can be still be enabled)
 472 #define overrides_are_enabled   ( conf.override_disable != 1 )
 473 // True if Auto ISO and bracketing overrides are enabled, false if disabled
 474 #define autoiso_and_bracketing_overrides_are_enabled    ( !(conf.override_disable == 1 && conf.override_disable_all) )
 475 
 476 // True if a TV override value is set, false otherwise
 477 #define TV_OVERRIDE_EV_STEP     0
 478 #define TV_OVERRIDE_SHORT_EXP   1
 479 #define TV_OVERRIDE_LONG_EXP    2
 480 #define is_tv_override_enabled  (  conf.tv_override_enabled && overrides_are_enabled && \
 481                                     ((conf.tv_enum_type == TV_OVERRIDE_EV_STEP) || \
 482                                      (conf.tv_override_short_exp && (conf.tv_enum_type == TV_OVERRIDE_SHORT_EXP)) ||  \
 483                                      (conf.tv_override_long_exp && (conf.tv_enum_type == TV_OVERRIDE_LONG_EXP)) \
 484                                      ) \
 485                                 )
 486 // True if a AV override value is set, false otherwise
 487 #define is_av_override_enabled  ( conf.av_override_enabled && overrides_are_enabled )
 488 // True if a ISO override value is set, false otherwise
 489 #define is_iso_override_enabled ( conf.iso_override_value && conf.iso_override_koef && overrides_are_enabled )
 490 // True if a SD (subject distance) override value is set, false otherwise
 491 #define SD_OVERRIDE_OFF         0
 492 #define SD_OVERRIDE_ON          1
 493 #define SD_OVERRIDE_INFINITY    2
 494 #define is_sd_override_enabled  ( conf.subj_dist_override_value && conf.subj_dist_override_koef && overrides_are_enabled )
 495 
 496 // True if a TV bracketing value is set, false otherwise
 497 #define is_tv_bracketing_enabled  ( conf.tv_bracket_value && autoiso_and_bracketing_overrides_are_enabled )
 498 // True if a AV bracketing value is set, false otherwise
 499 #define is_av_bracketing_enabled  ( conf.av_bracket_value && autoiso_and_bracketing_overrides_are_enabled )
 500 // True if a ISO bracketing value is set, false otherwise
 501 #define is_iso_bracketing_enabled ( conf.iso_bracket_value && conf.iso_bracket_koef && autoiso_and_bracketing_overrides_are_enabled )
 502 // True if a SD (subject distance) bracketing value is set, false otherwise
 503 #define is_sd_bracketing_enabled  ( conf.subj_dist_bracket_value && conf.subj_dist_bracket_koef && autoiso_and_bracketing_overrides_are_enabled && shooting_can_focus() )
 504 
 505 #define ALT_PREVENT_SHUTDOWN_NO         0
 506 #define ALT_PREVENT_SHUTDOWN_ALT        1
 507 #define ALT_PREVENT_SHUTDOWN_ALT_SCRIPT 2
 508 #define ALT_PREVENT_SHUTDOWN_ALWAYS     3
 509 
 510 #define SHOOTING_PROGRESS_NONE          0
 511 #define SHOOTING_PROGRESS_STARTED       1
 512 #define SHOOTING_PROGRESS_PROCESSING    2
 513 #define SHOOTING_PROGRESS_DONE          3
 514 
 515 // script conf.script_startup values
 516 #define SCRIPT_AUTOSTART_NONE             0
 517 #define SCRIPT_AUTOSTART_ALWAYS           1
 518 #define SCRIPT_AUTOSTART_ONCE             2
 519 #define SCRIPT_AUTOSTART_ALT              3
 520 
 521 extern void conf_save();
 522 extern void conf_restore();
 523 extern void conf_load_defaults();
 524 extern void conf_change_dng(void);
 525 extern void conf_update_prevent_shutdown(void);
 526 extern void cb_autoiso_menu_change(unsigned int item);  // gui.c
 527 extern int conf_getValue(unsigned short id, tConfigVal* configVal);
 528 extern int conf_setValue(unsigned short id, tConfigVal configVal);
 529 extern void conf_setAutosave(int n);
 530 
 531 // reyalp: putting these in conf, since the conf values are lookups for them
 532 // prefixes and extentions available for raw images (index with conf.raw_prefix etc)
 533 #define NUM_IMG_FOLDER_NAMES 3  // 
 534 #define NUM_IMG_PREFIXES 3  // IMG_ CRW_ SND_ (could add ETC_ SDR_ AUT_ MVI_ MRK_)
 535 #define NUM_IMG_EXTS 5      // .JPG .CRW .CR2 .THM .WAV (could add .AVI .MRK)
 536 extern const char* img_folders[NUM_IMG_FOLDER_NAMES];
 537 extern const char* img_prefixes[NUM_IMG_PREFIXES];
 538 extern const char* img_exts[NUM_IMG_EXTS];
 539 
 540 // is raw data available in the current mode and not blocked by current "raw exceptions" ?
 541 extern int is_raw_enabled();
 542 // is raw data valid raw data available in the current mode
 543 extern int is_raw_possible();
 544 
 545 //-------------------------------------------------------------------
 546 
 547 typedef struct {
 548     unsigned short      id;
 549     unsigned char       size;
 550     char                type;
 551     void                *var;
 552     union {
 553         void            *ptr;
 554         int             i;
 555         confColor       cl;
 556         OSD_pos         pos;
 557         OSD_scale       scale;
 558         long            (*func)(void);
 559     };
 560     unsigned int        last_saved;     // Record last value saved to file to determine if file needs updating
 561 } ConfInfo;
 562 
 563 #define CONF_INFO(id, param, type, def)             { id, sizeof( param ), type, &param, {def}, 0 }
 564 #define CONF_INFO2(id, param, type, px, py)         { id, sizeof( param ), type, &param, {pos:{px,py}}, 0 }
 565 #define CONF_INFOC(id, param, type, bc, fc, bt, ft) { id, sizeof( param ), type, &param, {cl:{fg:{fc,ft},bg:{bc,bt}}}, 0 }
 566 
 567 extern void config_save(ConfInfo *conf_info, const char *filename, int config_base);
 568 extern void config_restore(ConfInfo *confinfo, const char *filename, void (*info_func)(unsigned short id));
 569 
 570 extern int save_config_file(int config_base, const char *filename);
 571 extern int load_config_file(int config_base, const char *filename);
 572 
 573 extern void resetColors();
 574 
 575 //-------------------------------------------------------------------
 576 
 577 #endif

/* [<][>][^][v][top][bottom][index][help] */